]> git.lizzy.rs Git - rust.git/blob - src/test/ui/array-slice-vec/slice-panic-2.rs
fix(rustfmt): load nested out-of-line mods correctly
[rust.git] / src / test / ui / array-slice-vec / slice-panic-2.rs
1 // run-pass
2
3 // ignore-emscripten no threads support
4
5 // Test that if a slicing expr[..] fails, the correct cleanups happen.
6
7
8 use std::thread;
9
10 struct Foo;
11
12 static mut DTOR_COUNT: isize = 0;
13
14 impl Drop for Foo {
15     fn drop(&mut self) { unsafe { DTOR_COUNT += 1; } }
16 }
17
18 fn bar() -> usize {
19     panic!();
20 }
21
22 fn foo() {
23     let x: &[_] = &[Foo, Foo];
24     &x[3..bar()];
25 }
26
27 fn main() {
28     let _ = thread::spawn(move|| foo()).join();
29     unsafe { assert_eq!(DTOR_COUNT, 2); }
30 }