]> git.proxmox.com Git - rustc.git/blob - tests/ui/consts/issue-17718.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / consts / issue-17718.rs
1 // run-pass
2 #![allow(dead_code)]
3 // aux-build:issue-17718-aux.rs
4
5 extern crate issue_17718_aux as other;
6
7 use std::sync::atomic::{AtomicUsize, Ordering};
8
9 const C1: usize = 1;
10 const C2: AtomicUsize = AtomicUsize::new(0);
11 const C3: fn() = foo;
12 const C4: usize = C1 * C1 + C1 / C1;
13 const C5: &'static usize = &C4;
14 const C6: usize = {
15 const C: usize = 3;
16 C
17 };
18
19 static S1: usize = 3;
20 static S2: AtomicUsize = AtomicUsize::new(0);
21
22 mod test {
23 static A: usize = 4;
24 static B: &'static usize = &A;
25 static C: &'static usize = &(A);
26 }
27
28 fn foo() {}
29
30 fn main() {
31 assert_eq!(C1, 1);
32 assert_eq!(C3(), ());
33 assert_eq!(C2.fetch_add(1, Ordering::SeqCst), 0);
34 assert_eq!(C2.fetch_add(1, Ordering::SeqCst), 0);
35 assert_eq!(C4, 2);
36 assert_eq!(*C5, 2);
37 assert_eq!(C6, 3);
38 assert_eq!(S1, 3);
39 assert_eq!(S2.fetch_add(1, Ordering::SeqCst), 0);
40 assert_eq!(S2.fetch_add(1, Ordering::SeqCst), 1);
41
42 match 1 {
43 C1 => {}
44 _ => unreachable!(),
45 }
46
47 let _a = C1;
48 let _a = C2;
49 let _a = C3;
50 let _a = C4;
51 let _a = C5;
52 let _a = C6;
53 let _a = S1;
54
55 assert_eq!(other::C1, 1);
56 assert_eq!(other::C3(), ());
57 assert_eq!(other::C2.fetch_add(1, Ordering::SeqCst), 0);
58 assert_eq!(other::C2.fetch_add(1, Ordering::SeqCst), 0);
59 assert_eq!(other::C4, 2);
60 assert_eq!(*other::C5, 2);
61 assert_eq!(other::S1, 3);
62 assert_eq!(other::S2.fetch_add(1, Ordering::SeqCst), 0);
63 assert_eq!(other::S2.fetch_add(1, Ordering::SeqCst), 1);
64
65 let _a = other::C1;
66 let _a = other::C2;
67 let _a = other::C3;
68 let _a = other::C4;
69 let _a = other::C5;
70
71 match 1 {
72 other::C1 => {}
73 _ => unreachable!(),
74 }
75 }