rust-lang/rust

"let _ = foo" destructor semantics is broken

bblum opened this issue · 1 comments

What this ought to do in the long term is under discussion in #3181, but I'm pretty sure some bug broke the current behaviour.

Test case:

struct Foo;

impl Drop for Foo {
    fn drop(&self) {
        error!("this oughta happen first");
    }
}

fn foo(foo: Foo) {
    // { use std::util; util::ignore(foo); } // this works as expected
    let _ = foo; // this doesn't
    // { let _ = foo; } // behaves the same as without the braces
    error!("this oughta happen second");
}

fn main() {
    foo(Foo);
}

Closing as a dupe of #10488.