diff options
| author | Ralf Jung <post@ralfj.de> | 2020-12-19 20:25:27 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2020-12-19 20:52:24 +0100 |
| commit | f4085f0d3a4f1ff77153eabf8fa9cf6d0dafae1a (patch) | |
| tree | d0b21f6c352069cb0652c98ffe3f87ae6c28b498 /src/test/ui/error-codes | |
| parent | bd2f1cb2785f87177249e2bdb628ed782fcd8def (diff) | |
| download | rust-f4085f0d3a4f1ff77153eabf8fa9cf6d0dafae1a.tar.gz rust-f4085f0d3a4f1ff77153eabf8fa9cf6d0dafae1a.zip | |
also const-check FakeRead
Diffstat (limited to 'src/test/ui/error-codes')
| -rw-r--r-- | src/test/ui/error-codes/E0396.rs | 11 | ||||
| -rw-r--r-- | src/test/ui/error-codes/E0396.stderr | 20 |
2 files changed, 30 insertions, 1 deletions
diff --git a/src/test/ui/error-codes/E0396.rs b/src/test/ui/error-codes/E0396.rs index b32853e483d..58ed3c2c722 100644 --- a/src/test/ui/error-codes/E0396.rs +++ b/src/test/ui/error-codes/E0396.rs @@ -5,5 +5,16 @@ const REG_ADDR: *const u8 = 0x5f3759df as *const u8; const VALUE: u8 = unsafe { *REG_ADDR }; //~^ ERROR dereferencing raw pointers in constants is unstable +const unsafe fn unreachable() -> ! { + use std::convert::Infallible; + + const INFALLIBLE: *const Infallible = [].as_ptr(); + match *INFALLIBLE {} + //~^ ERROR dereferencing raw pointers in constant functions is unstable + + const BAD: () = unsafe { match *INFALLIBLE {} }; + //~^ ERROR dereferencing raw pointers in constants is unstable +} + fn main() { } diff --git a/src/test/ui/error-codes/E0396.stderr b/src/test/ui/error-codes/E0396.stderr index 7d2544f939f..20dad1b983c 100644 --- a/src/test/ui/error-codes/E0396.stderr +++ b/src/test/ui/error-codes/E0396.stderr @@ -7,6 +7,24 @@ LL | const VALUE: u8 = unsafe { *REG_ADDR }; = note: see issue #51911 <https://github.com/rust-lang/rust/issues/51911> for more information = help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable -error: aborting due to previous error +error[E0658]: dereferencing raw pointers in constant functions is unstable + --> $DIR/E0396.rs:12:11 + | +LL | match *INFALLIBLE {} + | ^^^^^^^^^^^ + | + = note: see issue #51911 <https://github.com/rust-lang/rust/issues/51911> for more information + = help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable + +error[E0658]: dereferencing raw pointers in constants is unstable + --> $DIR/E0396.rs:15:36 + | +LL | const BAD: () = unsafe { match *INFALLIBLE {} }; + | ^^^^^^^^^^^ + | + = note: see issue #51911 <https://github.com/rust-lang/rust/issues/51911> for more information + = help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0658`. |
