about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Scherer <github35764891676564198441@oli-obk.de>2019-12-22 21:42:50 +0100
committerOliver Scherer <github35764891676564198441@oli-obk.de>2019-12-23 14:54:37 +0100
commite56a86162ceeb285c48132a103a6559f4d406ba7 (patch)
treeadcb848a02c16dd3b14ff19ba1af1b7e4377fc48
parent2022fac4df5830a1a346f0174f189cc2894f7229 (diff)
downloadrust-e56a86162ceeb285c48132a103a6559f4d406ba7.tar.gz
rust-e56a86162ceeb285c48132a103a6559f4d406ba7.zip
Show `const_err` lints
-rw-r--r--src/test/ui/consts/miri_unleashed/const_refers_to_static.rs8
-rw-r--r--src/test/ui/consts/miri_unleashed/const_refers_to_static.stderr45
2 files changed, 45 insertions, 8 deletions
diff --git a/src/test/ui/consts/miri_unleashed/const_refers_to_static.rs b/src/test/ui/consts/miri_unleashed/const_refers_to_static.rs
index 58eac59ba38..55f3f1c8488 100644
--- a/src/test/ui/consts/miri_unleashed/const_refers_to_static.rs
+++ b/src/test/ui/consts/miri_unleashed/const_refers_to_static.rs
@@ -1,5 +1,5 @@
 // compile-flags: -Zunleash-the-miri-inside-of-you
-#![allow(const_err)]
+#![warn(const_err)]
 
 #![feature(const_raw_ptr_deref)]
 
@@ -14,19 +14,19 @@ const BOO: &usize = { //~ ERROR undefined behavior to use this value
 
 const FOO: usize = {
     static FOO: AtomicUsize = AtomicUsize::new(0);
-    FOO.fetch_add(1, Ordering::Relaxed) // FIXME: this should error
+    FOO.fetch_add(1, Ordering::Relaxed) //~ WARN any use of this value will cause an error
     //~^ WARN skipping const checks
     //~| WARN skipping const checks
 };
 
 const BAR: usize = {
     static FOO: AtomicUsize = AtomicUsize::new(0);
-    unsafe { *(&FOO as *const _ as *const usize) } // FIXME: this should error
+    unsafe { *(&FOO as *const _ as *const usize) } //~ WARN any use of this value will cause an err
     //~^ WARN skipping const checks
 };
 
 static mut MUTABLE: u32 = 0;
-const BAD: u32 = unsafe { MUTABLE }; // FIXME: this should error
+const BAD: u32 = unsafe { MUTABLE }; //~ WARN any use of this value will cause an error
 //~^ WARN skipping const checks
 
 // ok some day perhaps
diff --git a/src/test/ui/consts/miri_unleashed/const_refers_to_static.stderr b/src/test/ui/consts/miri_unleashed/const_refers_to_static.stderr
index 7a8c9d44e5a..6ae88558d70 100644
--- a/src/test/ui/consts/miri_unleashed/const_refers_to_static.stderr
+++ b/src/test/ui/consts/miri_unleashed/const_refers_to_static.stderr
@@ -7,25 +7,25 @@ LL |     unsafe { &*(&FOO as *const _ as *const usize) }
 warning: skipping const checks
   --> $DIR/const_refers_to_static.rs:17:5
    |
-LL |     FOO.fetch_add(1, Ordering::Relaxed) // FIXME: this should error
+LL |     FOO.fetch_add(1, Ordering::Relaxed)
    |     ^^^
 
 warning: skipping const checks
   --> $DIR/const_refers_to_static.rs:17:5
    |
-LL |     FOO.fetch_add(1, Ordering::Relaxed) // FIXME: this should error
+LL |     FOO.fetch_add(1, Ordering::Relaxed)
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: skipping const checks
   --> $DIR/const_refers_to_static.rs:24:17
    |
-LL |     unsafe { *(&FOO as *const _ as *const usize) } // FIXME: this should error
+LL |     unsafe { *(&FOO as *const _ as *const usize) }
    |                 ^^^
 
 warning: skipping const checks
   --> $DIR/const_refers_to_static.rs:29:27
    |
-LL | const BAD: u32 = unsafe { MUTABLE }; // FIXME: this should error
+LL | const BAD: u32 = unsafe { MUTABLE };
    |                           ^^^^^^^
 
 warning: skipping const checks
@@ -46,6 +46,43 @@ LL | | };
    |
    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
 
+warning: any use of this value will cause an error
+  --> $DIR/const_refers_to_static.rs:17:5
+   |
+LL | / const FOO: usize = {
+LL | |     static FOO: AtomicUsize = AtomicUsize::new(0);
+LL | |     FOO.fetch_add(1, Ordering::Relaxed)
+   | |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calling non-const function `std::sync::atomic::AtomicUsize::fetch_add`
+LL | |
+LL | |
+LL | | };
+   | |__-
+   |
+note: lint level defined here
+  --> $DIR/const_refers_to_static.rs:2:9
+   |
+LL | #![warn(const_err)]
+   |         ^^^^^^^^^
+
+warning: any use of this value will cause an error
+  --> $DIR/const_refers_to_static.rs:24:14
+   |
+LL | / const BAR: usize = {
+LL | |     static FOO: AtomicUsize = AtomicUsize::new(0);
+LL | |     unsafe { *(&FOO as *const _ as *const usize) }
+   | |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static
+LL | |
+LL | | };
+   | |__-
+
+warning: any use of this value will cause an error
+  --> $DIR/const_refers_to_static.rs:29:27
+   |
+LL | const BAD: u32 = unsafe { MUTABLE };
+   | --------------------------^^^^^^^---
+   |                           |
+   |                           constant accesses static
+
 error[E0080]: it is undefined behavior to use this value
   --> $DIR/const_refers_to_static.rs:33:1
    |