Debian Codegraph @

gcc/testsuite/rust/compile/torture/intrinsics-4.rs

raw
1 #![feature(intrinsics)]
2
3 #[lang = "sized"]
4 pub trait Sized {}
5
6 #[lang = "clone"]
7 pub trait Clone: Sized {
8 fn clone(&self) -> Self;
9
10 fn clone_from(&mut self, source: &Self) {
11 *self = source.clone()
12 }
13 }
14
15 mod impls {
16 use super::Clone;
17
18 macro_rules! impl_clone {
19 ($($t:ty)*) => {
20 $(
21 impl Clone for $t {
22 fn clone(&self) -> Self {
23 *self
24 }
25 }
26 )*
27 }
28 }
29
30 impl_clone! {
31 usize u8 u16 u32 u64 // u128
32 isize i8 i16 i32 i64 // i128
33 f32 f64
34 bool char
35 }
36 }
37
38 #[lang = "copy"]
39 pub trait Copy: Clone {
40 // Empty.
41 }
42
43 mod copy_impls {
44 use super::Copy;
45
46 macro_rules! impl_copy {
47 ($($t:ty)*) => {
48 $(
49 impl Copy for $t {}
50 )*
51 }
52 }
53
54 impl_copy! {
55 usize u8 u16 u32 u64 // u128
56 isize i8 i16 i32 i64 // i128
57 f32 f64
58 bool char
59 }
60 }
61
62 extern "rust-intrinsic" {
63 pub fn atomic_store_seqcst<T: Copy>(dst: *mut T, val: T);
64 pub fn atomic_store_release<T: Copy>(dst: *mut T, val: T);
65 pub fn atomic_store_relaxed<T: Copy>(dst: *mut T, val: T);
66 pub fn atomic_store_unordered<T: Copy>(dst: *mut T, val: T);
67 }
68
69 fn main() {
70 let mut dst = 15u32;
71 let new_value = 14;
72
73 unsafe {
74 atomic_store_seqcst(&mut dst, new_value);
75 atomic_store_release(&mut dst, new_value);
76 atomic_store_relaxed(&mut dst, new_value);
77 atomic_store_unordered(&mut dst, new_value);
78 }
79 }