Skip to content

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

@bstrie

Description

@bstrie
Contributor
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.

Activity

added a commit that references this issue on Jun 1, 2013
c35b7b5
added a commit that references this issue on Jun 1, 2013
luqmana

luqmana commented on Jun 1, 2013

@luqmana
Member

Fixed by #6889.

added a commit that references this issue on Jul 11, 2024
0abcd34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

        Participants

        @luqmana@bstrie

        Issue actions

          Destructors do not run when implemented on unit-like structs · Issue #6861 · rust-lang/rust