Skip to content

Commit 6e9172f

Browse files
committed
Auto merge of #66932 - rust-lang:pass-check-runfail, r=petrochenkov
Revamp `// run-fail` wrt. `--pass` & support `// build-fail` & `// check-fail` Revamp how `// run-fail` tests work internally by having a separate `FailMode` that does not interfere with `PassMode`. In particular, `--pass check` will now have no effect on `// *-fail` tests. Moreover, new test annotations `// check-fail` (the default) and `// build-fail` are added. The latter is useful to distinguish post-monomorphization failures from pre-monomorphization failures as seen throughout the PR. Finally, ensure that non-`Ui` tests do not listen to `--pass check` such that the flag can be used with e.g. `./x.py test --pass check` directly. Fixes #66929. Fixes #67128. r? @petrochenkov cc @RalfJung @ninjasource
2 parents 5535c25 + 73e6a21 commit 6e9172f

File tree

174 files changed

+613
-406
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+613
-406
lines changed

src/test/ui/asm/issue-51431.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// build-fail
12
// ignore-emscripten no asm! support
23

34
#![feature(asm)]

src/test/ui/asm/issue-51431.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0669]: invalid value for constraint in inline assembly
2-
--> $DIR/issue-51431.rs:7:32
2+
--> $DIR/issue-51431.rs:8:32
33
|
44
LL | asm! {"mov $0,$1"::"0"("bx"),"1"(0x00)}
55
| ^^^^

src/test/ui/bad/bad-intrinsic-monomorphization.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// build-fail
2+
13
#![feature(repr_simd, platform_intrinsics, core_intrinsics)]
24
#![allow(warnings)]
35
#![crate_type = "rlib"]

src/test/ui/bad/bad-intrinsic-monomorphization.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
error[E0511]: invalid monomorphization of `cttz` intrinsic: expected basic integer type, found `Foo`
2-
--> $DIR/bad-intrinsic-monomorphization.rs:18:5
2+
--> $DIR/bad-intrinsic-monomorphization.rs:20:5
33
|
44
LL | intrinsics::cttz(v)
55
| ^^^^^^^^^^^^^^^^^^^
66

77
error[E0511]: invalid monomorphization of `fadd_fast` intrinsic: expected basic float type, found `Foo`
8-
--> $DIR/bad-intrinsic-monomorphization.rs:23:5
8+
--> $DIR/bad-intrinsic-monomorphization.rs:25:5
99
|
1010
LL | intrinsics::fadd_fast(a, b)
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error[E0511]: invalid monomorphization of `simd_add` intrinsic: expected SIMD input type, found non-SIMD `Foo`
14-
--> $DIR/bad-intrinsic-monomorphization.rs:28:5
14+
--> $DIR/bad-intrinsic-monomorphization.rs:30:5
1515
|
1616
LL | simd_add(a, b)
1717
| ^^^^^^^^^^^^^^

src/test/ui/cdylib-deps-must-be-static.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// build-fail
12
// error-pattern: crate `cdylib_dep` required to be available in rlib format, but was not found
23
// aux-build:cdylib-dep.rs
34
// ignore-musl

src/test/ui/commandline-argfile-badutf8.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Check to see if we can get parameters from an @argsfile file
22
//
3-
// build-fail
43
// compile-flags: --cfg cmdline_set @{{src-base}}/commandline-argfile-badutf8.args
54

65
#[cfg(not(cmdline_set))]

src/test/ui/commandline-argfile-missing.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Check to see if we can get parameters from an @argsfile file
22
//
33
// ignore-tidy-linelength
4-
// build-fail
54
// normalize-stderr-test: "os error \d+" -> "os error $$ERR"
65
// normalize-stderr-test: "commandline-argfile-missing.args:[^(]*" -> "commandline-argfile-missing.args: $$FILE_MISSING "
76
// compile-flags: --cfg cmdline_set @{{src-base}}/commandline-argfile-missing.args

