]> git.proxmox.com Git - rustc.git/blame - src/test/ui/mir/mir_fat_ptr_drop.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / src / test / ui / mir / mir_fat_ptr_drop.rs
CommitLineData
b7449926 1// run-pass
0bf4aa26 2#![allow(unused_variables)]
b7449926
XL
3#![allow(stable_features)]
4
54a0048b
SL
5// test that ordinary fat pointer operations work.
6
7#![feature(braced_empty_structs)]
8#![feature(rustc_attrs)]
9
10use std::sync::atomic;
11use std::sync::atomic::Ordering::SeqCst;
12
9fa01778 13static COUNTER: atomic::AtomicUsize = atomic::AtomicUsize::new(0);
54a0048b
SL
14
15struct DropMe {
16}
17
18impl Drop for DropMe {
19 fn drop(&mut self) {
20 COUNTER.fetch_add(1, SeqCst);
21 }
22}
23
54a0048b
SL
24fn fat_ptr_move_then_drop(a: Box<[DropMe]>) {
25 let b = a;
26}
27
28fn main() {
29 let a: Box<[DropMe]> = Box::new([DropMe { }]);
30 fat_ptr_move_then_drop(a);
31 assert_eq!(COUNTER.load(SeqCst), 1);
32}