summaryrefslogtreecommitdiffstats
path: root/src/test/ui/consts/const-mut-refs/issue-76510.rs
blob: 08cf64ee330db74af03b8bc009206907bd4462bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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() {}