rust/src/test/ui/consts/write_to_mut_ref_dest.rs

17 lines
355 B
Rust
Raw Normal View History

2019-11-28 11:57:34 -05:00
// revisions: stock mut_refs
#![cfg_attr(mut_refs, feature(const_mut_refs))]
use std::cell::Cell;
const FOO: &u32 = {
let mut a = 42;
{
let b: *mut u32 = &mut a; //[stock]~ ERROR mutable references are not allowed in constants
unsafe { *b = 5; } //~ ERROR dereferencing raw pointers in constants
}
&{a}
};
2018-11-21 11:13:49 +01:00
fn main() {}