]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-mut-refs/issue-76510.rs
Bless nll tests.
[rust.git] / src / test / ui / consts / const-mut-refs / issue-76510.rs
1 // stderr-per-bitwidth
2
3 use std::mem::{transmute, ManuallyDrop};
4
5 const S: &'static mut str = &mut " hello ";
6 //~^ ERROR: mutable references are not allowed in the final value of constants
7 //~| ERROR: mutation through a reference is not allowed in constants
8 //~| ERROR: cannot borrow data in a `&` reference as mutable
9 //~| ERROR: it is undefined behavior to use this value
10
11 const fn trigger() -> [(); unsafe {
12         let s = transmute::<(*const u8, usize), &ManuallyDrop<str>>((S.as_ptr(), 3));
13         0
14     }] {
15     [(); 0]
16 }
17
18 fn main() {}