]> git.lizzy.rs Git - rust.git/blob - src/test/ui/asm-in-moved.rs
Rollup merge of #70649 - GuillaumeGomez:cleanup-e0468, r=Dylan-DPC
[rust.git] / src / test / ui / asm-in-moved.rs
1 // run-pass
2
3 #![feature(llvm_asm)]
4 #![allow(dead_code)]
5
6 use std::cell::Cell;
7
8 #[repr(C)]
9 struct NoisyDrop<'a>(&'a Cell<&'static str>);
10 impl<'a> Drop for NoisyDrop<'a> {
11     fn drop(&mut self) {
12         self.0.set("destroyed");
13     }
14 }
15
16 #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
17 fn main() {
18     let status = Cell::new("alive");
19     {
20         let _y: Box<NoisyDrop>;
21         let x = Box::new(NoisyDrop(&status));
22         unsafe {
23             llvm_asm!("mov $1, $0" : "=r"(_y) : "r"(x));
24         }
25         assert_eq!(status.get(), "alive");
26     }
27     assert_eq!(status.get(), "destroyed");
28 }
29
30 #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
31 fn main() {}