From 670c84dde3ad25f113b00436066a65a0dfb808cd Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Tue, 17 Sep 2019 16:25:42 -0700 Subject: [PATCH] Fix tests broken by more consistent miri unleashed warnings --- .../ui/consts/const-eval/const_fn_ptr.stderr | 144 ++---------------- .../ui/consts/const-eval/const_fn_ptr_fail.rs | 1 + .../const-eval/const_fn_ptr_fail.stderr | 6 + .../consts/const-eval/const_fn_ptr_fail2.rs | 8 +- .../const-eval/const_fn_ptr_fail2.stderr | 50 +----- .../consts/miri_unleashed/assoc_const.stderr | 4 +- .../miri_unleashed/enum_discriminants.stderr | 48 ------ .../ui/consts/miri_unleashed/mutable_const.rs | 1 + .../miri_unleashed/mutable_const.stderr | 10 +- .../miri_unleashed/mutable_references.rs | 6 + .../miri_unleashed/mutable_references.stderr | 38 ++++- .../miri_unleashed/mutable_references_ice.rs | 2 +- .../mutable_references_ice.stderr | 6 + 13 files changed, 82 insertions(+), 242 deletions(-) create mode 100644 src/test/ui/consts/const-eval/const_fn_ptr_fail.stderr 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 41452ee59eb..2fbb1932244 100644 --- a/src/test/ui/consts/const-eval/const_fn_ptr.stderr +++ b/src/test/ui/consts/const-eval/const_fn_ptr.stderr @@ -1,146 +1,20 @@ warning: skipping const checks - --> $DIR/const_fn_ptr.rs:25:5 + --> $DIR/const_fn_ptr.rs:12:5 | -LL | assert_eq!(Y, 4); - | ^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) +LL | X(x) + | ^^^^ warning: skipping const checks - --> $DIR/const_fn_ptr.rs:25:5 + --> $DIR/const_fn_ptr.rs:16:5 | -LL | assert_eq!(Y, 4); - | ^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) +LL | X_const(x) + | ^^^^^^^^^^ warning: skipping const checks - --> $DIR/const_fn_ptr.rs:25:5 + --> $DIR/const_fn_ptr.rs:20:5 | -LL | assert_eq!(Y, 4); - | ^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/const_fn_ptr.rs:27:5 - | -LL | assert_eq!(y, 4); - | ^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/const_fn_ptr.rs:27:5 - | -LL | assert_eq!(y, 4); - | ^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/const_fn_ptr.rs:27:5 - | -LL | assert_eq!(y, 4); - | ^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/const_fn_ptr.rs:29:5 - | -LL | assert_eq!(y, 4); - | ^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/const_fn_ptr.rs:29:5 - | -LL | assert_eq!(y, 4); - | ^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/const_fn_ptr.rs:29:5 - | -LL | assert_eq!(y, 4); - | ^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/const_fn_ptr.rs:32:5 - | -LL | assert_eq!(Z, 4); - | ^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/const_fn_ptr.rs:32:5 - | -LL | assert_eq!(Z, 4); - | ^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/const_fn_ptr.rs:32:5 - | -LL | assert_eq!(Z, 4); - | ^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/const_fn_ptr.rs:34:5 - | -LL | assert_eq!(z, 4); - | ^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/const_fn_ptr.rs:34:5 - | -LL | assert_eq!(z, 4); - | ^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/const_fn_ptr.rs:34:5 - | -LL | assert_eq!(z, 4); - | ^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/const_fn_ptr.rs:36:5 - | -LL | assert_eq!(z, 4); - | ^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/const_fn_ptr.rs:36:5 - | -LL | assert_eq!(z, 4); - | ^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/const_fn_ptr.rs:36:5 - | -LL | assert_eq!(z, 4); - | ^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) +LL | x(y) + | ^^^^ warning: constant `X_const` should have an upper case name --> $DIR/const_fn_ptr.rs:9:7 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 14bd6558e7f..90d3cba07a5 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,6 +8,7 @@ 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 new file mode 100644 index 00000000000..e80f363ff8b --- /dev/null +++ b/src/test/ui/consts/const-eval/const_fn_ptr_fail.stderr @@ -0,0 +1,6 @@ +warning: skipping const checks + --> $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 74c60f9a2a5..b300119509c 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 @@ -6,7 +6,7 @@ fn double(x: usize) -> usize { x * 2 } const X: fn(usize) -> usize = double; const fn bar(x: fn(usize) -> usize, y: usize) -> usize { - x(y) + x(y) //~ WARN skipping const checks } const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday @@ -15,12 +15,6 @@ const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday fn main() { assert_eq!(Y, 4); //~^ ERROR evaluation of constant expression failed - //~^^ WARN skipping const checks - //~^^^ WARN skipping const checks - //~^^^^ WARN skipping const checks assert_eq!(Z, 4); //~^ ERROR evaluation of constant expression failed - //~^^ WARN skipping const checks - //~^^^ WARN skipping const checks - //~^^^^ WARN skipping const checks } 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 611cc5313c0..9d74d3b0bf2 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,50 +1,8 @@ warning: skipping const checks - --> $DIR/const_fn_ptr_fail2.rs:16:5 + --> $DIR/const_fn_ptr_fail2.rs:9:5 | -LL | assert_eq!(Y, 4); - | ^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/const_fn_ptr_fail2.rs:16:5 - | -LL | assert_eq!(Y, 4); - | ^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/const_fn_ptr_fail2.rs:16:5 - | -LL | assert_eq!(Y, 4); - | ^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/const_fn_ptr_fail2.rs:21:5 - | -LL | assert_eq!(Z, 4); - | ^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/const_fn_ptr_fail2.rs:21:5 - | -LL | assert_eq!(Z, 4); - | ^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/const_fn_ptr_fail2.rs:21:5 - | -LL | assert_eq!(Z, 4); - | ^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) +LL | x(y) + | ^^^^ error[E0080]: evaluation of constant expression failed --> $DIR/const_fn_ptr_fail2.rs:16:5 @@ -57,7 +15,7 @@ LL | assert_eq!(Y, 4); = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error[E0080]: evaluation of constant expression failed - --> $DIR/const_fn_ptr_fail2.rs:21:5 + --> $DIR/const_fn_ptr_fail2.rs:18:5 | LL | assert_eq!(Z, 4); | ^^^^^^^^^^^-^^^^^ diff --git a/src/test/ui/consts/miri_unleashed/assoc_const.stderr b/src/test/ui/consts/miri_unleashed/assoc_const.stderr index e814303923e..6a6cb343f17 100644 --- a/src/test/ui/consts/miri_unleashed/assoc_const.stderr +++ b/src/test/ui/consts/miri_unleashed/assoc_const.stderr @@ -1,8 +1,8 @@ warning: skipping const checks - --> $DIR/assoc_const.rs:12:31 + --> $DIR/assoc_const.rs:12:20 | LL | const F: u32 = (U::X, 42).1; - | ^ + | ^^^^^^^^^^ error[E0080]: erroneous constant used --> $DIR/assoc_const.rs:29:13 diff --git a/src/test/ui/consts/miri_unleashed/enum_discriminants.stderr b/src/test/ui/consts/miri_unleashed/enum_discriminants.stderr index 8ca81ad22b7..df366ba22e4 100644 --- a/src/test/ui/consts/miri_unleashed/enum_discriminants.stderr +++ b/src/test/ui/consts/miri_unleashed/enum_discriminants.stderr @@ -22,51 +22,3 @@ warning: skipping const checks LL | if let E1::V2 { .. } = (E1::V1 { f: true }) { | ^^^^^^^^^^^^^ -warning: skipping const checks - --> $DIR/enum_discriminants.rs:108:5 - | -LL | assert_eq!(OVERFLOW, 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/enum_discriminants.rs:108:5 - | -LL | assert_eq!(OVERFLOW, 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/enum_discriminants.rs:108:5 - | -LL | assert_eq!(OVERFLOW, 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/enum_discriminants.rs:109:5 - | -LL | assert_eq!(MORE_OVERFLOW, 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/enum_discriminants.rs:109:5 - | -LL | assert_eq!(MORE_OVERFLOW, 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/enum_discriminants.rs:109:5 - | -LL | assert_eq!(MORE_OVERFLOW, 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - diff --git a/src/test/ui/consts/miri_unleashed/mutable_const.rs b/src/test/ui/consts/miri_unleashed/mutable_const.rs index b476e04529a..44b40849467 100644 --- a/src/test/ui/consts/miri_unleashed/mutable_const.rs +++ b/src/test/ui/consts/miri_unleashed/mutable_const.rs @@ -7,6 +7,7 @@ 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: () = { // 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 507d4823a11..757f0ffb59f 100644 --- a/src/test/ui/consts/miri_unleashed/mutable_const.stderr +++ b/src/test/ui/consts/miri_unleashed/mutable_const.stderr @@ -1,11 +1,17 @@ warning: skipping const checks - --> $DIR/mutable_const.rs:14:9 + --> $DIR/mutable_const.rs:9:38 + | +LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _; + | ^^^^^^^^^^^^^^^^^^^^ + +warning: skipping const checks + --> $DIR/mutable_const.rs:15:9 | LL | *MUTABLE_BEHIND_RAW = 99 | ^^^^^^^^^^^^^^^^^^^^^^^^ error: any use of this value will cause an error - --> $DIR/mutable_const.rs:14:9 + --> $DIR/mutable_const.rs:15:9 | LL | / const MUTATING_BEHIND_RAW: () = { LL | | // Test that `MUTABLE_BEHIND_RAW` is actually immutable, by doing this at const time. diff --git a/src/test/ui/consts/miri_unleashed/mutable_references.rs b/src/test/ui/consts/miri_unleashed/mutable_references.rs index f81c78a8221..b2f3e0cdb28 100644 --- a/src/test/ui/consts/miri_unleashed/mutable_references.rs +++ b/src/test/ui/consts/miri_unleashed/mutable_references.rs @@ -6,12 +6,16 @@ use std::cell::UnsafeCell; // a test demonstrating what things we could allow with a smarter const qualification static FOO: &&mut u32 = &&mut 42; +//~^ WARN: skipping const checks +//~| WARN: skipping const checks static BAR: &mut () = &mut (); +//~^ WARN: skipping const checks struct Foo(T); static BOO: &mut Foo<()> = &mut Foo(()); +//~^ WARN: skipping const checks struct Meh { x: &'static UnsafeCell, @@ -21,9 +25,11 @@ unsafe impl Sync for Meh {} static MEH: Meh = Meh { x: &UnsafeCell::new(42), + //~^ WARN: skipping const checks }; static OH_YES: &mut i32 = &mut 42; +//~^ WARN: skipping const checks fn main() { unsafe { diff --git a/src/test/ui/consts/miri_unleashed/mutable_references.stderr b/src/test/ui/consts/miri_unleashed/mutable_references.stderr index 12840e00df9..ba01d155725 100644 --- a/src/test/ui/consts/miri_unleashed/mutable_references.stderr +++ b/src/test/ui/consts/miri_unleashed/mutable_references.stderr @@ -1,5 +1,41 @@ +warning: skipping const checks + --> $DIR/mutable_references.rs:8:26 + | +LL | static FOO: &&mut u32 = &&mut 42; + | ^^^^^^^ + +warning: skipping const checks + --> $DIR/mutable_references.rs:8:25 + | +LL | static FOO: &&mut u32 = &&mut 42; + | ^^^^^^^^ + +warning: skipping const checks + --> $DIR/mutable_references.rs:12:23 + | +LL | static BAR: &mut () = &mut (); + | ^^^^^^^ + +warning: skipping const checks + --> $DIR/mutable_references.rs:17:28 + | +LL | static BOO: &mut Foo<()> = &mut Foo(()); + | ^^^^^^^^^^^^ + +warning: skipping const checks + --> $DIR/mutable_references.rs:27:8 + | +LL | x: &UnsafeCell::new(42), + | ^^^^^^^^^^^^^^^^^^^^ + +warning: skipping const checks + --> $DIR/mutable_references.rs:31:27 + | +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:32:5 + --> $DIR/mutable_references.rs:38:5 | LL | *OH_YES = 99; | ^^^^^^^^^^^^ cannot assign 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 b051f6b59c4..635cad81c97 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), + x: &UnsafeCell::new(42), //~ WARN: skipping const checks }; 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 24c9de5ee2e..c148842bcbc 100644 --- a/src/test/ui/consts/miri_unleashed/mutable_references_ice.stderr +++ b/src/test/ui/consts/miri_unleashed/mutable_references_ice.stderr @@ -1,3 +1,9 @@ +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