summaryrefslogtreecommitdiffstats
path: root/tests/ui/consts/issue-17718.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/consts/issue-17718.rs
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/consts/issue-17718.rs')
-rw-r--r--tests/ui/consts/issue-17718.rs75
1 files changed, 75 insertions, 0 deletions
diff --git a/tests/ui/consts/issue-17718.rs b/tests/ui/consts/issue-17718.rs
new file mode 100644
index 000000000..c6341d808
--- /dev/null
+++ b/tests/ui/consts/issue-17718.rs
@@ -0,0 +1,75 @@
+// run-pass
+#![allow(dead_code)]
+// aux-build:issue-17718-aux.rs
+
+extern crate issue_17718_aux as other;
+
+use std::sync::atomic::{AtomicUsize, Ordering};
+
+const C1: usize = 1;
+const C2: AtomicUsize = AtomicUsize::new(0);
+const C3: fn() = foo;
+const C4: usize = C1 * C1 + C1 / C1;
+const C5: &'static usize = &C4;
+const C6: usize = {
+ const C: usize = 3;
+ C
+};
+
+static S1: usize = 3;
+static S2: AtomicUsize = AtomicUsize::new(0);
+
+mod test {
+ static A: usize = 4;
+ static B: &'static usize = &A;
+ static C: &'static usize = &(A);
+}
+
+fn foo() {}
+
+fn main() {
+ assert_eq!(C1, 1);
+ assert_eq!(C3(), ());
+ assert_eq!(C2.fetch_add(1, Ordering::SeqCst), 0);
+ assert_eq!(C2.fetch_add(1, Ordering::SeqCst), 0);
+ assert_eq!(C4, 2);
+ assert_eq!(*C5, 2);
+ assert_eq!(C6, 3);
+ assert_eq!(S1, 3);
+ assert_eq!(S2.fetch_add(1, Ordering::SeqCst), 0);
+ assert_eq!(S2.fetch_add(1, Ordering::SeqCst), 1);
+
+ match 1 {
+ C1 => {}
+ _ => unreachable!(),
+ }
+
+ let _a = C1;
+ let _a = C2;
+ let _a = C3;
+ let _a = C4;
+ let _a = C5;
+ let _a = C6;
+ let _a = S1;
+
+ assert_eq!(other::C1, 1);
+ assert_eq!(other::C3(), ());
+ assert_eq!(other::C2.fetch_add(1, Ordering::SeqCst), 0);
+ assert_eq!(other::C2.fetch_add(1, Ordering::SeqCst), 0);
+ assert_eq!(other::C4, 2);
+ assert_eq!(*other::C5, 2);
+ assert_eq!(other::S1, 3);
+ assert_eq!(other::S2.fetch_add(1, Ordering::SeqCst), 0);
+ assert_eq!(other::S2.fetch_add(1, Ordering::SeqCst), 1);
+
+ let _a = other::C1;
+ let _a = other::C2;
+ let _a = other::C3;
+ let _a = other::C4;
+ let _a = other::C5;
+
+ match 1 {
+ other::C1 => {}
+ _ => unreachable!(),
+ }
+}