]> git.lizzy.rs Git - rust.git/blob - src/test/ui/array-slice-vec/slice-panic-1.rs
Rollup merge of #86424 - calebcartwright:rustfmt-mod-resolution, r=Mark-Simulacrum
[rust.git] / src / test / ui / array-slice-vec / slice-panic-1.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 foo() {
19     let x: &[_] = &[Foo, Foo];
20     let _ = &x[3..4];
21 }
22
23 fn main() {
24     let _ = thread::spawn(move|| foo()).join();
25     unsafe { assert_eq!(DTOR_COUNT, 2); }
26 }