Auto merge of #71631 - RalfJung:miri-unleash-the-gates, r=oli-obk
Miri: unleash all feature gates IMO it is silly to unleash features that do not even have a feature gate yet, but not unleash features that do. The only thing this achieves is making unleashed mode annoying to use as we have to figure out the feature flags to enable (and not always do the error messages say what that flag is). Given that the point of `-Z unleash-the-miri-inside-of-you` is to debug the Miri internals, I see no good reason for this extra hurdle. I cannot imagine a situation where we'd use that flag, realize the program also requires some feature gate, and then be like "oh I guess if this feature is unstable I will do something else". Instead, we'll always just add that flag to the code as well, so requiring the flag achieves nothing. r? @oli-obk @ecstatic-morse Fixes https://github.com/rust-lang/rust/issues/71630
This commit is contained in:
commit
a0c61a9044
@ -193,7 +193,7 @@ pub fn run_compiler_in_existing_thread_pool<R>(
|
||||
|
||||
let r = {
|
||||
let _sess_abort_error = OnDrop(|| {
|
||||
compiler.sess.diagnostic().print_error_count(registry);
|
||||
compiler.sess.finish_diagnostics(registry);
|
||||
});
|
||||
|
||||
f(&compiler)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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<CtfeBacktrace>,
|
||||
|
||||
/// 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<Vec<(Span, Option<Symbol>)>>,
|
||||
|
||||
/// 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<Symbol>) {
|
||||
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,
|
||||
};
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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
|
||||
|
||||
|
@ -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() {}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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`.
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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`.
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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() {}
|
||||
|
@ -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`.
|
||||
|
@ -11,7 +11,7 @@ trait Foo<T> {
|
||||
}
|
||||
|
||||
trait Bar<T, U: Foo<T>> {
|
||||
const F: u32 = (U::X, 42).1; //~ WARN skipping const checks
|
||||
const F: u32 = (U::X, 42).1;
|
||||
}
|
||||
|
||||
impl Foo<u32> for () {
|
||||
|
@ -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 as Bar<Vec<u32>, 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`.
|
||||
|
@ -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
|
||||
};
|
||||
|
@ -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`.
|
||||
|
@ -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;
|
||||
|
@ -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`.
|
||||
|
@ -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() {}
|
||||
|
@ -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`.
|
||||
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
@ -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`.
|
||||
|
@ -15,5 +15,4 @@ static TEST_OK: () = {
|
||||
// The actual error is tested by the error-pattern above.
|
||||
static TEST_BAD: () = {
|
||||
let _v: Vec<i32> = Vec::new();
|
||||
//~^ WARN skipping const check
|
||||
};
|
||||
|
@ -1,9 +1,3 @@
|
||||
warning: skipping const checks
|
||||
--> $DIR/drop.rs:17:9
|
||||
|
|
||||
LL | let _v: Vec<i32> = 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 `<std::vec::Vec<i32> as std::ops::Drop>::drop`
|
||||
| inside `std::intrinsics::drop_in_place::<std::vec::Vec<i32>> - shim(Some(std::vec::Vec<i32>))` 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<i32> = Vec::new();
|
||||
| ^^
|
||||
|
||||
error: aborting due to previous error; 1 warning emitted
|
||||
|
||||
|
@ -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!
|
||||
};
|
||||
|
@ -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`.
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
||||
|
@ -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() {}
|
||||
|
@ -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 _;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -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`.
|
||||
|
@ -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`.
|
||||
|
@ -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() {
|
||||
|
@ -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
|
||||
|
||||
|
@ -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`
|
||||
|
||||
|
@ -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`.
|
||||
|
@ -1,5 +1,4 @@
|
||||
// run-pass
|
||||
// compile-flags: -Zunleash-the-miri-inside-of-you
|
||||
#![feature(const_mut_refs)]
|
||||
#![allow(const_err)]
|
||||
|
@ -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() {
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user