about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNazım Can Altınova <canaltinova@gmail.com>2020-07-18 02:27:41 +0200
committerNazım Can Altınova <canaltinova@gmail.com>2020-07-18 02:27:47 +0200
commit6cd164f49e6f9c2b914fa5d55755d78e3fabbc27 (patch)
tree1550a8414425ad240e28a6f6df5d9fba78f47706
parentc45e9c86ca5e1aa20ec8ec9904c4ad9a33a072e5 (diff)
downloadrust-6cd164f49e6f9c2b914fa5d55755d78e3fabbc27.tar.gz
rust-6cd164f49e6f9c2b914fa5d55755d78e3fabbc27.zip
Update UB test to fail during build with contant errors
-rw-r--r--src/test/ui/consts/const_unsafe_unreachable_ub.rs5
-rw-r--r--src/test/ui/consts/const_unsafe_unreachable_ub.stderr34
2 files changed, 34 insertions, 5 deletions
diff --git a/src/test/ui/consts/const_unsafe_unreachable_ub.rs b/src/test/ui/consts/const_unsafe_unreachable_ub.rs
index 2e4dfd1522b..11920d852e0 100644
--- a/src/test/ui/consts/const_unsafe_unreachable_ub.rs
+++ b/src/test/ui/consts/const_unsafe_unreachable_ub.rs
@@ -1,3 +1,5 @@
+// build-fail
+
 #![feature(const_fn)]
 #![feature(const_unreachable_unchecked)]
 
@@ -8,8 +10,11 @@ const unsafe fn foo(x: bool) -> bool {
     }
 }
 
+#[warn(const_err)]
 const BAR: bool = unsafe { foo(false) };
 
 fn main() {
   assert_eq!(BAR, true);
+  //~^ ERROR E0080
+  //~| ERROR erroneous constant
 }
diff --git a/src/test/ui/consts/const_unsafe_unreachable_ub.stderr b/src/test/ui/consts/const_unsafe_unreachable_ub.stderr
index 0a7aa4e0021..3ef8043a54d 100644
--- a/src/test/ui/consts/const_unsafe_unreachable_ub.stderr
+++ b/src/test/ui/consts/const_unsafe_unreachable_ub.stderr
@@ -1,4 +1,4 @@
-error: any use of this value will cause an error
+warning: any use of this value will cause an error
   --> $SRC_DIR/libcore/hint.rs:LL:COL
    |
 LL |     unsafe { intrinsics::unreachable() }
@@ -6,15 +6,39 @@ LL |     unsafe { intrinsics::unreachable() }
    |              |
    |              entering unreachable code
    |              inside `std::hint::unreachable_unchecked` at $SRC_DIR/libcore/hint.rs:LL:COL
-   |              inside `foo` at $DIR/const_unsafe_unreachable_ub.rs:7:18
-   |              inside `BAR` at $DIR/const_unsafe_unreachable_ub.rs:11:28
+   |              inside `foo` at $DIR/const_unsafe_unreachable_ub.rs:9:18
+   |              inside `BAR` at $DIR/const_unsafe_unreachable_ub.rs:14:28
    | 
-  ::: $DIR/const_unsafe_unreachable_ub.rs:11:1
+  ::: $DIR/const_unsafe_unreachable_ub.rs:14:1
    |
 LL | const BAR: bool = unsafe { foo(false) };
    | ----------------------------------------
    |
+note: the lint level is defined here
+  --> $DIR/const_unsafe_unreachable_ub.rs:13:8
+   |
+LL | #[warn(const_err)]
+   |        ^^^^^^^^^
+
+error[E0080]: evaluation of constant expression failed
+  --> $DIR/const_unsafe_unreachable_ub.rs:17:3
+   |
+LL |   assert_eq!(BAR, true);
+   |   ^^^^^^^^^^^---^^^^^^^^
+   |              |
+   |              referenced constant has errors
+   |
+   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: erroneous constant used
+  --> $DIR/const_unsafe_unreachable_ub.rs:17:3
+   |
+LL |   assert_eq!(BAR, true);
+   |   ^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
+   |
    = note: `#[deny(const_err)]` on by default
+   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
-error: aborting due to previous error
+error: aborting due to 2 previous errors; 1 warning emitted
 
+For more information about this error, try `rustc --explain E0080`.