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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

21 lines
733 B
Rust
Raw Normal View History

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