Skip to content

"let _ = foo" destructor semantics is broken #8194

@bblum

Description

@bblum

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);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationA-destructorsArea: Destructors (`Drop`, …)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions