Skip to content

Wrong path statement warning with constant implementing Drop #71837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tspiteri opened this issue May 3, 2020 · 1 comment
Closed

Wrong path statement warning with constant implementing Drop #71837

tspiteri opened this issue May 3, 2020 · 1 comment
Labels
C-bug Category: This is a bug.

Comments

@tspiteri
Copy link
Contributor

tspiteri commented May 3, 2020

This program prints dropped as the constant is copied and dropped.

struct S;
impl Drop for S {
    fn drop(&mut self) {
        println!("dropped")
    }
}
const C: S = S;
fn main() {
    C;
}

That means that the statement C; does have an effect: it prints dropped. But the compiler warns that the statement has no effect:

warning: path statement with no effect
 --> src/main.rs:9:5
  |
9 |     C;
  |     ^^
  |
  = note: `#[warn(path_statements)]` on by default

(Reproduced on stable 1.43.0 and nightly 2020-05-02.)

@tspiteri tspiteri added the C-bug Category: This is a bug. label May 3, 2020
@jonas-schievink
Copy link
Contributor

Duplicate of #48852

@jonas-schievink jonas-schievink marked this as a duplicate of #48852 May 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants