deduplicate warnings

This commit is contained in:
Ralf Jung 2020-04-29 09:53:22 +02:00
parent 9273962aef
commit c7eb91652f
35 changed files with 244 additions and 236 deletions

View File

@ -253,7 +253,7 @@ impl Validator<'mir, 'tcx> {
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.span_warn(self.tcx.def_span(self.def_id), "skipping const checks");
return;
}

View File

@ -8,16 +8,16 @@ const fn double_const(x: usize) -> usize { x * 2 }
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
const fn bar(x: usize) -> usize { //~ WARNING skipping const checks
X(x)
}
const fn bar_const(x: usize) -> usize {
X_CONST(x) //~ WARNING skipping const checks
const fn bar_const(x: usize) -> usize { //~ WARNING skipping const checks
X_CONST(x)
}
const fn foo(x: fn(usize) -> usize, y: usize) -> usize {
x(y) //~ WARNING skipping const checks
const fn foo(x: fn(usize) -> usize, y: usize) -> usize { //~ WARNING skipping const checks
x(y)
}
fn main() {

View File

@ -1,20 +1,26 @@
warning: skipping const checks
--> $DIR/const_fn_ptr.rs:12:5
--> $DIR/const_fn_ptr.rs:11:1
|
LL | X(x)
| ^^^^
LL | / const fn bar(x: usize) -> usize {
LL | | X(x)
LL | | }
| |_^
warning: skipping const checks
--> $DIR/const_fn_ptr.rs:16:5
--> $DIR/const_fn_ptr.rs:15:1
|
LL | X_CONST(x)
| ^^^^^^^^^^
LL | / const fn bar_const(x: usize) -> usize {
LL | | X_CONST(x)
LL | | }
| |_^
warning: skipping const checks
--> $DIR/const_fn_ptr.rs:20:5
--> $DIR/const_fn_ptr.rs:19:1
|
LL | x(y)
| ^^^^
LL | / const fn foo(x: fn(usize) -> usize, y: usize) -> usize {
LL | | x(y)
LL | | }
| |_^
warning: 3 warnings emitted

View File

@ -6,9 +6,8 @@
fn double(x: usize) -> usize { x * 2 }
const X: fn(usize) -> usize = double;
const fn bar(x: usize) -> usize {
const fn bar(x: usize) -> usize { //~ WARNING skipping const checks
X(x) // FIXME: this should error someday
//~^ WARN: skipping const checks
}
fn main() {}

View File

@ -1,8 +1,10 @@
warning: skipping const checks
--> $DIR/const_fn_ptr_fail.rs:10:5
--> $DIR/const_fn_ptr_fail.rs:9:1
|
LL | X(x) // FIXME: this should error someday
| ^^^^
LL | / const fn bar(x: usize) -> usize {
LL | | X(x) // FIXME: this should error someday
LL | | }
| |_^
warning: 1 warning emitted

View File

@ -9,8 +9,8 @@ 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
const fn bar(x: fn(usize) -> usize, y: usize) -> usize { //~ WARN skipping const checks
x(y)
}
const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday

View File

@ -1,8 +1,10 @@
warning: skipping const checks
--> $DIR/const_fn_ptr_fail2.rs:13:5
--> $DIR/const_fn_ptr_fail2.rs:12:1
|
LL | x(y)
| ^^^^
LL | / const fn bar(x: fn(usize) -> usize, y: usize) -> usize {
LL | | x(y)
LL | | }
| |_^
error[E0080]: evaluation of constant expression failed
--> $DIR/const_fn_ptr_fail2.rs:20:5

View File

@ -1,8 +1,8 @@
warning: skipping const checks
--> $DIR/const-points-to-static.rs:5:20
--> $DIR/const-points-to-static.rs:5:1
|
LL | const TEST: &u8 = &MY_STATIC;
| ^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0080]: it is undefined behavior to use this value
--> $DIR/const-points-to-static.rs:5:1

View File

@ -1,8 +1,8 @@
warning: skipping const checks
--> $DIR/const-prop-read-static-in-const.rs:5:18
--> $DIR/const-prop-read-static-in-const.rs:5:1
|
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

View File

@ -7,9 +7,9 @@
const extern "C" fn c_fn() {}
const fn call_rust_fn(my_fn: extern "Rust" fn()) {
//~^ WARN skipping const checks
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`
}

View File

@ -1,23 +1,29 @@
warning: skipping const checks
--> $DIR/abi-mismatch.rs:10:5
--> $DIR/abi-mismatch.rs:9:1
|
LL | my_fn();
| ^^^^^^^
LL | / const fn call_rust_fn(my_fn: extern "Rust" fn()) {
LL | |
LL | | my_fn();
LL | |
LL | |
LL | |
LL | | }
| |_^
warning: skipping const checks
--> $DIR/abi-mismatch.rs:17:40
--> $DIR/abi-mismatch.rs:17:1
|
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
--> $DIR/abi-mismatch.rs:11:5
|
LL | my_fn();
| ^^^^^^^
| |
| calling a function with ABI C using caller ABI Rust
| inside `call_rust_fn` at $DIR/abi-mismatch.rs:10:5
| inside `call_rust_fn` at $DIR/abi-mismatch.rs:11: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

View File

@ -1,8 +1,8 @@
warning: skipping const checks
--> $DIR/assoc_const.rs:14:20
--> $DIR/assoc_const.rs:14:5
|
LL | const F: u32 = (U::X, 42).1;
| ^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0080]: erroneous constant used
--> $DIR/assoc_const.rs:31:13

View File

@ -1,4 +1,4 @@
// compile-flags: -Zunleash-the-miri-inside-of-you
// compile-flags: -Zunleash-the-miri-inside-of-you -Zdeduplicate-diagnostics
#![feature(box_syntax)]
#![allow(const_err)]
@ -6,12 +6,8 @@ use std::mem::ManuallyDrop;
fn main() {}
static TEST_BAD: &mut i32 = {
static TEST_BAD: &mut i32 = { //~ WARN skipping const checks
&mut *(box 0)
//~^ WARN skipping const check
//~| ERROR could not evaluate static initializer
//~^ ERROR could not evaluate static initializer
//~| NOTE heap allocations
//~| WARN skipping const checks
//~| WARN skipping const checks
//~| WARN skipping const checks
};

View File

@ -1,26 +1,12 @@
warning: skipping const checks
--> $DIR/box.rs:10:11
--> $DIR/box.rs:9:1
|
LL | &mut *(box 0)
| ^^^^^^^
warning: skipping const checks
--> $DIR/box.rs:10:16
|
LL | &mut *(box 0)
| ^
warning: skipping const checks
--> $DIR/box.rs:10:5
|
LL | &mut *(box 0)
| ^^^^^^^^^^^^^
warning: skipping const checks
--> $DIR/box.rs:10:5
|
LL | &mut *(box 0)
| ^^^^^^^^^^^^^
LL | / static TEST_BAD: &mut i32 = {
LL | | &mut *(box 0)
LL | |
LL | |
LL | | };
| |__^
error[E0080]: could not evaluate static initializer
--> $DIR/box.rs:10:11
@ -28,6 +14,6 @@ error[E0080]: could not evaluate static initializer
LL | &mut *(box 0)
| ^^^^^^^ "heap allocations via `box` keyword" needs an rfc before being allowed inside constants
error: aborting due to previous error; 4 warnings emitted
error: aborting due to previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0080`.

View File

@ -1,5 +1,5 @@
// build-fail
// compile-flags: -Zunleash-the-miri-inside-of-you
// compile-flags: -Zunleash-the-miri-inside-of-you -Zdeduplicate-diagnostics
#![allow(const_err)]
use std::sync::atomic::AtomicUsize;
@ -9,23 +9,20 @@ use std::sync::atomic::Ordering;
// when *using* the const.
const MUTATE_INTERIOR_MUT: usize = {
//~^ WARN skipping const checks
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 = {
//~^ WARN skipping const checks
static FOO: AtomicUsize = AtomicUsize::new(0);
unsafe { *(&FOO as *const _ as *const usize) }
//~^ WARN skipping const checks
//~| 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;

View File

@ -1,57 +1,47 @@
warning: skipping const checks
--> $DIR/const_refers_to_static.rs:13:5
--> $DIR/const_refers_to_static.rs:11:1
|
LL | FOO.fetch_add(1, Ordering::Relaxed)
| ^^^
LL | / const MUTATE_INTERIOR_MUT: usize = {
LL | |
LL | | static FOO: AtomicUsize = AtomicUsize::new(0);
LL | | FOO.fetch_add(1, Ordering::Relaxed)
LL | | };
| |__^
warning: skipping const checks
--> $DIR/const_refers_to_static.rs:13:5
--> $DIR/const_refers_to_static.rs:17:1
|
LL | FOO.fetch_add(1, Ordering::Relaxed)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | / const READ_INTERIOR_MUT: usize = {
LL | |
LL | | static FOO: AtomicUsize = AtomicUsize::new(0);
LL | | unsafe { *(&FOO as *const _ as *const usize) }
LL | | };
| |__^
warning: skipping const checks
--> $DIR/const_refers_to_static.rs:20:17
|
LL | unsafe { *(&FOO as *const _ as *const usize) }
| ^^^
warning: skipping const checks
--> $DIR/const_refers_to_static.rs:20:14
|
LL | unsafe { *(&FOO as *const _ as *const usize) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: skipping const checks
--> $DIR/const_refers_to_static.rs:26:32
--> $DIR/const_refers_to_static.rs:24:1
|
LL | const READ_MUT: u32 = unsafe { MUTABLE };
| ^^^^^^^
warning: skipping const checks
--> $DIR/const_refers_to_static.rs:26:32
|
LL | const READ_MUT: u32 = unsafe { MUTABLE };
| ^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0080]: erroneous constant used
--> $DIR/const_refers_to_static.rs:31:5
--> $DIR/const_refers_to_static.rs:28:5
|
LL | MUTATE_INTERIOR_MUT;
| ^^^^^^^^^^^^^^^^^^^ referenced constant has errors
error[E0080]: erroneous constant used
--> $DIR/const_refers_to_static.rs:33:5
--> $DIR/const_refers_to_static.rs:30:5
|
LL | READ_INTERIOR_MUT;
| ^^^^^^^^^^^^^^^^^ referenced constant has errors
error[E0080]: erroneous constant used
--> $DIR/const_refers_to_static.rs:35:5
--> $DIR/const_refers_to_static.rs:32:5
|
LL | READ_MUT;
| ^^^^^^^^ referenced constant has errors
error: aborting due to 3 previous errors; 6 warnings emitted
error: aborting due to 3 previous errors; 3 warnings emitted
For more information about this error, try `rustc --explain E0080`.

View File

@ -1,4 +1,4 @@
// compile-flags: -Zunleash-the-miri-inside-of-you
// compile-flags: -Zunleash-the-miri-inside-of-you -Zdeduplicate-diagnostics
#![allow(const_err)]
use std::sync::atomic::AtomicUsize;
@ -8,21 +8,20 @@ use std::sync::atomic::Ordering;
// so they cause an immediate error when *defining* the const.
const REF_INTERIOR_MUT: &usize = { //~ ERROR undefined behavior to use this value
//~^ WARN skipping const checks
//~| NOTE encountered a reference pointing to a static variable
//~| NOTE
static FOO: AtomicUsize = AtomicUsize::new(0);
unsafe { &*(&FOO as *const _ as *const usize) }
//~^ WARN skipping const checks
//~| WARN skipping const checks
};
// ok some day perhaps
const READ_IMMUT: &usize = { //~ ERROR it is undefined behavior to use this value
//~^ WARN skipping const checks
//~| NOTE encountered a reference pointing to a static variable
//~| NOTE
static FOO: usize = 0;
&FOO
//~^ WARN skipping const checks
};
fn main() {}

View File

@ -1,20 +1,26 @@
warning: skipping const checks
--> $DIR/const_refers_to_static2.rs:14:18
--> $DIR/const_refers_to_static2.rs:10:1
|
LL | unsafe { &*(&FOO as *const _ as *const usize) }
| ^^^
LL | / const REF_INTERIOR_MUT: &usize = {
LL | |
LL | |
LL | |
LL | | static FOO: AtomicUsize = AtomicUsize::new(0);
LL | | unsafe { &*(&FOO as *const _ as *const usize) }
LL | | };
| |__^
warning: skipping const checks
--> $DIR/const_refers_to_static2.rs:14:14
--> $DIR/const_refers_to_static2.rs:19:1
|
LL | unsafe { &*(&FOO as *const _ as *const usize) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: skipping const checks
--> $DIR/const_refers_to_static2.rs:24:6
|
LL | &FOO
| ^^^
LL | / const READ_IMMUT: &usize = {
LL | |
LL | |
LL | |
LL | | static FOO: usize = 0;
LL | | &FOO
LL | | };
| |__^
error[E0080]: it is undefined behavior to use this value
--> $DIR/const_refers_to_static2.rs:10:1
@ -22,28 +28,28 @@ error[E0080]: it is undefined behavior to use this value
LL | / const REF_INTERIOR_MUT: &usize = {
LL | |
LL | |
LL | | static FOO: AtomicUsize = AtomicUsize::new(0);
... |
LL | |
LL | | static FOO: AtomicUsize = AtomicUsize::new(0);
LL | | unsafe { &*(&FOO as *const _ as *const usize) }
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:20:1
--> $DIR/const_refers_to_static2.rs:19:1
|
LL | / const READ_IMMUT: &usize = {
LL | |
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; 3 warnings emitted
error: aborting due to 2 previous errors; 2 warnings emitted
For more information about this error, try `rustc --explain E0080`.

View File

@ -9,33 +9,32 @@ extern crate static_cross_crate;
// Sneaky: reference to a mutable static.
// Allowing this would be a disaster for pattern matching, we could violate exhaustiveness checking!
const SLICE_MUT: &[u8; 1] = { //~ ERROR undefined behavior to use this value
//~^ WARN skipping const checks
//~| 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
//~^ WARN skipping const checks
//~| 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
//~^ WARN skipping const checks
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
//~^ WARN skipping const checks
unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
//~^ WARN skipping const checks
//~| WARN skipping const checks
//~| WARN [const_err]
//~^ WARN [const_err]
//~| NOTE constant accesses static
};

View File

@ -1,8 +1,13 @@
warning: skipping const checks
--> $DIR/const_refers_to_static_cross_crate.rs:14:15
--> $DIR/const_refers_to_static_cross_crate.rs:11:1
|
LL | unsafe { &static_cross_crate::ZERO }
| ^^^^^^^^^^^^^^^^^^^^^^^^
LL | / const SLICE_MUT: &[u8; 1] = {
LL | |
LL | |
LL | |
LL | | unsafe { &static_cross_crate::ZERO }
LL | | };
| |__^
error[E0080]: it is undefined behavior to use this value
--> $DIR/const_refers_to_static_cross_crate.rs:11:1
@ -10,24 +15,29 @@ error[E0080]: it is undefined behavior to use this value
LL | / const SLICE_MUT: &[u8; 1] = {
LL | |
LL | |
LL | | unsafe { &static_cross_crate::ZERO }
LL | |
LL | | unsafe { &static_cross_crate::ZERO }
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:44:9
--> $DIR/const_refers_to_static_cross_crate.rs:43:9
|
LL | SLICE_MUT => true,
| ^^^^^^^^^
warning: skipping const checks
--> $DIR/const_refers_to_static_cross_crate.rs:21:15
--> $DIR/const_refers_to_static_cross_crate.rs:18:1
|
LL | unsafe { &static_cross_crate::ZERO[0] }
| ^^^^^^^^^^^^^^^^^^^^^^^^
LL | / const U8_MUT: &u8 = {
LL | |
LL | |
LL | |
LL | | unsafe { &static_cross_crate::ZERO[0] }
LL | | };
| |__^
error[E0080]: it is undefined behavior to use this value
--> $DIR/const_refers_to_static_cross_crate.rs:18:1
@ -35,34 +45,39 @@ error[E0080]: it is undefined behavior to use this value
LL | / const U8_MUT: &u8 = {
LL | |
LL | |
LL | | unsafe { &static_cross_crate::ZERO[0] }
LL | |
LL | | unsafe { &static_cross_crate::ZERO[0] }
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:52:9
--> $DIR/const_refers_to_static_cross_crate.rs:51: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:1
|
LL | / const U8_MUT2: &u8 = {
LL | |
LL | | unsafe { &(*static_cross_crate::ZERO_REF)[0] }
LL | |
LL | |
LL | | };
| |__^
warning: any use of this value will cause an error
--> $DIR/const_refers_to_static_cross_crate.rs:29:14
|
LL | / const U8_MUT2: &u8 = {
LL | |
LL | | unsafe { &(*static_cross_crate::ZERO_REF)[0] }
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static
LL | |
LL | |
LL | |
LL | | };
| |__-
|
@ -73,35 +88,31 @@ LL | #[warn(const_err)]
| ^^^^^^^^^
error: could not evaluate constant pattern
--> $DIR/const_refers_to_static_cross_crate.rs:62:9
--> $DIR/const_refers_to_static_cross_crate.rs:61: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: skipping const checks
--> $DIR/const_refers_to_static_cross_crate.rs:35:77
|
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)
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:34:1
|
LL | / const U8_MUT3: &u8 = {
LL | |
LL | | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
LL | |
LL | |
LL | | };
| |__^
warning: any use of this value will cause an error
--> $DIR/const_refers_to_static_cross_crate.rs:36:51
|
LL | / const U8_MUT3: &u8 = {
LL | |
LL | | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
| | ^^^^^^^^^^^ constant accesses static
LL | |
LL | |
LL | |
LL | |
LL | | };
| |__-
|
@ -112,11 +123,11 @@ LL | #[warn(const_err)]
| ^^^^^^^^^
error: could not evaluate constant pattern
--> $DIR/const_refers_to_static_cross_crate.rs:69:9
--> $DIR/const_refers_to_static_cross_crate.rs:68:9
|
LL | U8_MUT3 => true,
| ^^^^^^^
error: aborting due to 6 previous errors; 7 warnings emitted
error: aborting due to 6 previous errors; 6 warnings emitted
For more information about this error, try `rustc --explain E0080`.

View File

@ -13,7 +13,6 @@ static TEST_OK: () = {
// Make sure we catch executing bad drop functions.
// The actual error is tested by the error-pattern above.
static TEST_BAD: () = {
static TEST_BAD: () = { //~ WARN skipping const checks
let _v: Vec<i32> = Vec::new();
//~^ WARN skipping const check
};

View File

@ -1,8 +1,10 @@
warning: skipping const checks
--> $DIR/drop.rs:17:9
--> $DIR/drop.rs:16:1
|
LL | let _v: Vec<i32> = Vec::new();
| ^^
LL | / static TEST_BAD: () = {
LL | | let _v: Vec<i32> = Vec::new();
LL | | };
| |__^
error[E0080]: could not evaluate static initializer
--> $SRC_DIR/libcore/ptr/mod.rs:LL:COL
@ -17,10 +19,10 @@ 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
error: aborting due to previous error; 1 warning emitted

View File

@ -6,11 +6,9 @@
fn main() {}
// Make sure we catch executing inline assembly.
static TEST_BAD: () = {
static TEST_BAD: () = { //~ WARN skipping const checks
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!
};

View File

@ -1,10 +1,13 @@
warning: skipping const checks
--> $DIR/inline_asm.rs:10:14
--> $DIR/inline_asm.rs:9:1
|
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)
LL | / static TEST_BAD: () = {
LL | | unsafe { llvm_asm!("xor %eax, %eax" ::: "eax"); }
LL | |
LL | |
LL | |
LL | | };
| |__^
error[E0080]: could not evaluate static initializer
--> $DIR/inline_asm.rs:10:14

View File

@ -1,4 +1,4 @@
// compile-flags: -Zunleash-the-miri-inside-of-you
// compile-flags: -Zunleash-the-miri-inside-of-you -Zdeduplicate-diagnostics
// normalize-stderr-test "alloc[0-9]+" -> "allocN"
#![deny(const_err)] // The `allow` variant is tested by `mutable_const2`.
@ -14,12 +14,11 @@ const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
//~^ WARN: skipping const checks
const MUTATING_BEHIND_RAW: () = { //~ NOTE
//~^ WARN skipping const checks
// Test that `MUTABLE_BEHIND_RAW` is actually immutable, by doing this at const time.
unsafe {
*MUTABLE_BEHIND_RAW = 99 //~ ERROR any use of this value will cause an error
//~^ NOTE: which is read-only
//~| WARN skipping const checks
//~| WARN skipping const checks
// FIXME would be good to match more of the error message here, but looks like we
// normalize *after* checking the annoations here.
}

View File

@ -1,25 +1,26 @@
warning: skipping const checks
--> $DIR/mutable_const.rs:13:38
--> $DIR/mutable_const.rs:13:1
|
LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
| ^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: skipping const checks
--> $DIR/mutable_const.rs:19:9
|
LL | *MUTABLE_BEHIND_RAW = 99
| ^^^^^^^^^^^^^^^^^^^^^^^^
warning: skipping const checks
--> $DIR/mutable_const.rs:19:9
|
LL | *MUTABLE_BEHIND_RAW = 99
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: any use of this value will cause an error
--> $DIR/mutable_const.rs:19:9
--> $DIR/mutable_const.rs:16:1
|
LL | / const MUTATING_BEHIND_RAW: () = {
LL | |
LL | | // Test that `MUTABLE_BEHIND_RAW` is actually immutable, by doing this at const time.
LL | | unsafe {
... |
LL | | }
LL | | };
| |__^
error: any use of this value will cause an error
--> $DIR/mutable_const.rs:20:9
|
LL | / const MUTATING_BEHIND_RAW: () = {
LL | |
LL | | // Test that `MUTABLE_BEHIND_RAW` is actually immutable, by doing this at const time.
LL | | unsafe {
LL | | *MUTABLE_BEHIND_RAW = 99
@ -35,5 +36,5 @@ note: the lint level is defined here
LL | #![deny(const_err)] // The `allow` variant is tested by `mutable_const2`.
| ^^^^^^^^^
error: aborting due to previous error; 3 warnings emitted
error: aborting due to previous error; 2 warnings emitted

View File

@ -1,8 +1,8 @@
warning: skipping const checks
--> $DIR/mutable_const2.rs:13:38
--> $DIR/mutable_const2.rs:13:1
|
LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
| ^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: 1 warning emitted

View File

@ -26,9 +26,8 @@ struct Meh {
unsafe impl Sync for Meh {}
static MEH: Meh = Meh {
static MEH: Meh = Meh { //~ WARN skipping const checks
x: &UnsafeCell::new(42),
//~^ WARN: skipping const checks
};
// this is fine for the same reason as `BAR`.

View File

@ -1,35 +1,37 @@
warning: skipping const checks
--> $DIR/mutable_references.rs:9:26
--> $DIR/mutable_references.rs:9:1
|
LL | static FOO: &&mut u32 = &&mut 42;
| ^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: skipping const checks
--> $DIR/mutable_references.rs:14:23
--> $DIR/mutable_references.rs:14:1
|
LL | static BAR: &mut () = &mut ();
| ^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: skipping const checks
--> $DIR/mutable_references.rs:20:28
--> $DIR/mutable_references.rs:20:1
|
LL | static BOO: &mut Foo<()> = &mut Foo(());
| ^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: skipping const checks
--> $DIR/mutable_references.rs:30:8
--> $DIR/mutable_references.rs:29:1
|
LL | x: &UnsafeCell::new(42),
| ^^^^^^^^^^^^^^^^^^^^
LL | / static MEH: Meh = Meh {
LL | | x: &UnsafeCell::new(42),
LL | | };
| |__^
warning: skipping const checks
--> $DIR/mutable_references.rs:35:27
--> $DIR/mutable_references.rs:34:1
|
LL | static OH_YES: &mut i32 = &mut 42;
| ^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0594]: cannot assign to `*OH_YES`, as `OH_YES` is an immutable static item
--> $DIR/mutable_references.rs:42:5
--> $DIR/mutable_references.rs:41:5
|
LL | *OH_YES = 99;
| ^^^^^^^^^^^^ cannot assign

View File

@ -18,8 +18,8 @@ struct Meh {
unsafe impl Sync for Meh {}
// the following will never be ok!
const MUH: Meh = Meh {
x: &UnsafeCell::new(42), //~ WARN: skipping const checks
const MUH: Meh = Meh { //~ WARN skipping const checks
x: &UnsafeCell::new(42),
};
fn main() {

View File

@ -1,8 +1,10 @@
warning: skipping const checks
--> $DIR/mutable_references_ice.rs:22:8
--> $DIR/mutable_references_ice.rs:21:1
|
LL | x: &UnsafeCell::new(42),
| ^^^^^^^^^^^^^^^^^^^^
LL | / const MUH: Meh = Meh {
LL | | x: &UnsafeCell::new(42),
LL | | };
| |__^
thread 'rustc' panicked at 'assertion failed: `(left != right)`
left: `Const`,

View File

@ -1,8 +1,8 @@
warning: skipping const checks
--> $DIR/non_const_fn.rs:9:16
--> $DIR/non_const_fn.rs:9:1
|
LL | static C: () = foo();
| ^^^^^
| ^^^^^^^^^^^^^^^^^^^^^
error[E0080]: could not evaluate static initializer
--> $DIR/non_const_fn.rs:9:16

View File

@ -1,8 +1,8 @@
warning: skipping const checks
--> $DIR/read_from_static.rs:5:27
--> $DIR/read_from_static.rs:5:1
|
LL | static OH_YES: &mut i32 = &mut 42;
| ^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: 1 warning emitted

View File

@ -15,10 +15,10 @@ const fn attributed() -> L {
std::intrinsics::caller_location()
}
const fn calling_attributed() -> L {
const fn calling_attributed() -> L { //~ WARN skipping const checks
// 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() {

View File

@ -1,8 +1,12 @@
warning: skipping const checks
--> $DIR/caller-location-fnptr-rt-ctfe-equiv.rs:21:5
--> $DIR/caller-location-fnptr-rt-ctfe-equiv.rs:18:1
|
LL | ptr()
| ^^^^^
LL | / const fn calling_attributed() -> L {
LL | | // We need `-Z unleash-the-miri-inside-of-you` for this as we don't have `const fn` pointers.
LL | | let ptr: fn() -> L = attributed;
LL | | ptr()
LL | | }
| |_^
warning: 1 warning emitted