about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr5
-rw-r--r--src/test/ui/error-codes/E0396.rs11
-rw-r--r--src/test/ui/error-codes/E0396.stderr20
3 files changed, 35 insertions, 1 deletions
diff --git a/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr b/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr
index 52662ef9eaf..b65e50eb9f4 100644
--- a/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr
+++ b/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr
@@ -146,6 +146,11 @@ help: skipping check that does not even have a feature gate
    |
 LL |     unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+help: skipping check that does not even have a feature gate
+  --> $DIR/const_refers_to_static_cross_crate.rs:32:20
+   |
+LL |     unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
+   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 help: skipping check for `const_panic` feature
   --> $DIR/const_refers_to_static_cross_crate.rs:32:77
    |
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`.