Skip to content

Commit

Permalink
deduplicate warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Apr 30, 2020
1 parent 9273962 commit c7eb916
Show file tree
Hide file tree
Showing 35 changed files with 235 additions and 227 deletions.
2 changes: 1 addition & 1 deletion src/librustc_mir/transform/check_consts/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
12 changes: 6 additions & 6 deletions src/test/ui/consts/const-eval/const_fn_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
24 changes: 15 additions & 9 deletions src/test/ui/consts/const-eval/const_fn_ptr.stderr
Original file line number Diff line number Diff line change
@@ -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

3 changes: 1 addition & 2 deletions src/test/ui/consts/const-eval/const_fn_ptr_fail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
8 changes: 5 additions & 3 deletions src/test/ui/consts/const-eval/const_fn_ptr_fail.stderr
Original file line number Diff line number Diff line change
@@ -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

4 changes: 2 additions & 2 deletions src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/consts/const-points-to-static.stderr
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/consts/const-prop-read-static-in-const.stderr
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/consts/miri_unleashed/abi-mismatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`
}
Expand Down
20 changes: 13 additions & 7 deletions src/test/ui/consts/miri_unleashed/abi-mismatch.stderr
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/consts/miri_unleashed/assoc_const.stderr
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 3 additions & 7 deletions src/test/ui/consts/miri_unleashed/box.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
// compile-flags: -Zunleash-the-miri-inside-of-you
// compile-flags: -Zunleash-the-miri-inside-of-you -Zdeduplicate-diagnostics
#![feature(box_syntax)]
#![allow(const_err)]

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
};
30 changes: 8 additions & 22 deletions src/test/ui/consts/miri_unleashed/box.stderr
Original file line number Diff line number Diff line change
@@ -1,33 +1,19 @@
warning: skipping const checks
--> $DIR/box.rs:10:11
|
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
--> $DIR/box.rs:9:1
|
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
|
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`.
9 changes: 3 additions & 6 deletions src/test/ui/consts/miri_unleashed/const_refers_to_static.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down
50 changes: 20 additions & 30 deletions src/test/ui/consts/miri_unleashed/const_refers_to_static.stderr
Original file line number Diff line number Diff line change
@@ -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
|
LL | const READ_MUT: u32 = unsafe { MUTABLE };
| ^^^^^^^

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 };
| ^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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`.
Loading

0 comments on commit c7eb916

Please sign in to comment.