rust/src/test/run-pass/issue-2735-2.rs
Tim Chevalier febd7ee239 Make let _ = e; have the same semantics as e;
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.
2012-08-08 15:37:45 -07:00

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);
}