Skip to content

Commit c7eb916

Browse files
committed
deduplicate warnings
1 parent 9273962 commit c7eb916

35 files changed

+235
-227
lines changed

src/librustc_mir/transform/check_consts/validation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ impl Validator<'mir, 'tcx> {
253253
let is_unleashable = O::IS_SUPPORTED_IN_MIRI;
254254

255255
if is_unleashable && self.tcx.sess.opts.debugging_opts.unleash_the_miri_inside_of_you {
256-
self.tcx.sess.span_warn(span, "skipping const checks");
256+
self.tcx.sess.span_warn(self.tcx.def_span(self.def_id), "skipping const checks");
257257
return;
258258
}
259259

src/test/ui/consts/const-eval/const_fn_ptr.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ const fn double_const(x: usize) -> usize { x * 2 }
88
const X: fn(usize) -> usize = double;
99
const X_CONST: fn(usize) -> usize = double_const;
1010

11-
const fn bar(x: usize) -> usize {
12-
X(x) //~ WARNING skipping const checks
11+
const fn bar(x: usize) -> usize { //~ WARNING skipping const checks
12+
X(x)
1313
}
1414

15-
const fn bar_const(x: usize) -> usize {
16-
X_CONST(x) //~ WARNING skipping const checks
15+
const fn bar_const(x: usize) -> usize { //~ WARNING skipping const checks
16+
X_CONST(x)
1717
}
1818

19-
const fn foo(x: fn(usize) -> usize, y: usize) -> usize {
20-
x(y) //~ WARNING skipping const checks
19+
const fn foo(x: fn(usize) -> usize, y: usize) -> usize { //~ WARNING skipping const checks
20+
x(y)
2121
}
2222

2323
fn main() {
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
warning: skipping const checks
2-
--> $DIR/const_fn_ptr.rs:12:5
2+
--> $DIR/const_fn_ptr.rs:11:1
33
|
4-
LL | X(x)
5-
| ^^^^
4+
LL | / const fn bar(x: usize) -> usize {
5+
LL | | X(x)
6+
LL | | }
7+
| |_^
68

79
warning: skipping const checks
8-
--> $DIR/const_fn_ptr.rs:16:5
10+
--> $DIR/const_fn_ptr.rs:15:1
911
|
10-
LL | X_CONST(x)
11-
| ^^^^^^^^^^
12+
LL | / const fn bar_const(x: usize) -> usize {
13+
LL | | X_CONST(x)
14+
LL | | }
15+
| |_^
1216

1317
warning: skipping const checks
14-
--> $DIR/const_fn_ptr.rs:20:5
18+
--> $DIR/const_fn_ptr.rs:19:1
1519
|
16-
LL | x(y)
17-
| ^^^^
20+
LL | / const fn foo(x: fn(usize) -> usize, y: usize) -> usize {
21+
LL | | x(y)
22+
LL | | }
23+
| |_^
1824

1925
warning: 3 warnings emitted
2026

src/test/ui/consts/const-eval/const_fn_ptr_fail.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
fn double(x: usize) -> usize { x * 2 }
77
const X: fn(usize) -> usize = double;
88

9-
const fn bar(x: usize) -> usize {
9+
const fn bar(x: usize) -> usize { //~ WARNING skipping const checks
1010
X(x) // FIXME: this should error someday
11-
//~^ WARN: skipping const checks
1211
}
1312

1413
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
warning: skipping const checks
2-
--> $DIR/const_fn_ptr_fail.rs:10:5
2+
--> $DIR/const_fn_ptr_fail.rs:9:1
33
|
4-
LL | X(x) // FIXME: this should error someday
5-
| ^^^^
4+
LL | / const fn bar(x: usize) -> usize {
5+
LL | | X(x) // FIXME: this should error someday
6+
LL | | }
7+
| |_^
68

79
warning: 1 warning emitted
810

src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ fn double(x: usize) -> usize {
99
}
1010
const X: fn(usize) -> usize = double;
1111

12-
const fn bar(x: fn(usize) -> usize, y: usize) -> usize {
13-
x(y) //~ WARN skipping const checks
12+
const fn bar(x: fn(usize) -> usize, y: usize) -> usize { //~ WARN skipping const checks
13+
x(y)
1414
}
1515

1616
const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday

src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
warning: skipping const checks
2-
--> $DIR/const_fn_ptr_fail2.rs:13:5
2+
--> $DIR/const_fn_ptr_fail2.rs:12:1
33
|
4-
LL | x(y)
5-
| ^^^^
4+
LL | / const fn bar(x: fn(usize) -> usize, y: usize) -> usize {
5+
LL | | x(y)
6+
LL | | }
7+
| |_^
68

79
error[E0080]: evaluation of constant expression failed
810
--> $DIR/const_fn_ptr_fail2.rs:20:5

src/test/ui/consts/const-points-to-static.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
warning: skipping const checks
2-
--> $DIR/const-points-to-static.rs:5:20
2+
--> $DIR/const-points-to-static.rs:5:1
33
|
44
LL | const TEST: &u8 = &MY_STATIC;
5-
| ^^^^^^^^^
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66

77
error[E0080]: it is undefined behavior to use this value
88
--> $DIR/const-points-to-static.rs:5:1

src/test/ui/consts/const-prop-read-static-in-const.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
warning: skipping const checks
2-
--> $DIR/const-prop-read-static-in-const.rs:5:18
2+
--> $DIR/const-prop-read-static-in-const.rs:5:1
33
|
44
LL | const TEST: u8 = MY_STATIC;
5-
| ^^^^^^^^^
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
66

77
error: any use of this value will cause an error
88
--> $DIR/const-prop-read-static-in-const.rs:5:18

src/test/ui/consts/miri_unleashed/abi-mismatch.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
const extern "C" fn c_fn() {}
88

99
const fn call_rust_fn(my_fn: extern "Rust" fn()) {
10+
//~^ WARN skipping const checks
1011
my_fn();
11-
//~^ WARN skipping const checks
12-
//~| ERROR could not evaluate static initializer
12+
//~^ ERROR could not evaluate static initializer
1313
//~| NOTE calling a function with ABI C using caller ABI Rust
1414
//~| NOTE inside `call_rust_fn`
1515
}

src/test/ui/consts/miri_unleashed/abi-mismatch.stderr

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
11
warning: skipping const checks
2-
--> $DIR/abi-mismatch.rs:10:5
2+
--> $DIR/abi-mismatch.rs:9:1
33
|
4-
LL | my_fn();
5-
| ^^^^^^^
4+
LL | / const fn call_rust_fn(my_fn: extern "Rust" fn()) {
5+
LL | |
6+
LL | | my_fn();
7+
LL | |
8+
LL | |
9+
LL | |
10+
LL | | }
11+
| |_^
612

713
warning: skipping const checks
8-
--> $DIR/abi-mismatch.rs:17:40
14+
--> $DIR/abi-mismatch.rs:17:1
915
|
1016
LL | static VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern "C" fn()) });
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1218

1319
error[E0080]: could not evaluate static initializer
14-
--> $DIR/abi-mismatch.rs:10:5
20+
--> $DIR/abi-mismatch.rs:11:5
1521
|
1622
LL | my_fn();
1723
| ^^^^^^^
1824
| |
1925
| calling a function with ABI C using caller ABI Rust
20-
| inside `call_rust_fn` at $DIR/abi-mismatch.rs:10:5
26+
| inside `call_rust_fn` at $DIR/abi-mismatch.rs:11:5
2127
...
2228
LL | static VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern "C" fn()) });
2329
| --------------------------------------------------------------------- inside `VAL` at $DIR/abi-mismatch.rs:17:18

src/test/ui/consts/miri_unleashed/assoc_const.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
warning: skipping const checks
2-
--> $DIR/assoc_const.rs:14:20
2+
--> $DIR/assoc_const.rs:14:5
33
|
44
LL | const F: u32 = (U::X, 42).1;
5-
| ^^^^^^^^^^
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66

77
error[E0080]: erroneous constant used
88
--> $DIR/assoc_const.rs:31:13
+3-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
// compile-flags: -Zunleash-the-miri-inside-of-you
1+
// compile-flags: -Zunleash-the-miri-inside-of-you -Zdeduplicate-diagnostics
22
#![feature(box_syntax)]
33
#![allow(const_err)]
44

55
use std::mem::ManuallyDrop;
66

77
fn main() {}
88

9-
static TEST_BAD: &mut i32 = {
9+
static TEST_BAD: &mut i32 = { //~ WARN skipping const checks
1010
&mut *(box 0)
11-
//~^ WARN skipping const check
12-
//~| ERROR could not evaluate static initializer
11+
//~^ ERROR could not evaluate static initializer
1312
//~| NOTE heap allocations
14-
//~| WARN skipping const checks
15-
//~| WARN skipping const checks
16-
//~| WARN skipping const checks
1713
};
+8-22
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,19 @@
11
warning: skipping const checks
2-
--> $DIR/box.rs:10:11
3-
|
4-
LL | &mut *(box 0)
5-
| ^^^^^^^
6-
7-
warning: skipping const checks
8-
--> $DIR/box.rs:10:16
9-
|
10-
LL | &mut *(box 0)
11-
| ^
12-
13-
warning: skipping const checks
14-
--> $DIR/box.rs:10:5
2+
--> $DIR/box.rs:9:1
153
|
16-
LL | &mut *(box 0)
17-
| ^^^^^^^^^^^^^
18-
19-
warning: skipping const checks
20-
--> $DIR/box.rs:10:5
21-
|
22-
LL | &mut *(box 0)
23-
| ^^^^^^^^^^^^^
4+
LL | / static TEST_BAD: &mut i32 = {
5+
LL | | &mut *(box 0)
6+
LL | |
7+
LL | |
8+
LL | | };
9+
| |__^
2410

2511
error[E0080]: could not evaluate static initializer
2612
--> $DIR/box.rs:10:11
2713
|
2814
LL | &mut *(box 0)
2915
| ^^^^^^^ "heap allocations via `box` keyword" needs an rfc before being allowed inside constants
3016

31-
error: aborting due to previous error; 4 warnings emitted
17+
error: aborting due to previous error; 1 warning emitted
3218

3319
For more information about this error, try `rustc --explain E0080`.

src/test/ui/consts/miri_unleashed/const_refers_to_static.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// build-fail
2-
// compile-flags: -Zunleash-the-miri-inside-of-you
2+
// compile-flags: -Zunleash-the-miri-inside-of-you -Zdeduplicate-diagnostics
33
#![allow(const_err)]
44

55
use std::sync::atomic::AtomicUsize;
@@ -9,23 +9,20 @@ use std::sync::atomic::Ordering;
99
// when *using* the const.
1010

1111
const MUTATE_INTERIOR_MUT: usize = {
12+
//~^ WARN skipping const checks
1213
static FOO: AtomicUsize = AtomicUsize::new(0);
1314
FOO.fetch_add(1, Ordering::Relaxed)
14-
//~^ WARN skipping const checks
15-
//~| WARN skipping const checks
1615
};
1716

1817
const READ_INTERIOR_MUT: usize = {
18+
//~^ WARN skipping const checks
1919
static FOO: AtomicUsize = AtomicUsize::new(0);
2020
unsafe { *(&FOO as *const _ as *const usize) }
21-
//~^ WARN skipping const checks
22-
//~| WARN skipping const checks
2321
};
2422

2523
static mut MUTABLE: u32 = 0;
2624
const READ_MUT: u32 = unsafe { MUTABLE };
2725
//~^ WARN skipping const checks
28-
//~| WARN skipping const checks
2926

3027
fn main() {
3128
MUTATE_INTERIOR_MUT;
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,47 @@
11
warning: skipping const checks
2-
--> $DIR/const_refers_to_static.rs:13:5
2+
--> $DIR/const_refers_to_static.rs:11:1
33
|
4-
LL | FOO.fetch_add(1, Ordering::Relaxed)
5-
| ^^^
4+
LL | / const MUTATE_INTERIOR_MUT: usize = {
5+
LL | |
6+
LL | | static FOO: AtomicUsize = AtomicUsize::new(0);
7+
LL | | FOO.fetch_add(1, Ordering::Relaxed)
8+
LL | | };
9+
| |__^
610

711
warning: skipping const checks
8-
--> $DIR/const_refers_to_static.rs:13:5
12+
--> $DIR/const_refers_to_static.rs:17:1
913
|
10-
LL | FOO.fetch_add(1, Ordering::Relaxed)
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
LL | / const READ_INTERIOR_MUT: usize = {
15+
LL | |
16+
LL | | static FOO: AtomicUsize = AtomicUsize::new(0);
17+
LL | | unsafe { *(&FOO as *const _ as *const usize) }
18+
LL | | };
19+
| |__^
1220

1321
warning: skipping const checks
14-
--> $DIR/const_refers_to_static.rs:20:17
15-
|
16-
LL | unsafe { *(&FOO as *const _ as *const usize) }
17-
| ^^^
18-
19-
warning: skipping const checks
20-
--> $DIR/const_refers_to_static.rs:20:14
21-
|
22-
LL | unsafe { *(&FOO as *const _ as *const usize) }
23-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24-
25-
warning: skipping const checks
26-
--> $DIR/const_refers_to_static.rs:26:32
27-
|
28-
LL | const READ_MUT: u32 = unsafe { MUTABLE };
29-
| ^^^^^^^
30-
31-
warning: skipping const checks
32-
--> $DIR/const_refers_to_static.rs:26:32
22+
--> $DIR/const_refers_to_static.rs:24:1
3323
|
3424
LL | const READ_MUT: u32 = unsafe { MUTABLE };
35-
| ^^^^^^^
25+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3626

3727
error[E0080]: erroneous constant used
38-
--> $DIR/const_refers_to_static.rs:31:5
28+
--> $DIR/const_refers_to_static.rs:28:5
3929
|
4030
LL | MUTATE_INTERIOR_MUT;
4131
| ^^^^^^^^^^^^^^^^^^^ referenced constant has errors
4232

4333
error[E0080]: erroneous constant used
44-
--> $DIR/const_refers_to_static.rs:33:5
34+
--> $DIR/const_refers_to_static.rs:30:5
4535
|
4636
LL | READ_INTERIOR_MUT;
4737
| ^^^^^^^^^^^^^^^^^ referenced constant has errors
4838

4939
error[E0080]: erroneous constant used
50-
--> $DIR/const_refers_to_static.rs:35:5
40+
--> $DIR/const_refers_to_static.rs:32:5
5141
|
5242
LL | READ_MUT;
5343
| ^^^^^^^^ referenced constant has errors
5444

55-
error: aborting due to 3 previous errors; 6 warnings emitted
45+
error: aborting due to 3 previous errors; 3 warnings emitted
5646

5747
For more information about this error, try `rustc --explain E0080`.

0 commit comments

Comments
 (0)