src/test/ui/consts/array-literal-index-oob.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// build-fail
2+
13
fn main() {
24
&{[1, 2, 3][4]};
35
//~^ ERROR index out of bounds

src/test/ui/consts/array-literal-index-oob.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: index out of bounds: the len is 3 but the index is 4
2-
--> $DIR/array-literal-index-oob.rs:2:7
2+
--> $DIR/array-literal-index-oob.rs:4:7
33
|
44
LL | &{[1, 2, 3][4]};
55
| ^^^^^^^^^^^^
66
|
77
= note: `#[deny(const_err)]` on by default
88

99
error: reaching this expression at runtime will panic or abort
10-
--> $DIR/array-literal-index-oob.rs:2:7
10+
--> $DIR/array-literal-index-oob.rs:4:7
1111
|
1212
LL | &{[1, 2, 3][4]};
1313
| --^^^^^^^^^^^^-

src/test/ui/consts/assoc_const_generic_impl.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// build-fail
2+
13
#![warn(const_err)]
24

35
trait ZeroSized: Sized {

src/test/ui/consts/assoc_const_generic_impl.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
warning: any use of this value will cause an error
2-
--> $DIR/assoc_const_generic_impl.rs:9:34
2+
--> $DIR/assoc_const_generic_impl.rs:11:34
33
|
44
LL | const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::<Self>()];
55
| -----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
66
| |
77
| index out of bounds: the len is 1 but the index is 4
88
|
99
note: lint level defined here
10-
--> $DIR/assoc_const_generic_impl.rs:1:9
10+
--> $DIR/assoc_const_generic_impl.rs:3:9
1111
|
1212
LL | #![warn(const_err)]
1313
| ^^^^^^^^^
1414

1515
error: erroneous constant encountered
16-
--> $DIR/assoc_const_generic_impl.rs:11:18
16+
--> $DIR/assoc_const_generic_impl.rs:13:18
1717
|
1818
LL | let () = Self::I_AM_ZERO_SIZED;
1919
| ^^^^^^^^^^^^^^^^^^^^^

src/test/ui/consts/const-err.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// build-fail
12
// compile-flags: -Zforce-overflow-checks=on
23

34
#![allow(exceeding_bitshifts)]

src/test/ui/consts/const-err.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
warning: any use of this value will cause an error
2-
--> $DIR/const-err.rs:10:17
2+
--> $DIR/const-err.rs:11:17
33
|
44
LL | const FOO: u8 = [5u8][1];
55
| ----------------^^^^^^^^-
66
| |
77
| index out of bounds: the len is 1 but the index is 1
88
|
99
note: lint level defined here
10-
--> $DIR/const-err.rs:4:9
10+
--> $DIR/const-err.rs:5:9
1111
|
1212
LL | #![warn(const_err)]
1313
| ^^^^^^^^^
1414

1515
error[E0080]: erroneous constant used
16-
--> $DIR/const-err.rs:14:16
16+
--> $DIR/const-err.rs:15:16
1717
|
1818
LL | black_box((FOO, FOO));
1919
| ^^^ referenced constant has errors
2020

2121
error[E0080]: erroneous constant used
22-
--> $DIR/const-err.rs:14:21
22+
--> $DIR/const-err.rs:15:21
2323
|
2424
LL | black_box((FOO, FOO));
2525
| ^^^ referenced constant has errors

src/test/ui/consts/const-err2.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// needed because negating int::MIN will behave differently between
22
// optimized compilation and unoptimized compilation and thus would
33
// lead to different lints being emitted
4+
5+
// build-fail
46
// compile-flags: -O
57

68
#![feature(rustc_attrs)]

src/test/ui/consts/const-err2.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
error: this expression will panic at runtime
2-
--> $DIR/const-err2.rs:16:13
2+
--> $DIR/const-err2.rs:18:13
33
|
44
LL | let a = -std::i8::MIN;
55
| ^^^^^^^^^^^^^ attempt to negate with overflow
66
|
77
note: lint level defined here
8-
--> $DIR/const-err2.rs:9:9
8+
--> $DIR/const-err2.rs:11:9
99
|
1010
LL | #![deny(const_err)]
1111
| ^^^^^^^^^
1212

1313
error: this expression will panic at runtime
14-
--> $DIR/const-err2.rs:18:13
14+
--> $DIR/const-err2.rs:20:13
1515
|
1616
LL | let b = 200u8 + 200u8 + 200u8;
1717
| ^^^^^^^^^^^^^ attempt to add with overflow
1818

1919
error: this expression will panic at runtime
20-
--> $DIR/const-err2.rs:20:13
20+
--> $DIR/const-err2.rs:22:13
2121
|
2222
LL | let c = 200u8 * 4;
2323
| ^^^^^^^^^ attempt to multiply with overflow
2424

2525
error: this expression will panic at runtime
26-
--> $DIR/const-err2.rs:22:13
26+
--> $DIR/const-err2.rs:24:13
2727
|
2828
LL | let d = 42u8 - (42u8 + 1);
2929
| ^^^^^^^^^^^^^^^^^ attempt to subtract with overflow
3030

3131
error: index out of bounds: the len is 1 but the index is 1
32-
--> $DIR/const-err2.rs:24:14
32+
--> $DIR/const-err2.rs:26:14
3333
|
3434
LL | let _e = [5u8][1];
3535
| ^^^^^^^^

src/test/ui/consts/const-err3.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// needed because negating int::MIN will behave differently between
22
// optimized compilation and unoptimized compilation and thus would
33
// lead to different lints being emitted
4+
5+
// build-fail
46
// compile-flags: -C overflow-checks=on -O
57

68
#![feature(rustc_attrs)]

src/test/ui/consts/const-err3.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
error: attempt to negate with overflow
2-
--> $DIR/const-err3.rs:16:13
2+
--> $DIR/const-err3.rs:18:13
33
|
44
LL | let a = -std::i8::MIN;
55
| ^^^^^^^^^^^^^
66
|
77
note: lint level defined here
8-
--> $DIR/const-err3.rs:9:9
8+
--> $DIR/const-err3.rs:11:9
99
|
1010
LL | #![deny(const_err)]
1111
| ^^^^^^^^^
1212

1313
error: attempt to add with overflow
14-
--> $DIR/const-err3.rs:18:13
14+
--> $DIR/const-err3.rs:20:13
1515
|
1616
LL | let b = 200u8 + 200u8 + 200u8;
1717
| ^^^^^^^^^^^^^
1818

1919
error: attempt to multiply with overflow
20-
--> $DIR/const-err3.rs:20:13
20+
--> $DIR/const-err3.rs:22:13
2121
|
2222
LL | let c = 200u8 * 4;
2323
| ^^^^^^^^^
2424

2525
error: attempt to subtract with overflow
26-
--> $DIR/const-err3.rs:22:13
26+
--> $DIR/const-err3.rs:24:13
2727
|
2828
LL | let d = 42u8 - (42u8 + 1);
2929
| ^^^^^^^^^^^^^^^^^
3030

3131
error: index out of bounds: the len is 1 but the index is 1
32-
--> $DIR/const-err3.rs:24:14
32+
--> $DIR/const-err3.rs:26:14
3333
|
3434
LL | let _e = [5u8][1];
3535
| ^^^^^^^^

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

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// build-fail
2+
13
#![warn(const_err)]
24

35
const X: u32 = 5;

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
warning: any use of this value will cause an error
2-
--> $DIR/conditional_array_execution.rs:5:19
2+
--> $DIR/conditional_array_execution.rs:7:19
33
|
44
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
55
| ------------------^^^^^---------------------------
66
| |
77
| attempt to subtract with overflow
88
|
99
note: lint level defined here
10-
--> $DIR/conditional_array_execution.rs:1:9
10+
--> $DIR/conditional_array_execution.rs:3:9
1111
|
1212
LL | #![warn(const_err)]
1313
| ^^^^^^^^^
1414

1515
error[E0080]: evaluation of constant expression failed
16-
--> $DIR/conditional_array_execution.rs:9:20
16+
--> $DIR/conditional_array_execution.rs:11:20
1717
|
1818
LL | println!("{}", FOO);
1919
| ^^^ referenced constant has errors

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

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
// build-fail
12
// compile-flags: -Zunleash-the-miri-inside-of-you
3+
24
#![feature(const_fn)]
35
#![allow(const_err)]
46

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
warning: skipping const checks
2-
--> $DIR/const_fn_ptr_fail2.rs:9:5
2+
--> $DIR/const_fn_ptr_fail2.rs:11:5
33
|
44
LL | x(y)
55
| ^^^^
66

77
error[E0080]: evaluation of constant expression failed
8-
--> $DIR/const_fn_ptr_fail2.rs:16:5
8+
--> $DIR/const_fn_ptr_fail2.rs:18:5
99
|
1010
LL | assert_eq!(Y, 4);
1111
| ^^^^^^^^^^^-^^^^^
@@ -15,7 +15,7 @@ LL | assert_eq!(Y, 4);
1515
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
1616

1717
error[E0080]: evaluation of constant expression failed
18-
--> $DIR/const_fn_ptr_fail2.rs:18:5
18+
--> $DIR/const_fn_ptr_fail2.rs:20:5
1919
|
2020
LL | assert_eq!(Z, 4);
2121
| ^^^^^^^^^^^-^^^^^

src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// build-fail
2+
13
// Regression test for #66975
24
#![warn(const_err)]
35
#![feature(never_type)]

src/test/ui/consts/const-eval/index-out-of-bounds-never-type.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
warning: any use of this value will cause an error
2-
--> $DIR/index-out-of-bounds-never-type.rs:8:61
2+
--> $DIR/index-out-of-bounds-never-type.rs:10:61
33
|
44
LL | const VOID: ! = { let x = 0 * std::mem::size_of::<T>(); [][x] };
55
| --------------------------------------------------------^^^^^---
66
| |
77
| index out of bounds: the len is 0 but the index is 0
88
|
99
note: lint level defined here
10-
--> $DIR/index-out-of-bounds-never-type.rs:2:9
10+
--> $DIR/index-out-of-bounds-never-type.rs:4:9
1111
|
1212
LL | #![warn(const_err)]
1313
| ^^^^^^^^^
1414

1515
error: erroneous constant encountered
16-
--> $DIR/index-out-of-bounds-never-type.rs:13:13
16+
--> $DIR/index-out-of-bounds-never-type.rs:15:13
1717
|
1818
LL | let _ = PrintName::<T>::VOID;
1919
| ^^^^^^^^^^^^^^^^^^^^

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

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// build-fail
2+
13
fn main() {
24
let array = [std::env::args().len()];
35
array[1]; //~ ERROR index out of bounds

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: index out of bounds: the len is 1 but the index is 1
2-
--> $DIR/index_out_of_bounds_propagated.rs:3:5
2+
--> $DIR/index_out_of_bounds_propagated.rs:5:5
33
|
44
LL | array[1];
55
| ^^^^^^^^

src/test/ui/consts/const-eval/issue-43197.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// build-fail
2+
13
#![warn(const_err)]
24

35
const fn foo(x: u32) -> u32 {

src/test/ui/consts/const-eval/issue-43197.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
warning: any use of this value will cause an error
2-
--> $DIR/issue-43197.rs:8:20
2+
--> $DIR/issue-43197.rs:10:20
33
|
44
LL | const X: u32 = 0-1;
55
| ---------------^^^-
66
| |
77
| attempt to subtract with overflow
88
|
99
note: lint level defined here
10-
--> $DIR/issue-43197.rs:1:9
10+
--> $DIR/issue-43197.rs:3:9
1111
|
1212
LL | #![warn(const_err)]
1313
| ^^^^^^^^^
1414

1515
warning: any use of this value will cause an error
16-
--> $DIR/issue-43197.rs:10:24
16+
--> $DIR/issue-43197.rs:12:24
1717
|
1818
LL | const Y: u32 = foo(0-1);
1919
| -------------------^^^--
2020
| |
2121
| attempt to subtract with overflow
2222

2323
error[E0080]: evaluation of constant expression failed
24-
--> $DIR/issue-43197.rs:12:23
24+
--> $DIR/issue-43197.rs:14:23
2525
|
2626
LL | println!("{} {}", X, Y);
2727
| ^ referenced constant has errors
2828

2929
error[E0080]: evaluation of constant expression failed
30-
--> $DIR/issue-43197.rs:12:26
30+
--> $DIR/issue-43197.rs:14:26
3131
|
3232
LL | println!("{} {}", X, Y);
3333
| ^ referenced constant has errors

src/test/ui/consts/const-eval/issue-44578.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// build-fail
2+
13
#![allow(const_err)]
24

35
trait Foo {

0 commit comments

Comments
 (0)