Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
bstrie opened this issue May 31, 2013 · 1 comment
Closed

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

bstrie opened this issue May 31, 2013 · 1 comment

Comments

@bstrie
Copy link
Contributor

bstrie commented May 31, 2013

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.

@luqmana
Copy link
Member

luqmana commented Jun 1, 2013

Fixed by #6889.

@luqmana luqmana closed this as completed Jun 1, 2013
flip1995 pushed a commit to flip1995/rust that referenced this issue Jul 11, 2024
Implement a lint to replace manual bit rotations with rotate_left/rot…

Fixes rust-lang#6861

r? `@llogiq`

---

changelog: add [`manual_rotate`] lint
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants