]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-26655.rs
Require Drop impls to have the same constness on its bounds as the bounds on the...
[rust.git] / src / test / ui / issues / issue-26655.rs
1 // run-pass
2 // needs-unwind
3 // ignore-emscripten no threads support
4
5 // Check that the destructors of simple enums are run on unwinding
6
7 use std::sync::atomic::{Ordering, AtomicUsize};
8 use std::thread;
9
10 static LOG: AtomicUsize = AtomicUsize::new(0);
11
12 enum WithDtor { Val }
13 impl Drop for WithDtor {
14     fn drop(&mut self) {
15         LOG.store(LOG.load(Ordering::SeqCst)+1,Ordering::SeqCst);
16     }
17 }
18
19 pub fn main() {
20     thread::spawn(move|| {
21         let _e: WithDtor = WithDtor::Val;
22         panic!("fail");
23     }).join().unwrap_err();
24
25     assert_eq!(LOG.load(Ordering::SeqCst), 1);
26 }