Skip to content

FSU doesn't run destructors of temporaries #17302

Closed
@alexcrichton

Description

@alexcrichton
struct A(int);
struct Foo { _a: A, _b: int }

impl Drop for A {
    fn drop(&mut self) {
        let A(i) = *self;
        println!("dropping {}", i);
    }
}

fn main() {
    Foo {
        _a: A(1),
        ..Foo { _a: A(2), _b: 2 }
    };
}
$ rustc foo.rs && ./foo 
dropping 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-destructorsArea: Destructors (`Drop`, …)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions