-
Notifications
You must be signed in to change notification settings - Fork 13k
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
MIR dynamic drop flags cause spurious extra drops with optimizations on. #38437
Comments
From my testing I found that the write in |
cc @rust-lang/compiler |
struct Good(usize);
impl Drop for Good {
#[inline(never)]
fn drop(&mut self) {
println!("dropping Good({})", self.0);
}
}
struct Bad(usize);
impl Drop for Bad {
#[inline(never)]
fn drop(&mut self) {
println!("dropping Bad({})", self.0);
}
}
enum E { A(Bad), B(Good) }
fn main() {
let mut go = true;
loop {
let next;
match go {
true => next = E::B(Good(123)),
false => return,
}
match next {
E::A(_) => return,
E::B(_good) => go = false,
}
}
} Prints, on stable, beta and nightly, with optimizations on:
Looking at post-drop-elaboration MIR, there's a drop flag for This is why there's no bug with optimizations off. The problem with that though is the |
triage: P-high @arielb1 will investigate, as he is the dynamic drop master :) |
This program generates an assertion failure on nightly Rust:
The assertion in the destructor of the main function should never trip, but something's tripping it! This is an adapted test case from rust-lang/futures-rs#296, and although the original issue reproduces on stable/beta/nightly this test case only reproduces on nightly:
The text was updated successfully, but these errors were encountered: