diff --git a/src/librustc_interface/interface.rs b/src/librustc_interface/interface.rs index 8e929b7daa8..55f825e150e 100644 --- a/src/librustc_interface/interface.rs +++ b/src/librustc_interface/interface.rs @@ -193,7 +193,7 @@ pub fn run_compiler_in_existing_thread_pool( let r = { let _sess_abort_error = OnDrop(|| { - compiler.sess.diagnostic().print_error_count(registry); + compiler.sess.finish_diagnostics(registry); }); f(&compiler) diff --git a/src/librustc_mir/transform/check_consts/validation.rs b/src/librustc_mir/transform/check_consts/validation.rs index 691903c9069..3fd9131d5db 100644 --- a/src/librustc_mir/transform/check_consts/validation.rs +++ b/src/librustc_mir/transform/check_consts/validation.rs @@ -247,12 +247,12 @@ impl Validator<'mir, 'tcx> { return; } - // If an operation is supported in miri (and is not already controlled by a feature gate) it - // can be turned on with `-Zunleash-the-miri-inside-of-you`. - let is_unleashable = O::IS_SUPPORTED_IN_MIRI && O::feature_gate().is_none(); + // If an operation is supported in miri it can be turned on with + // `-Zunleash-the-miri-inside-of-you`. + let is_unleashable = O::IS_SUPPORTED_IN_MIRI; if is_unleashable && self.tcx.sess.opts.debugging_opts.unleash_the_miri_inside_of_you { - self.tcx.sess.span_warn(span, "skipping const checks"); + self.tcx.sess.miri_unleashed_feature(span, O::feature_gate()); return; } diff --git a/src/librustc_session/session.rs b/src/librustc_session/session.rs index 69e1b46de4d..93a1315c6b5 100644 --- a/src/librustc_session/session.rs +++ b/src/librustc_session/session.rs @@ -18,10 +18,11 @@ use rustc_data_structures::sync::{ use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitterWriter; use rustc_errors::emitter::{Emitter, EmitterWriter, HumanReadableErrorType}; use rustc_errors::json::JsonEmitter; +use rustc_errors::registry::Registry; use rustc_errors::{Applicability, DiagnosticBuilder, DiagnosticId, ErrorReported}; use rustc_span::edition::Edition; use rustc_span::source_map::{self, FileLoader, MultiSpan, RealFileLoader, SourceMap, Span}; -use rustc_span::SourceFileHashAlgorithm; +use rustc_span::{SourceFileHashAlgorithm, Symbol}; use rustc_target::spec::{PanicStrategy, RelocModel, RelroLevel, Target, TargetTriple, TlsModel}; use std::cell::{self, RefCell}; @@ -142,6 +143,12 @@ pub struct Session { /// and immediately printing the backtrace to stderr. pub ctfe_backtrace: Lock, + /// This tracks where `-Zunleash-the-miri-inside-of-you` was used to get around a + /// const check, optionally with the relevant feature gate. We use this to + /// warn about unleashing, but with a single diagnostic instead of dozens that + /// drown everything else in noise. + miri_unleashed_features: Lock)>>, + /// Base directory containing the `src/` for the Rust standard library, and /// potentially `rustc` as well, if we can can find it. Right now it's always /// `$sysroot/lib/rustlib/src/rust` (i.e. the `rustup` `rust-src` component). @@ -189,6 +196,44 @@ impl From<&'static lint::Lint> for DiagnosticMessageId { } impl Session { + pub fn miri_unleashed_feature(&self, span: Span, feature_gate: Option) { + self.miri_unleashed_features.lock().push((span, feature_gate)); + } + + fn check_miri_unleashed_features(&self) { + let unleashed_features = self.miri_unleashed_features.lock(); + if !unleashed_features.is_empty() { + let mut must_err = false; + // Create a diagnostic pointing at where things got unleashed. + let mut diag = self.struct_warn("skipping const checks"); + for &(span, feature_gate) in unleashed_features.iter() { + // FIXME: `span_label` doesn't do anything, so we use "help" as a hack. + if let Some(feature_gate) = feature_gate { + diag.span_help(span, &format!("skipping check for `{}` feature", feature_gate)); + // The unleash flag must *not* be used to just "hack around" feature gates. + must_err = true; + } else { + diag.span_help(span, "skipping check that does not even have a feature gate"); + } + } + diag.emit(); + // If we should err, make sure we did. + if must_err && !self.has_errors() { + // We have skipped a feature gate, and not run into other errors... reject. + self.err( + "`-Zunleash-the-miri-inside-of-you` may not be used to circumvent feature \ + gates, except when testing error paths in the CTFE engine", + ); + } + } + } + + /// Invoked all the way at the end to finish off diagnostics printing. + pub fn finish_diagnostics(&self, registry: &Registry) { + self.check_miri_unleashed_features(); + self.diagnostic().print_error_count(registry); + } + pub fn local_crate_disambiguator(&self) -> CrateDisambiguator { *self.crate_disambiguator.get() } @@ -1139,6 +1184,7 @@ pub fn build_session_with_source_map( confused_type_with_std_module: Lock::new(Default::default()), system_library_path: OneThread::new(RefCell::new(Default::default())), ctfe_backtrace, + miri_unleashed_features: Lock::new(Default::default()), real_rust_source_base_dir, }; diff --git a/src/test/ui/consts/const-eval/const_fn_ptr.rs b/src/test/ui/consts/const-eval/const_fn_ptr.rs index 9b94b45f522..045fe9ad11a 100644 --- a/src/test/ui/consts/const-eval/const_fn_ptr.rs +++ b/src/test/ui/consts/const-eval/const_fn_ptr.rs @@ -9,15 +9,15 @@ const X: fn(usize) -> usize = double; const X_CONST: fn(usize) -> usize = double_const; const fn bar(x: usize) -> usize { - X(x) //~ WARNING skipping const checks + X(x) } const fn bar_const(x: usize) -> usize { - X_CONST(x) //~ WARNING skipping const checks + X_CONST(x) } const fn foo(x: fn(usize) -> usize, y: usize) -> usize { - x(y) //~ WARNING skipping const checks + x(y) } fn main() { diff --git a/src/test/ui/consts/const-eval/const_fn_ptr.stderr b/src/test/ui/consts/const-eval/const_fn_ptr.stderr index 5f1e85b0d6d..d0ae94079da 100644 --- a/src/test/ui/consts/const-eval/const_fn_ptr.stderr +++ b/src/test/ui/consts/const-eval/const_fn_ptr.stderr @@ -1,20 +1,20 @@ warning: skipping const checks + | +help: skipping check that does not even have a feature gate --> $DIR/const_fn_ptr.rs:12:5 | LL | X(x) | ^^^^ - -warning: skipping const checks +help: skipping check that does not even have a feature gate --> $DIR/const_fn_ptr.rs:16:5 | LL | X_CONST(x) | ^^^^^^^^^^ - -warning: skipping const checks +help: skipping check that does not even have a feature gate --> $DIR/const_fn_ptr.rs:20:5 | LL | x(y) | ^^^^ -warning: 3 warnings emitted +warning: 1 warning emitted diff --git a/src/test/ui/consts/const-eval/const_fn_ptr_fail.rs b/src/test/ui/consts/const-eval/const_fn_ptr_fail.rs index 90d3cba07a5..14bd6558e7f 100644 --- a/src/test/ui/consts/const-eval/const_fn_ptr_fail.rs +++ b/src/test/ui/consts/const-eval/const_fn_ptr_fail.rs @@ -8,7 +8,6 @@ const X: fn(usize) -> usize = double; const fn bar(x: usize) -> usize { X(x) // FIXME: this should error someday - //~^ WARN: skipping const checks } fn main() {} diff --git a/src/test/ui/consts/const-eval/const_fn_ptr_fail.stderr b/src/test/ui/consts/const-eval/const_fn_ptr_fail.stderr index 39676965932..0a7182fd39c 100644 --- a/src/test/ui/consts/const-eval/const_fn_ptr_fail.stderr +++ b/src/test/ui/consts/const-eval/const_fn_ptr_fail.stderr @@ -1,4 +1,6 @@ warning: skipping const checks + | +help: skipping check that does not even have a feature gate --> $DIR/const_fn_ptr_fail.rs:10:5 | LL | X(x) // FIXME: this should error someday diff --git a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs index 81f53826d81..f67871e6142 100644 --- a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs +++ b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs @@ -10,7 +10,7 @@ fn double(x: usize) -> usize { const X: fn(usize) -> usize = double; const fn bar(x: fn(usize) -> usize, y: usize) -> usize { - x(y) //~ WARN skipping const checks + x(y) } const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday diff --git a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr index b980deea1e1..90ee2afa315 100644 --- a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr +++ b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr @@ -1,9 +1,3 @@ -warning: skipping const checks - --> $DIR/const_fn_ptr_fail2.rs:13:5 - | -LL | x(y) - | ^^^^ - error[E0080]: evaluation of constant expression failed --> $DIR/const_fn_ptr_fail2.rs:20:5 | @@ -24,6 +18,14 @@ LL | assert_eq!(Z, 4); | = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) +warning: skipping const checks + | +help: skipping check that does not even have a feature gate + --> $DIR/const_fn_ptr_fail2.rs:13:5 + | +LL | x(y) + | ^^^^ + error: aborting due to 2 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-points-to-static.rs b/src/test/ui/consts/const-points-to-static.rs index b998b7a97be..7087b6e6a67 100644 --- a/src/test/ui/consts/const-points-to-static.rs +++ b/src/test/ui/consts/const-points-to-static.rs @@ -3,8 +3,9 @@ #![allow(dead_code)] const TEST: &u8 = &MY_STATIC; -//~^ skipping const checks -//~| it is undefined behavior to use this value +//~^ ERROR it is undefined behavior to use this value +//~| NOTE encountered a reference pointing to a static variable +//~| NOTE static MY_STATIC: u8 = 4; diff --git a/src/test/ui/consts/const-points-to-static.stderr b/src/test/ui/consts/const-points-to-static.stderr index 62e59531c1e..465537fb3d5 100644 --- a/src/test/ui/consts/const-points-to-static.stderr +++ b/src/test/ui/consts/const-points-to-static.stderr @@ -1,9 +1,3 @@ -warning: skipping const checks - --> $DIR/const-points-to-static.rs:5:20 - | -LL | const TEST: &u8 = &MY_STATIC; - | ^^^^^^^^^ - error[E0080]: it is undefined behavior to use this value --> $DIR/const-points-to-static.rs:5:1 | @@ -12,6 +6,14 @@ LL | const TEST: &u8 = &MY_STATIC; | = 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: skipping const checks + | +help: skipping check that does not even have a feature gate + --> $DIR/const-points-to-static.rs:5:20 + | +LL | const TEST: &u8 = &MY_STATIC; + | ^^^^^^^^^ + error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-prop-read-static-in-const.rs b/src/test/ui/consts/const-prop-read-static-in-const.rs index 14ec064e4ce..13b1b2d1412 100644 --- a/src/test/ui/consts/const-prop-read-static-in-const.rs +++ b/src/test/ui/consts/const-prop-read-static-in-const.rs @@ -3,7 +3,6 @@ #![allow(dead_code)] const TEST: u8 = MY_STATIC; //~ ERROR any use of this value will cause an error -//~^ skipping const checks static MY_STATIC: u8 = 4; diff --git a/src/test/ui/consts/const-prop-read-static-in-const.stderr b/src/test/ui/consts/const-prop-read-static-in-const.stderr index 0da2dbc888a..7a517d1d7b3 100644 --- a/src/test/ui/consts/const-prop-read-static-in-const.stderr +++ b/src/test/ui/consts/const-prop-read-static-in-const.stderr @@ -1,9 +1,3 @@ -warning: skipping const checks - --> $DIR/const-prop-read-static-in-const.rs:5:18 - | -LL | const TEST: u8 = MY_STATIC; - | ^^^^^^^^^ - error: any use of this value will cause an error --> $DIR/const-prop-read-static-in-const.rs:5:18 | @@ -14,5 +8,13 @@ LL | const TEST: u8 = MY_STATIC; | = note: `#[deny(const_err)]` on by default +warning: skipping const checks + | +help: skipping check that does not even have a feature gate + --> $DIR/const-prop-read-static-in-const.rs:5:18 + | +LL | const TEST: u8 = MY_STATIC; + | ^^^^^^^^^ + error: aborting due to previous error; 1 warning emitted diff --git a/src/test/ui/consts/miri_unleashed/abi-mismatch.rs b/src/test/ui/consts/miri_unleashed/abi-mismatch.rs index a99e6327987..ae440d4f8f7 100644 --- a/src/test/ui/consts/miri_unleashed/abi-mismatch.rs +++ b/src/test/ui/consts/miri_unleashed/abi-mismatch.rs @@ -8,14 +8,12 @@ const extern "C" fn c_fn() {} const fn call_rust_fn(my_fn: extern "Rust" fn()) { my_fn(); - //~^ WARN skipping const checks - //~| ERROR could not evaluate static initializer + //~^ ERROR could not evaluate static initializer //~| NOTE calling a function with ABI C using caller ABI Rust //~| NOTE inside `call_rust_fn` } static VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern "C" fn()) }); -//~^ WARN skipping const checks -//~| NOTE inside `VAL` +//~^ NOTE inside `VAL` fn main() {} diff --git a/src/test/ui/consts/miri_unleashed/abi-mismatch.stderr b/src/test/ui/consts/miri_unleashed/abi-mismatch.stderr index 674a293d281..d55090c75e6 100644 --- a/src/test/ui/consts/miri_unleashed/abi-mismatch.stderr +++ b/src/test/ui/consts/miri_unleashed/abi-mismatch.stderr @@ -1,15 +1,3 @@ -warning: skipping const checks - --> $DIR/abi-mismatch.rs:10:5 - | -LL | my_fn(); - | ^^^^^^^ - -warning: skipping const checks - --> $DIR/abi-mismatch.rs:17:40 - | -LL | static VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern "C" fn()) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error[E0080]: could not evaluate static initializer --> $DIR/abi-mismatch.rs:10:5 | @@ -20,8 +8,21 @@ LL | my_fn(); | inside `call_rust_fn` at $DIR/abi-mismatch.rs:10:5 ... LL | static VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern "C" fn()) }); - | --------------------------------------------------------------------- inside `VAL` at $DIR/abi-mismatch.rs:17:18 + | --------------------------------------------------------------------- inside `VAL` at $DIR/abi-mismatch.rs:16:18 -error: aborting due to previous error; 2 warnings emitted +warning: skipping const checks + | +help: skipping check that does not even have a feature gate + --> $DIR/abi-mismatch.rs:10:5 + | +LL | my_fn(); + | ^^^^^^^ +help: skipping check that does not even have a feature gate + --> $DIR/abi-mismatch.rs:16:40 + | +LL | static VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern "C" fn()) }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/miri_unleashed/assoc_const.rs b/src/test/ui/consts/miri_unleashed/assoc_const.rs index cfbcc959d3b..5f520c2cfdb 100644 --- a/src/test/ui/consts/miri_unleashed/assoc_const.rs +++ b/src/test/ui/consts/miri_unleashed/assoc_const.rs @@ -11,7 +11,7 @@ trait Foo { } trait Bar> { - const F: u32 = (U::X, 42).1; //~ WARN skipping const checks + const F: u32 = (U::X, 42).1; } impl Foo for () { diff --git a/src/test/ui/consts/miri_unleashed/assoc_const.stderr b/src/test/ui/consts/miri_unleashed/assoc_const.stderr index 8d8d9f9ba4c..193a49bb266 100644 --- a/src/test/ui/consts/miri_unleashed/assoc_const.stderr +++ b/src/test/ui/consts/miri_unleashed/assoc_const.stderr @@ -1,15 +1,17 @@ -warning: skipping const checks - --> $DIR/assoc_const.rs:14:20 - | -LL | const F: u32 = (U::X, 42).1; - | ^^^^^^^^^^ - error[E0080]: erroneous constant used --> $DIR/assoc_const.rs:31:13 | LL | let y = , String>>::F; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors +warning: skipping const checks + | +help: skipping check that does not even have a feature gate + --> $DIR/assoc_const.rs:14:20 + | +LL | const F: u32 = (U::X, 42).1; + | ^^^^^^^^^^ + error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/miri_unleashed/box.rs b/src/test/ui/consts/miri_unleashed/box.rs index 1b18470eded..1f0b7f7e78a 100644 --- a/src/test/ui/consts/miri_unleashed/box.rs +++ b/src/test/ui/consts/miri_unleashed/box.rs @@ -1,5 +1,5 @@ // compile-flags: -Zunleash-the-miri-inside-of-you -#![feature(const_mut_refs, box_syntax)] +#![feature(box_syntax)] #![allow(const_err)] use std::mem::ManuallyDrop; @@ -8,7 +8,6 @@ fn main() {} static TEST_BAD: &mut i32 = { &mut *(box 0) - //~^ WARN skipping const check - //~| ERROR could not evaluate static initializer + //~^ ERROR could not evaluate static initializer //~| NOTE heap allocations }; diff --git a/src/test/ui/consts/miri_unleashed/box.stderr b/src/test/ui/consts/miri_unleashed/box.stderr index d1b404ea737..768b795ca5b 100644 --- a/src/test/ui/consts/miri_unleashed/box.stderr +++ b/src/test/ui/consts/miri_unleashed/box.stderr @@ -1,15 +1,32 @@ -warning: skipping const checks - --> $DIR/box.rs:10:11 - | -LL | &mut *(box 0) - | ^^^^^^^ - error[E0080]: could not evaluate static initializer --> $DIR/box.rs:10:11 | LL | &mut *(box 0) | ^^^^^^^ "heap allocations via `box` keyword" needs an rfc before being allowed inside constants +warning: skipping const checks + | +help: skipping check that does not even have a feature gate + --> $DIR/box.rs:10:11 + | +LL | &mut *(box 0) + | ^^^^^^^ +help: skipping check for `const_mut_refs` feature + --> $DIR/box.rs:10:16 + | +LL | &mut *(box 0) + | ^ +help: skipping check for `const_mut_refs` feature + --> $DIR/box.rs:10:5 + | +LL | &mut *(box 0) + | ^^^^^^^^^^^^^ +help: skipping check for `const_mut_refs` feature + --> $DIR/box.rs:10:5 + | +LL | &mut *(box 0) + | ^^^^^^^^^^^^^ + error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0080`. 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 6b205a2f66d..c9dc1de515b 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 @@ -2,8 +2,6 @@ // compile-flags: -Zunleash-the-miri-inside-of-you #![allow(const_err)] -#![feature(const_raw_ptr_deref)] - use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; @@ -13,20 +11,15 @@ use std::sync::atomic::Ordering; const MUTATE_INTERIOR_MUT: usize = { static FOO: AtomicUsize = AtomicUsize::new(0); FOO.fetch_add(1, Ordering::Relaxed) - //~^ WARN skipping const checks - //~| WARN skipping const checks }; const READ_INTERIOR_MUT: usize = { static FOO: AtomicUsize = AtomicUsize::new(0); unsafe { *(&FOO as *const _ as *const usize) } - //~^ WARN skipping const checks }; static mut MUTABLE: u32 = 0; const READ_MUT: u32 = unsafe { MUTABLE }; -//~^ WARN skipping const checks -//~| WARN skipping const checks fn main() { MUTATE_INTERIOR_MUT; 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 acc3b637f58..e5cd86b3d6c 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 @@ -1,51 +1,54 @@ -warning: skipping const checks - --> $DIR/const_refers_to_static.rs:15:5 - | -LL | FOO.fetch_add(1, Ordering::Relaxed) - | ^^^ - -warning: skipping const checks - --> $DIR/const_refers_to_static.rs:15:5 - | -LL | FOO.fetch_add(1, Ordering::Relaxed) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: skipping const checks - --> $DIR/const_refers_to_static.rs:22:17 - | -LL | unsafe { *(&FOO as *const _ as *const usize) } - | ^^^ - -warning: skipping const checks - --> $DIR/const_refers_to_static.rs:27:32 - | -LL | const READ_MUT: u32 = unsafe { MUTABLE }; - | ^^^^^^^ - -warning: skipping const checks - --> $DIR/const_refers_to_static.rs:27:32 - | -LL | const READ_MUT: u32 = unsafe { MUTABLE }; - | ^^^^^^^ - error[E0080]: erroneous constant used - --> $DIR/const_refers_to_static.rs:32:5 + --> $DIR/const_refers_to_static.rs:25:5 | LL | MUTATE_INTERIOR_MUT; | ^^^^^^^^^^^^^^^^^^^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const_refers_to_static.rs:34:5 + --> $DIR/const_refers_to_static.rs:27:5 | LL | READ_INTERIOR_MUT; | ^^^^^^^^^^^^^^^^^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const_refers_to_static.rs:36:5 + --> $DIR/const_refers_to_static.rs:29:5 | LL | READ_MUT; | ^^^^^^^^ referenced constant has errors -error: aborting due to 3 previous errors; 5 warnings emitted +warning: skipping const checks + | +help: skipping check that does not even have a feature gate + --> $DIR/const_refers_to_static.rs:13:5 + | +LL | FOO.fetch_add(1, Ordering::Relaxed) + | ^^^ +help: skipping check that does not even have a feature gate + --> $DIR/const_refers_to_static.rs:13:5 + | +LL | FOO.fetch_add(1, Ordering::Relaxed) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: skipping check that does not even have a feature gate + --> $DIR/const_refers_to_static.rs:18:17 + | +LL | unsafe { *(&FOO as *const _ as *const usize) } + | ^^^ +help: skipping check for `const_raw_ptr_deref` feature + --> $DIR/const_refers_to_static.rs:18:14 + | +LL | unsafe { *(&FOO as *const _ as *const usize) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: skipping check that does not even have a feature gate + --> $DIR/const_refers_to_static.rs:22:32 + | +LL | const READ_MUT: u32 = unsafe { MUTABLE }; + | ^^^^^^^ +help: skipping check that does not even have a feature gate + --> $DIR/const_refers_to_static.rs:22:32 + | +LL | const READ_MUT: u32 = unsafe { MUTABLE }; + | ^^^^^^^ + +error: aborting due to 3 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/miri_unleashed/const_refers_to_static2.rs b/src/test/ui/consts/miri_unleashed/const_refers_to_static2.rs index 553d90f1891..b5db685ef2c 100644 --- a/src/test/ui/consts/miri_unleashed/const_refers_to_static2.rs +++ b/src/test/ui/consts/miri_unleashed/const_refers_to_static2.rs @@ -1,8 +1,6 @@ // compile-flags: -Zunleash-the-miri-inside-of-you #![allow(const_err)] -#![feature(const_raw_ptr_deref)] - use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; @@ -14,7 +12,6 @@ const REF_INTERIOR_MUT: &usize = { //~ ERROR undefined behavior to use this valu //~| NOTE static FOO: AtomicUsize = AtomicUsize::new(0); unsafe { &*(&FOO as *const _ as *const usize) } - //~^ WARN skipping const checks }; // ok some day perhaps @@ -23,7 +20,6 @@ const READ_IMMUT: &usize = { //~ ERROR it is undefined behavior to use this valu //~| NOTE static FOO: usize = 0; &FOO - //~^ WARN skipping const checks }; fn main() {} diff --git a/src/test/ui/consts/miri_unleashed/const_refers_to_static2.stderr b/src/test/ui/consts/miri_unleashed/const_refers_to_static2.stderr index 33f4a42605c..2e40b38dac7 100644 --- a/src/test/ui/consts/miri_unleashed/const_refers_to_static2.stderr +++ b/src/test/ui/consts/miri_unleashed/const_refers_to_static2.stderr @@ -1,43 +1,47 @@ -warning: skipping const checks - --> $DIR/const_refers_to_static2.rs:16:18 - | -LL | unsafe { &*(&FOO as *const _ as *const usize) } - | ^^^ - -warning: skipping const checks - --> $DIR/const_refers_to_static2.rs:25:6 - | -LL | &FOO - | ^^^ - error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static2.rs:12:1 + --> $DIR/const_refers_to_static2.rs:10:1 | LL | / const REF_INTERIOR_MUT: &usize = { LL | | LL | | LL | | static FOO: AtomicUsize = AtomicUsize::new(0); LL | | unsafe { &*(&FOO as *const _ as *const usize) } -LL | | LL | | }; | |__^ type validation failed: encountered a reference pointing to a static variable | = 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. error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static2.rs:21:1 + --> $DIR/const_refers_to_static2.rs:18:1 | LL | / const READ_IMMUT: &usize = { LL | | LL | | LL | | static FOO: usize = 0; LL | | &FOO -LL | | LL | | }; | |__^ type validation failed: encountered a reference pointing to a static variable | = 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. -error: aborting due to 2 previous errors; 2 warnings emitted +warning: skipping const checks + | +help: skipping check that does not even have a feature gate + --> $DIR/const_refers_to_static2.rs:14:18 + | +LL | unsafe { &*(&FOO as *const _ as *const usize) } + | ^^^ +help: skipping check for `const_raw_ptr_deref` feature + --> $DIR/const_refers_to_static2.rs:14:14 + | +LL | unsafe { &*(&FOO as *const _ as *const usize) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: skipping check that does not even have a feature gate + --> $DIR/const_refers_to_static2.rs:22:6 + | +LL | &FOO + | ^^^ + +error: aborting due to 2 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs b/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs index 8bdb48e6f12..52f6536b5ea 100644 --- a/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs +++ b/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs @@ -1,8 +1,9 @@ -// compile-flags: -Zunleash-the-miri-inside-of-you -Zdeduplicate-diagnostics +// compile-flags: -Zunleash-the-miri-inside-of-you // aux-build:static_cross_crate.rs #![allow(const_err)] -#![feature(exclusive_range_pattern, half_open_range_patterns, const_if_match, const_panic)] +// `const_if_match` is a HIR check and thus needed even when unleashed. +#![feature(exclusive_range_pattern, half_open_range_patterns, const_if_match)] extern crate static_cross_crate; @@ -12,29 +13,25 @@ const SLICE_MUT: &[u8; 1] = { //~ ERROR undefined behavior to use this value //~| NOTE encountered a reference pointing to a static variable //~| NOTE unsafe { &static_cross_crate::ZERO } - //~^ WARN skipping const checks }; const U8_MUT: &u8 = { //~ ERROR undefined behavior to use this value //~| NOTE encountered a reference pointing to a static variable //~| NOTE unsafe { &static_cross_crate::ZERO[0] } - //~^ WARN skipping const checks }; // Also test indirection that reads from other static. This causes a const_err. #[warn(const_err)] //~ NOTE const U8_MUT2: &u8 = { //~ NOTE unsafe { &(*static_cross_crate::ZERO_REF)[0] } - //~^ WARN skipping const checks - //~| WARN [const_err] + //~^ WARN [const_err] //~| NOTE constant accesses static }; #[warn(const_err)] //~ NOTE const U8_MUT3: &u8 = { //~ NOTE unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } - //~^ WARN skipping const checks - //~| WARN [const_err] + //~^ WARN [const_err] //~| NOTE constant accesses static }; @@ -42,6 +39,7 @@ pub fn test(x: &[u8; 1]) -> bool { match x { SLICE_MUT => true, //~^ ERROR could not evaluate constant pattern + //~| ERROR could not evaluate constant pattern &[1..] => false, } } @@ -50,6 +48,7 @@ pub fn test2(x: &u8) -> bool { match x { U8_MUT => true, //~^ ERROR could not evaluate constant pattern + //~| ERROR could not evaluate constant pattern &(1..) => false, } } @@ -60,6 +59,7 @@ pub fn test3(x: &u8) -> bool { match x { U8_MUT2 => true, //~^ ERROR could not evaluate constant pattern + //~| ERROR could not evaluate constant pattern &(1..) => false, } } @@ -67,6 +67,7 @@ pub fn test4(x: &u8) -> bool { match x { U8_MUT3 => true, //~^ ERROR could not evaluate constant pattern + //~| ERROR could not evaluate constant pattern &(1..) => false, } } 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 bc6375f3d5e..9d1e88a811f 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 @@ -1,34 +1,21 @@ -warning: skipping const checks - --> $DIR/const_refers_to_static_cross_crate.rs:14:15 - | -LL | unsafe { &static_cross_crate::ZERO } - | ^^^^^^^^^^^^^^^^^^^^^^^^ - error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static_cross_crate.rs:11:1 + --> $DIR/const_refers_to_static_cross_crate.rs:12:1 | LL | / const SLICE_MUT: &[u8; 1] = { LL | | LL | | LL | | unsafe { &static_cross_crate::ZERO } -LL | | LL | | }; | |__^ type validation failed: encountered a reference pointing to a static variable | = 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. error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:43:9 + --> $DIR/const_refers_to_static_cross_crate.rs:40:9 | LL | SLICE_MUT => true, | ^^^^^^^^^ -warning: skipping const checks - --> $DIR/const_refers_to_static_cross_crate.rs:21:15 - | -LL | unsafe { &static_cross_crate::ZERO[0] } - | ^^^^^^^^^^^^^^^^^^^^^^^^ - error[E0080]: it is undefined behavior to use this value --> $DIR/const_refers_to_static_cross_crate.rs:18:1 | @@ -36,68 +23,53 @@ LL | / const U8_MUT: &u8 = { LL | | LL | | LL | | unsafe { &static_cross_crate::ZERO[0] } -LL | | LL | | }; | |__^ type validation failed: encountered a reference pointing to a static variable | = 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. error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:51:9 + --> $DIR/const_refers_to_static_cross_crate.rs:49:9 | LL | U8_MUT => true, | ^^^^^^ -warning: skipping const checks - --> $DIR/const_refers_to_static_cross_crate.rs:28:17 - | -LL | unsafe { &(*static_cross_crate::ZERO_REF)[0] } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - warning: any use of this value will cause an error - --> $DIR/const_refers_to_static_cross_crate.rs:28:14 + --> $DIR/const_refers_to_static_cross_crate.rs:27:14 | LL | / const U8_MUT2: &u8 = { LL | | unsafe { &(*static_cross_crate::ZERO_REF)[0] } | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static LL | | LL | | -LL | | LL | | }; | |__- | note: the lint level is defined here - --> $DIR/const_refers_to_static_cross_crate.rs:26:8 + --> $DIR/const_refers_to_static_cross_crate.rs:25:8 | LL | #[warn(const_err)] | ^^^^^^^^^ error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:61:9 + --> $DIR/const_refers_to_static_cross_crate.rs:60:9 | LL | U8_MUT2 => true, | ^^^^^^^ -warning: skipping const checks - --> $DIR/const_refers_to_static_cross_crate.rs:35:20 - | -LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - warning: any use of this value will cause an error - --> $DIR/const_refers_to_static_cross_crate.rs:35:51 + --> $DIR/const_refers_to_static_cross_crate.rs:33:51 | LL | / const U8_MUT3: &u8 = { LL | | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | | ^^^^^^^^^^^ constant accesses static LL | | LL | | -LL | | LL | | }; | |__- | note: the lint level is defined here - --> $DIR/const_refers_to_static_cross_crate.rs:33:8 + --> $DIR/const_refers_to_static_cross_crate.rs:31:8 | LL | #[warn(const_err)] | ^^^^^^^^^ @@ -108,6 +80,89 @@ error: could not evaluate constant pattern LL | U8_MUT3 => true, | ^^^^^^^ -error: aborting due to 6 previous errors; 6 warnings emitted +error: could not evaluate constant pattern + --> $DIR/const_refers_to_static_cross_crate.rs:40:9 + | +LL | SLICE_MUT => true, + | ^^^^^^^^^ + +error: could not evaluate constant pattern + --> $DIR/const_refers_to_static_cross_crate.rs:49:9 + | +LL | U8_MUT => true, + | ^^^^^^ + +error: could not evaluate constant pattern + --> $DIR/const_refers_to_static_cross_crate.rs:60:9 + | +LL | U8_MUT2 => true, + | ^^^^^^^ + +error: could not evaluate constant pattern + --> $DIR/const_refers_to_static_cross_crate.rs:68:9 + | +LL | U8_MUT3 => true, + | ^^^^^^^ + +warning: skipping const checks + | +help: skipping check that does not even have a feature gate + --> $DIR/const_refers_to_static_cross_crate.rs:15:15 + | +LL | unsafe { &static_cross_crate::ZERO } + | ^^^^^^^^^^^^^^^^^^^^^^^^ +help: skipping check that does not even have a feature gate + --> $DIR/const_refers_to_static_cross_crate.rs:15:15 + | +LL | unsafe { &static_cross_crate::ZERO } + | ^^^^^^^^^^^^^^^^^^^^^^^^ +help: skipping check that does not even have a feature gate + --> $DIR/const_refers_to_static_cross_crate.rs:21:15 + | +LL | unsafe { &static_cross_crate::ZERO[0] } + | ^^^^^^^^^^^^^^^^^^^^^^^^ +help: skipping check that does not even have a feature gate + --> $DIR/const_refers_to_static_cross_crate.rs:21:15 + | +LL | unsafe { &static_cross_crate::ZERO[0] } + | ^^^^^^^^^^^^^^^^^^^^^^^^ +help: skipping check that does not even have a feature gate + --> $DIR/const_refers_to_static_cross_crate.rs:21:15 + | +LL | unsafe { &static_cross_crate::ZERO[0] } + | ^^^^^^^^^^^^^^^^^^^^^^^^ +help: skipping check that does not even have a feature gate + --> $DIR/const_refers_to_static_cross_crate.rs:27:17 + | +LL | unsafe { &(*static_cross_crate::ZERO_REF)[0] } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: skipping check that does not even have a feature gate + --> $DIR/const_refers_to_static_cross_crate.rs:33:20 + | +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:33:20 + | +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:33: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:33:77 + | +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:33:20 + | +LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 10 previous errors; 3 warnings emitted For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/miri_unleashed/drop.rs b/src/test/ui/consts/miri_unleashed/drop.rs index 3b9208dd126..9bd56e81cbf 100644 --- a/src/test/ui/consts/miri_unleashed/drop.rs +++ b/src/test/ui/consts/miri_unleashed/drop.rs @@ -15,5 +15,4 @@ static TEST_OK: () = { // The actual error is tested by the error-pattern above. static TEST_BAD: () = { let _v: Vec = Vec::new(); - //~^ WARN skipping const check }; diff --git a/src/test/ui/consts/miri_unleashed/drop.stderr b/src/test/ui/consts/miri_unleashed/drop.stderr index 9d89836e3f8..34ab5155e22 100644 --- a/src/test/ui/consts/miri_unleashed/drop.stderr +++ b/src/test/ui/consts/miri_unleashed/drop.stderr @@ -1,9 +1,3 @@ -warning: skipping const checks - --> $DIR/drop.rs:17:9 - | -LL | let _v: Vec = Vec::new(); - | ^^ - error[E0080]: could not evaluate static initializer --> $SRC_DIR/libcore/ptr/mod.rs:LL:COL | @@ -17,10 +11,18 @@ LL | | } | |_calling non-const function ` as std::ops::Drop>::drop` | inside `std::intrinsics::drop_in_place::> - shim(Some(std::vec::Vec))` at $SRC_DIR/libcore/ptr/mod.rs:LL:COL | - ::: $DIR/drop.rs:19:1 + ::: $DIR/drop.rs:18:1 | LL | }; - | - inside `TEST_BAD` at $DIR/drop.rs:19:1 + | - inside `TEST_BAD` at $DIR/drop.rs:18:1 + +warning: skipping const checks + | +help: skipping check that does not even have a feature gate + --> $DIR/drop.rs:17:9 + | +LL | let _v: Vec = Vec::new(); + | ^^ error: aborting due to previous error; 1 warning emitted diff --git a/src/test/ui/consts/miri_unleashed/inline_asm.rs b/src/test/ui/consts/miri_unleashed/inline_asm.rs index ddc4767b83a..7b2b1ed4965 100644 --- a/src/test/ui/consts/miri_unleashed/inline_asm.rs +++ b/src/test/ui/consts/miri_unleashed/inline_asm.rs @@ -9,8 +9,7 @@ fn main() {} static TEST_BAD: () = { unsafe { llvm_asm!("xor %eax, %eax" ::: "eax"); } //~^ ERROR could not evaluate static initializer - //~| NOTE in this expansion of llvm_asm! //~| NOTE inline assembly is not supported - //~| WARN skipping const checks + //~| NOTE in this expansion of llvm_asm! //~| NOTE in this expansion of llvm_asm! }; diff --git a/src/test/ui/consts/miri_unleashed/inline_asm.stderr b/src/test/ui/consts/miri_unleashed/inline_asm.stderr index 444a0172621..0f5ee5de396 100644 --- a/src/test/ui/consts/miri_unleashed/inline_asm.stderr +++ b/src/test/ui/consts/miri_unleashed/inline_asm.stderr @@ -1,11 +1,3 @@ -warning: skipping const checks - --> $DIR/inline_asm.rs:10:14 - | -LL | unsafe { llvm_asm!("xor %eax, %eax" ::: "eax"); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - error[E0080]: could not evaluate static initializer --> $DIR/inline_asm.rs:10:14 | @@ -14,6 +6,15 @@ LL | unsafe { llvm_asm!("xor %eax, %eax" ::: "eax"); } | = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) +warning: skipping const checks + | +help: skipping check that does not even have a feature gate + --> $DIR/inline_asm.rs:10:14 + | +LL | unsafe { llvm_asm!("xor %eax, %eax" ::: "eax"); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) + error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/miri_unleashed/mutable_const.rs b/src/test/ui/consts/miri_unleashed/mutable_const.rs index 5cc8808be5d..f8aa6528273 100644 --- a/src/test/ui/consts/miri_unleashed/mutable_const.rs +++ b/src/test/ui/consts/miri_unleashed/mutable_const.rs @@ -1,8 +1,6 @@ // compile-flags: -Zunleash-the-miri-inside-of-you // normalize-stderr-test "alloc[0-9]+" -> "allocN" -#![feature(const_raw_ptr_deref)] -#![feature(const_mut_refs)] #![deny(const_err)] // The `allow` variant is tested by `mutable_const2`. //~^ NOTE lint level // Here we check that even though `MUTABLE_BEHIND_RAW` is created from a mutable @@ -13,7 +11,6 @@ use std::cell::UnsafeCell; // make sure we do not just intern this as mutable const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _; -//~^ WARN: skipping const checks const MUTATING_BEHIND_RAW: () = { //~ NOTE // Test that `MUTABLE_BEHIND_RAW` is actually immutable, by doing this at const time. diff --git a/src/test/ui/consts/miri_unleashed/mutable_const.stderr b/src/test/ui/consts/miri_unleashed/mutable_const.stderr index 34993247fca..4772baf9d9a 100644 --- a/src/test/ui/consts/miri_unleashed/mutable_const.stderr +++ b/src/test/ui/consts/miri_unleashed/mutable_const.stderr @@ -1,11 +1,5 @@ -warning: skipping const checks - --> $DIR/mutable_const.rs:15:38 - | -LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _; - | ^^^^^^^^^^^^^^^^^^^^ - error: any use of this value will cause an error - --> $DIR/mutable_const.rs:21:9 + --> $DIR/mutable_const.rs:18:9 | LL | / const MUTATING_BEHIND_RAW: () = { LL | | // Test that `MUTABLE_BEHIND_RAW` is actually immutable, by doing this at const time. @@ -18,10 +12,28 @@ LL | | }; | |__- | note: the lint level is defined here - --> $DIR/mutable_const.rs:6:9 + --> $DIR/mutable_const.rs:4:9 | LL | #![deny(const_err)] // The `allow` variant is tested by `mutable_const2`. | ^^^^^^^^^ +warning: skipping const checks + | +help: skipping check that does not even have a feature gate + --> $DIR/mutable_const.rs:13:38 + | +LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _; + | ^^^^^^^^^^^^^^^^^^^^ +help: skipping check for `const_raw_ptr_deref` feature + --> $DIR/mutable_const.rs:18:9 + | +LL | *MUTABLE_BEHIND_RAW = 99 + | ^^^^^^^^^^^^^^^^^^^^^^^^ +help: skipping check for `const_mut_refs` feature + --> $DIR/mutable_const.rs:18:9 + | +LL | *MUTABLE_BEHIND_RAW = 99 + | ^^^^^^^^^^^^^^^^^^^^^^^^ + error: aborting due to previous error; 1 warning emitted diff --git a/src/test/ui/consts/miri_unleashed/mutable_const2.rs b/src/test/ui/consts/miri_unleashed/mutable_const2.rs index c2c7fb18e2a..867091af7ba 100644 --- a/src/test/ui/consts/miri_unleashed/mutable_const2.rs +++ b/src/test/ui/consts/miri_unleashed/mutable_const2.rs @@ -5,15 +5,12 @@ // normalize-stderr-test "note: compiler flags: .*" -> "note: compiler flags: FLAGS" // normalize-stderr-test "interpret/intern.rs:[0-9]+:[0-9]+" -> "interpret/intern.rs:LL:CC" -#![feature(const_raw_ptr_deref)] -#![feature(const_mut_refs)] #![allow(const_err)] use std::cell::UnsafeCell; // make sure we do not just intern this as mutable const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _; -//~^ WARN: skipping const checks -//~| ERROR: mutable allocation in constant +//~^ ERROR: mutable allocation in constant fn main() {} diff --git a/src/test/ui/consts/miri_unleashed/mutable_const2.stderr b/src/test/ui/consts/miri_unleashed/mutable_const2.stderr index 39027dd2b41..98a1c8bdd89 100644 --- a/src/test/ui/consts/miri_unleashed/mutable_const2.stderr +++ b/src/test/ui/consts/miri_unleashed/mutable_const2.stderr @@ -1,5 +1,7 @@ warning: skipping const checks - --> $DIR/mutable_const2.rs:15:38 + | +help: skipping check that does not even have a feature gate + --> $DIR/mutable_const2.rs:13:38 | LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _; | ^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +9,7 @@ LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *m warning: 1 warning emitted error: internal compiler error: mutable allocation in constant - --> $DIR/mutable_const2.rs:15:1 + --> $DIR/mutable_const2.rs:13:1 | LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/consts/miri_unleashed/mutable_references.rs b/src/test/ui/consts/miri_unleashed/mutable_references.rs index fe3c4ee70f2..ed2ca86ba2c 100644 --- a/src/test/ui/consts/miri_unleashed/mutable_references.rs +++ b/src/test/ui/consts/miri_unleashed/mutable_references.rs @@ -1,5 +1,4 @@ // compile-flags: -Zunleash-the-miri-inside-of-you -#![feature(const_mut_refs)] #![allow(const_err)] use std::cell::UnsafeCell; @@ -26,7 +25,6 @@ unsafe impl Sync for Meh {} static MEH: Meh = Meh { x: &UnsafeCell::new(42), - //~^ WARN: skipping const checks }; // this is fine for the same reason as `BAR`. diff --git a/src/test/ui/consts/miri_unleashed/mutable_references.stderr b/src/test/ui/consts/miri_unleashed/mutable_references.stderr index 69d02bd543d..83c4e0ceba0 100644 --- a/src/test/ui/consts/miri_unleashed/mutable_references.stderr +++ b/src/test/ui/consts/miri_unleashed/mutable_references.stderr @@ -1,15 +1,37 @@ -warning: skipping const checks - --> $DIR/mutable_references.rs:28:8 - | -LL | x: &UnsafeCell::new(42), - | ^^^^^^^^^^^^^^^^^^^^ - error[E0594]: cannot assign to `*OH_YES`, as `OH_YES` is an immutable static item - --> $DIR/mutable_references.rs:39:5 + --> $DIR/mutable_references.rs:37:5 | LL | *OH_YES = 99; | ^^^^^^^^^^^^ cannot assign +warning: skipping const checks + | +help: skipping check for `const_mut_refs` feature + --> $DIR/mutable_references.rs:9:26 + | +LL | static FOO: &&mut u32 = &&mut 42; + | ^^^^^^^ +help: skipping check for `const_mut_refs` feature + --> $DIR/mutable_references.rs:13:23 + | +LL | static BAR: &mut () = &mut (); + | ^^^^^^^ +help: skipping check for `const_mut_refs` feature + --> $DIR/mutable_references.rs:18:28 + | +LL | static BOO: &mut Foo<()> = &mut Foo(()); + | ^^^^^^^^^^^^ +help: skipping check that does not even have a feature gate + --> $DIR/mutable_references.rs:27:8 + | +LL | x: &UnsafeCell::new(42), + | ^^^^^^^^^^^^^^^^^^^^ +help: skipping check for `const_mut_refs` feature + --> $DIR/mutable_references.rs:31:27 + | +LL | static OH_YES: &mut i32 = &mut 42; + | ^^^^^^^ + error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/consts/miri_unleashed/mutable_references_ice.rs b/src/test/ui/consts/miri_unleashed/mutable_references_ice.rs index 9d8d5f513c7..7388aad2a9e 100644 --- a/src/test/ui/consts/miri_unleashed/mutable_references_ice.rs +++ b/src/test/ui/consts/miri_unleashed/mutable_references_ice.rs @@ -19,7 +19,7 @@ unsafe impl Sync for Meh {} // the following will never be ok! const MUH: Meh = Meh { - x: &UnsafeCell::new(42), //~ WARN: skipping const checks + x: &UnsafeCell::new(42), }; fn main() { diff --git a/src/test/ui/consts/miri_unleashed/mutable_references_ice.stderr b/src/test/ui/consts/miri_unleashed/mutable_references_ice.stderr index 545a1af5c6f..7ddf77af4d3 100644 --- a/src/test/ui/consts/miri_unleashed/mutable_references_ice.stderr +++ b/src/test/ui/consts/miri_unleashed/mutable_references_ice.stderr @@ -1,9 +1,3 @@ -warning: skipping const checks - --> $DIR/mutable_references_ice.rs:22:8 - | -LL | x: &UnsafeCell::new(42), - | ^^^^^^^^^^^^^^^^^^^^ - thread 'rustc' panicked at 'assertion failed: `(left != right)` left: `Const`, right: `Const`: UnsafeCells are not allowed behind references in constants. This should have been prevented statically by const qualification. If this were allowed one would be able to change a constant at one use site and other use sites could observe that mutation.', src/librustc_mir/interpret/intern.rs:LL:CC @@ -19,5 +13,13 @@ note: rustc VERSION running on TARGET note: compiler flags: FLAGS +warning: skipping const checks + | +help: skipping check that does not even have a feature gate + --> $DIR/mutable_references_ice.rs:22:8 + | +LL | x: &UnsafeCell::new(42), + | ^^^^^^^^^^^^^^^^^^^^ + warning: 1 warning emitted diff --git a/src/test/ui/consts/miri_unleashed/non_const_fn.rs b/src/test/ui/consts/miri_unleashed/non_const_fn.rs index b401884139d..70da94df7a2 100644 --- a/src/test/ui/consts/miri_unleashed/non_const_fn.rs +++ b/src/test/ui/consts/miri_unleashed/non_const_fn.rs @@ -6,7 +6,7 @@ fn foo() {} -static C: () = foo(); //~ WARN: skipping const checks +static C: () = foo(); //~^ ERROR could not evaluate static initializer //~| NOTE calling non-const function `foo` diff --git a/src/test/ui/consts/miri_unleashed/non_const_fn.stderr b/src/test/ui/consts/miri_unleashed/non_const_fn.stderr index d20cd6d6f0b..3e9658ad88e 100644 --- a/src/test/ui/consts/miri_unleashed/non_const_fn.stderr +++ b/src/test/ui/consts/miri_unleashed/non_const_fn.stderr @@ -1,15 +1,17 @@ -warning: skipping const checks - --> $DIR/non_const_fn.rs:9:16 - | -LL | static C: () = foo(); - | ^^^^^ - error[E0080]: could not evaluate static initializer --> $DIR/non_const_fn.rs:9:16 | LL | static C: () = foo(); | ^^^^^ calling non-const function `foo` +warning: skipping const checks + | +help: skipping check that does not even have a feature gate + --> $DIR/non_const_fn.rs:9:16 + | +LL | static C: () = foo(); + | ^^^^^ + error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/miri_unleashed/read_from_static.rs b/src/test/ui/consts/read_from_static_mut_ref.rs similarity index 77% rename from src/test/ui/consts/miri_unleashed/read_from_static.rs rename to src/test/ui/consts/read_from_static_mut_ref.rs index 821c501c9fc..c18227e0f55 100644 --- a/src/test/ui/consts/miri_unleashed/read_from_static.rs +++ b/src/test/ui/consts/read_from_static_mut_ref.rs @@ -1,5 +1,4 @@ // run-pass -// compile-flags: -Zunleash-the-miri-inside-of-you #![feature(const_mut_refs)] #![allow(const_err)] diff --git a/src/test/ui/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.rs b/src/test/ui/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.rs index fe2b92eafdb..edf9ba2c41a 100644 --- a/src/test/ui/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.rs +++ b/src/test/ui/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.rs @@ -18,7 +18,7 @@ const fn attributed() -> L { const fn calling_attributed() -> L { // We need `-Z unleash-the-miri-inside-of-you` for this as we don't have `const fn` pointers. let ptr: fn() -> L = attributed; - ptr() //~ WARN skipping const checks + ptr() } fn main() { diff --git a/src/test/ui/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.stderr b/src/test/ui/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.stderr index 3a9be6a28fa..cf8ca57714c 100644 --- a/src/test/ui/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.stderr +++ b/src/test/ui/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.stderr @@ -1,4 +1,6 @@ warning: skipping const checks + | +help: skipping check that does not even have a feature gate --> $DIR/caller-location-fnptr-rt-ctfe-equiv.rs:21:5 | LL | ptr()