summaryrefslogtreecommitdiffstats
path: root/src/test/ui/consts/const-mut-refs/issue-76510.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/consts/const-mut-refs/issue-76510.rs')
-rw-r--r--src/test/ui/consts/const-mut-refs/issue-76510.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/test/ui/consts/const-mut-refs/issue-76510.rs b/src/test/ui/consts/const-mut-refs/issue-76510.rs
new file mode 100644
index 000000000..08cf64ee3
--- /dev/null
+++ b/src/test/ui/consts/const-mut-refs/issue-76510.rs
@@ -0,0 +1,18 @@
+// stderr-per-bitwidth
+
+use std::mem::{transmute, ManuallyDrop};
+
+const S: &'static mut str = &mut " hello ";
+//~^ ERROR: mutable references are not allowed in the final value of constants
+//~| ERROR: mutation through a reference is not allowed in constants
+//~| ERROR: cannot borrow data in a `&` reference as mutable
+
+const fn trigger() -> [(); unsafe {
+ let s = transmute::<(*const u8, usize), &ManuallyDrop<str>>((S.as_ptr(), 3));
+ //~^ ERROR evaluation of constant value failed
+ 0
+ }] {
+ [(); 0]
+}
+
+fn main() {}