Skip to content

Destructors do not run when implemented on unit-like structs #6861

Closed
@bstrie

Description

@bstrie
struct Bomb;

impl Drop for Bomb {
    fn finalize(&self) {
        println("Somebody set up us the bomb!");  // this is never printed
    }
}

fn main() {
    let b = Bomb;
    println(fmt!("b = %?", b));
}

Adding a single field like { a: int } to the struct makes it print the expected message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions