rust/tests/ui/error-codes/E0396.rs

19 lines
574 B
Rust
Raw Normal View History

const REG_ADDR: *mut u8 = 0x5f3759df as *mut u8;
2016-08-15 06:58:28 -05:00
const VALUE: u8 = unsafe { *REG_ADDR };
//~^ ERROR dereferencing raw mutable pointers in constants is unstable
2016-08-15 06:58:28 -05:00
2020-12-19 13:25:27 -06:00
const unsafe fn unreachable() -> ! {
use std::convert::Infallible;
const INFALLIBLE: *mut Infallible = &[] as *const [Infallible] as *const _ as _;
2020-12-19 13:25:27 -06:00
match *INFALLIBLE {}
//~^ ERROR dereferencing raw mutable pointers in constant functions is unstable
2020-12-19 13:25:27 -06:00
const BAD: () = unsafe { match *INFALLIBLE {} };
//~^ ERROR dereferencing raw mutable pointers in constants is unstable
2020-12-19 13:25:27 -06:00
}
2016-08-15 06:58:28 -05:00
fn main() {
}