]> git.lizzy.rs Git - rust.git/blob - src/test/ui/mir/mir_fat_ptr_drop.rs
Merge commit 'dbee13661efa269cb4cd57bb4c6b99a19732b484' into sync_cg_clif-2020-12-27
[rust.git] / src / test / ui / mir / mir_fat_ptr_drop.rs
1 // run-pass
2 #![allow(unused_variables)]
3 #![allow(stable_features)]
4
5 // test that ordinary fat pointer operations work.
6
7 #![feature(braced_empty_structs)]
8 #![feature(rustc_attrs)]
9
10 use std::sync::atomic;
11 use std::sync::atomic::Ordering::SeqCst;
12
13 static COUNTER: atomic::AtomicUsize = atomic::AtomicUsize::new(0);
14
15 struct DropMe {
16 }
17
18 impl Drop for DropMe {
19     fn drop(&mut self) {
20         COUNTER.fetch_add(1, SeqCst);
21     }
22 }
23
24 fn fat_ptr_move_then_drop(a: Box<[DropMe]>) {
25     let b = a;
26 }
27
28 fn main() {
29     let a: Box<[DropMe]> = Box::new([DropMe { }]);
30     fat_ptr_move_then_drop(a);
31     assert_eq!(COUNTER.load(SeqCst), 1);
32 }