]> git.proxmox.com Git - rustc.git/blame - src/test/ui/array-slice-vec/slice-panic-1.rs
New upstream version 1.55.0+dfsg1
[rustc.git] / src / test / ui / array-slice-vec / slice-panic-1.rs
CommitLineData
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 8use std::thread;
970d7e83 9
1a4d82fc
JJ
10struct Foo;
11
c34b1796 12static mut DTOR_COUNT: isize = 0;
1a4d82fc
JJ
13
14impl Drop for Foo {
15 fn drop(&mut self) { unsafe { DTOR_COUNT += 1; } }
16}
17
18fn foo() {
19 let x: &[_] = &[Foo, Foo];
136023e0 20 let _ = &x[3..4];
223e47cc
LB
21}
22
23fn main() {
85aaf69f 24 let _ = thread::spawn(move|| foo()).join();
62682a34 25 unsafe { assert_eq!(DTOR_COUNT, 2); }
223e47cc 26}