Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Possible to call Drop::drop more than once on the same value using the UFCS notation #19375

Closed
ftxqxd opened this issue Nov 28, 2014 · 0 comments · Fixed by #19587
Closed

Possible to call Drop::drop more than once on the same value using the UFCS notation #19375

ftxqxd opened this issue Nov 28, 2014 · 0 comments · Fixed by #19587
Assignees
Labels
A-destructors Area: Destructors (`Drop`, …)

Comments

@ftxqxd
Copy link
Contributor

ftxqxd commented Nov 28, 2014

foo.drop() currently errors with explicit call to destructor, which is good, but the error does not fire for UFCS-style Drop::drop(&mut foo) calls, leading to the ability to call a value’s destructor more than once:

struct Bass;

impl Drop for Bass {
    fn drop(&mut self) {
        println!("D-D-D-D-DROP THE BASS");
    }
}

fn main() {
    let mut bass = Bass;
    Drop::drop(&mut bass);
    Drop::drop(&mut bass);
    Drop::drop(&mut bass);
}
@huonw huonw added I-nominated A-destructors Area: Destructors (`Drop`, …) labels Nov 28, 2014
@huonw huonw self-assigned this Dec 5, 2014
huonw added a commit to huonw/rust that referenced this issue Dec 6, 2014
detect UFCS drop and allow UFCS methods to have explicit type parameters.

Work towards rust-lang#18875.

Since code could previously call the methods & implement the traits
manually, this is a

[breaking-change]

Closes rust-lang#19586. Closes rust-lang#19375.
alexcrichton added a commit to alexcrichton/rust that referenced this issue Dec 9, 2014
detect UFCS drop and allow UFCS methods to have explicit type parameters.

Work towards rust-lang#18875.

Since code could previously call the methods & implement the traits
manually, this is a

[breaking-change]

Closes rust-lang#19586. Closes rust-lang#19375.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-destructors Area: Destructors (`Drop`, …)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants