]>
Commit | Line | Data |
---|---|---|
b7449926 XL |
1 | // run-pass |
2 | ||
7453a54e SL |
3 | // ignore-emscripten no threads support |
4 | ||
1a4d82fc | 5 | // Test that if a slicing expr[..] fails, the correct cleanups happen. |
223e47cc | 6 | |
c34b1796 | 7 | |
85aaf69f | 8 | use std::thread; |
970d7e83 | 9 | |
1a4d82fc JJ |
10 | struct Foo; |
11 | ||
c34b1796 | 12 | static mut DTOR_COUNT: isize = 0; |
1a4d82fc JJ |
13 | |
14 | impl Drop for Foo { | |
15 | fn drop(&mut self) { unsafe { DTOR_COUNT += 1; } } | |
16 | } | |
17 | ||
18 | fn foo() { | |
19 | let x: &[_] = &[Foo, Foo]; | |
136023e0 | 20 | let _ = &x[3..4]; |
223e47cc LB |
21 | } |
22 | ||
23 | fn main() { | |
85aaf69f | 24 | let _ = thread::spawn(move|| foo()).join(); |
62682a34 | 25 | unsafe { assert_eq!(DTOR_COUNT, 2); } |
223e47cc | 26 | } |