The first case was getting treated like a variable binding, meaning that if e had a destructor, it wouldn't run until the end of the enclosing scope. To me it seems less confusing for let _ = e; and e; to work exactly the same way, so now, the destructor for e runs immediately in both cases.
15 lines
277 B
Rust
15 lines
277 B
Rust
// This test should behave exactly like issue-2735-3
|
|
class defer {
|
|
let b: &mut bool;
|
|
new(b: &mut bool) {
|
|
self.b = b;
|
|
}
|
|
drop { *(self.b) = true; }
|
|
}
|
|
|
|
fn main() {
|
|
let mut dtor_ran = false;
|
|
let _ = defer(&mut dtor_ran);
|
|
assert(dtor_ran);
|
|
}
|