]> git.lizzy.rs Git - rust.git/blob - tests/ui/consts/write_to_mut_ref_dest.rs
Rollup merge of #106717 - klensy:typo, r=lcnr
[rust.git] / tests / 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() {}