We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fd7eefc commit 9aa77c0Copy full SHA for 9aa77c0
tests/ui/statics/const_generics.rs
@@ -0,0 +1,24 @@
1
+//! check that we lose the information that `BAR` points to `FOO`
2
+//! when going through a const generic.
3
+
4
+//@ run-pass
5
+// With optimizations, LLVM will deduplicate the constant `X` whose
6
+// value is `&42` to just be a reference to the static. This is correct,
7
+// but obscures the issue we're trying to show.
8
+//@ revisions: opt noopt
9
+//@[noopt] compile-flags: -Copt-level=0
10
+//@[opt] compile-flags: -O
11
12
+#![feature(const_refs_to_static)]
13
+#![feature(adt_const_params)]
14
+#![allow(incomplete_features)]
15
16
+static FOO: usize = 42;
17
+const BAR: &usize = &FOO;
18
+fn foo<const X: &'static usize>() {
19
+ assert_eq!(cfg!(opt), std::ptr::eq(X, &FOO));
20
+}
21
22
+fn main() {
23
+ foo::<BAR>();
24
0 commit comments