]> git.proxmox.com Git - rustc.git/blob - src/test/ui/consts/write_to_mut_ref_dest.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / src / test / ui / consts / write_to_mut_ref_dest.rs
1 // revisions: stock mut_refs
2 //[mut_refs] check-pass
3
4 #![cfg_attr(mut_refs, feature(const_mut_refs))]
5
6 use std::cell::Cell;
7
8 const FOO: &u32 = {
9 let mut a = 42;
10 {
11 let b: *mut u32 = &mut a; //[stock]~ ERROR mutable references are not allowed in constants
12 unsafe { *b = 5; } //[stock]~ ERROR dereferencing raw mutable pointers in constants
13 }
14 &{a}
15 };
16
17 fn main() {}