Skip to content

"path statement with no effect" issued even when drop makes effect #48852

Closed
@vi

Description

@vi
struct Droppy;

impl Drop for Droppy {
    fn drop(&mut self) {
        println!("2");
    }
}

fn main() {
    let q = Droppy;
    (||{
        println!("1");
        q;
    })();
    println!("3");
}

(playground link)

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

Removing the "no effect" line definitely has effect.

The warning may instead suggest to explicitly use std::mem::drop if that is what is needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-destructorsArea: Destructors (`Drop`, …)A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions