-
Notifications
You must be signed in to change notification settings - Fork 13.3k
if true { ... } runs destructors twice #10734
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
Comments
(editing previous comment about unsure destructors are running twice) Correction, I'm now 100% sure that destructors are running twice: struct Foo;
impl Drop for Foo {
fn drop(&mut self) {
println!("dropping");
}
}
fn main() {
if true {
let _a = Foo;
}
} That code prints |
struct Foo;
impl Drop for Foo {
fn drop(&mut self) {
println("dropping");
}
}
fn main() {
let x = true;
if x {
let a = Foo;
}
} does not reproduce. Also cannot reproduce on 0.8; bisecting. |
I can't reproduce with |
My bisection says #9751 broke it. |
Disabling the |
However, with |
Whoa.
drops a whopping three times. |
Turns out `with_scope` already translates destructors, so by manually translating destructors we end up running them all twice (bad). Closes #10734
Update macros.rs (typo) r? `@Alexendoo` changelog: none
Doesn't get much worse than that. Nominating because this is terrible.
The text was updated successfully, but these errors were encountered: