Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revamp // run-fail wrt. --pass & support // build-fail & // check-fail #66932

Merged
merged 5 commits into from
Dec 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/test/ui/asm/issue-51431.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// build-fail
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how this is checked.
Looks like if the test starts failing at the "check" phase it will still pass with the // build-fail annotation.

Why are such annotations useful then?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, how the // build-fail test set was collected?
This can be done by introducing some kind of analogue of --pass check, but for failing tests, but I don't see it in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like if the test starts failing at the "check" phase it will still pass with the // build-fail annotation.

Ouch; Didn't think of that. To fix it, I think we'd need to compile the test twice, once as check-pass and once as build-fail.

Also, how the // build-fail test set was collected?

A set of tests started failing because they did not fail with --emit metadata.

This can be done by introducing some kind of analogue of --pass check, but for failing tests, but I don't see it in this PR.

Didn't feel necessary, but I can add --fail if you think it's useful.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but I can add --fail if you think it's useful.

No, no, just running twice would probably be preferable, the number of such tests is not too large, but we need to measure.
This is material for another PR anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I fixed it, but I had to refactor things to get rid of some implicit state to make it work. I think things should be less brittle & more understandable now. Let's see what the CI builder says. :)

// ignore-emscripten no asm! support

#![feature(asm)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/asm/issue-51431.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0669]: invalid value for constraint in inline assembly
--> $DIR/issue-51431.rs:7:32
--> $DIR/issue-51431.rs:8:32
|
LL | asm! {"mov $0,$1"::"0"("bx"),"1"(0x00)}
| ^^^^
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/bad/bad-intrinsic-monomorphization.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// build-fail

#![feature(repr_simd, platform_intrinsics, core_intrinsics)]
#![allow(warnings)]
#![crate_type = "rlib"]
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/bad/bad-intrinsic-monomorphization.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
error[E0511]: invalid monomorphization of `cttz` intrinsic: expected basic integer type, found `Foo`
--> $DIR/bad-intrinsic-monomorphization.rs:18:5
--> $DIR/bad-intrinsic-monomorphization.rs:20:5
|
LL | intrinsics::cttz(v)
| ^^^^^^^^^^^^^^^^^^^

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

error[E0511]: invalid monomorphization of `simd_add` intrinsic: expected SIMD input type, found non-SIMD `Foo`
--> $DIR/bad-intrinsic-monomorphization.rs:28:5
--> $DIR/bad-intrinsic-monomorphization.rs:30:5
|
LL | simd_add(a, b)
| ^^^^^^^^^^^^^^
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/cdylib-deps-must-be-static.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// build-fail
// error-pattern: crate `cdylib_dep` required to be available in rlib format, but was not found
// aux-build:cdylib-dep.rs
// ignore-musl
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/commandline-argfile-badutf8.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Check to see if we can get parameters from an @argsfile file
//
// build-fail
// compile-flags: --cfg cmdline_set @{{src-base}}/commandline-argfile-badutf8.args

#[cfg(not(cmdline_set))]
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/commandline-argfile-missing.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Check to see if we can get parameters from an @argsfile file
//
// ignore-tidy-linelength
// build-fail
// normalize-stderr-test: "os error \d+" -> "os error $$ERR"
// normalize-stderr-test: "commandline-argfile-missing.args:[^(]*" -> "commandline-argfile-missing.args: $$FILE_MISSING "
// compile-flags: --cfg cmdline_set @{{src-base}}/commandline-argfile-missing.args
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/consts/array-literal-index-oob.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// build-fail

fn main() {
&{[1, 2, 3][4]};
//~^ ERROR index out of bounds
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/consts/array-literal-index-oob.stderr
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
error: index out of bounds: the len is 3 but the index is 4
--> $DIR/array-literal-index-oob.rs:2:7
--> $DIR/array-literal-index-oob.rs:4:7
|
LL | &{[1, 2, 3][4]};
| ^^^^^^^^^^^^
|
= note: `#[deny(const_err)]` on by default

error: reaching this expression at runtime will panic or abort
--> $DIR/array-literal-index-oob.rs:2:7
--> $DIR/array-literal-index-oob.rs:4:7
|
LL | &{[1, 2, 3][4]};
| --^^^^^^^^^^^^-
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/consts/assoc_const_generic_impl.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// build-fail

#![warn(const_err)]

trait ZeroSized: Sized {
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/consts/assoc_const_generic_impl.stderr
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
warning: any use of this value will cause an error
--> $DIR/assoc_const_generic_impl.rs:9:34
--> $DIR/assoc_const_generic_impl.rs:11:34
|
LL | const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::<Self>()];
| -----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
| |
| index out of bounds: the len is 1 but the index is 4
|
note: lint level defined here
--> $DIR/assoc_const_generic_impl.rs:1:9
--> $DIR/assoc_const_generic_impl.rs:3:9
|
LL | #![warn(const_err)]
| ^^^^^^^^^

error: erroneous constant encountered
--> $DIR/assoc_const_generic_impl.rs:11:18
--> $DIR/assoc_const_generic_impl.rs:13:18
|
LL | let () = Self::I_AM_ZERO_SIZED;
| ^^^^^^^^^^^^^^^^^^^^^
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/consts/const-err.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// build-fail
// compile-flags: -Zforce-overflow-checks=on

#![allow(exceeding_bitshifts)]
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/consts/const-err.stderr
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
warning: any use of this value will cause an error
--> $DIR/const-err.rs:10:17
--> $DIR/const-err.rs:11:17
|
LL | const FOO: u8 = [5u8][1];
| ----------------^^^^^^^^-
| |
| index out of bounds: the len is 1 but the index is 1
|
note: lint level defined here
--> $DIR/const-err.rs:4:9
--> $DIR/const-err.rs:5:9
|
LL | #![warn(const_err)]
| ^^^^^^^^^

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

error[E0080]: erroneous constant used
--> $DIR/const-err.rs:14:21
--> $DIR/const-err.rs:15:21
|
LL | black_box((FOO, FOO));
| ^^^ referenced constant has errors
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/consts/const-err2.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// needed because negating int::MIN will behave differently between
// optimized compilation and unoptimized compilation and thus would
// lead to different lints being emitted

// build-fail
// compile-flags: -O

#![feature(rustc_attrs)]
Expand Down
12 changes: 6 additions & 6 deletions src/test/ui/consts/const-err2.stderr
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
error: this expression will panic at runtime
--> $DIR/const-err2.rs:16:13
--> $DIR/const-err2.rs:18:13
|
LL | let a = -std::i8::MIN;
| ^^^^^^^^^^^^^ attempt to negate with overflow
|
note: lint level defined here
--> $DIR/const-err2.rs:9:9
--> $DIR/const-err2.rs:11:9
|
LL | #![deny(const_err)]
| ^^^^^^^^^

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

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

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

error: index out of bounds: the len is 1 but the index is 1
--> $DIR/const-err2.rs:24:14
--> $DIR/const-err2.rs:26:14
|
LL | let _e = [5u8][1];
| ^^^^^^^^
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/consts/const-err3.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// needed because negating int::MIN will behave differently between
// optimized compilation and unoptimized compilation and thus would
// lead to different lints being emitted

// build-fail
// compile-flags: -C overflow-checks=on -O

#![feature(rustc_attrs)]
Expand Down
12 changes: 6 additions & 6 deletions src/test/ui/consts/const-err3.stderr
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
error: attempt to negate with overflow
--> $DIR/const-err3.rs:16:13
--> $DIR/const-err3.rs:18:13
|
LL | let a = -std::i8::MIN;
| ^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/const-err3.rs:9:9
--> $DIR/const-err3.rs:11:9
|
LL | #![deny(const_err)]
| ^^^^^^^^^

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

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

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

error: index out of bounds: the len is 1 but the index is 1
--> $DIR/const-err3.rs:24:14
--> $DIR/const-err3.rs:26:14
|
LL | let _e = [5u8][1];
| ^^^^^^^^
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/consts/const-eval/conditional_array_execution.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// build-fail

#![warn(const_err)]

const X: u32 = 5;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
warning: any use of this value will cause an error
--> $DIR/conditional_array_execution.rs:5:19
--> $DIR/conditional_array_execution.rs:7:19
|
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
| ------------------^^^^^---------------------------
| |
| attempt to subtract with overflow
|
note: lint level defined here
--> $DIR/conditional_array_execution.rs:1:9
--> $DIR/conditional_array_execution.rs:3:9
|
LL | #![warn(const_err)]
| ^^^^^^^^^

error[E0080]: evaluation of constant expression failed
--> $DIR/conditional_array_execution.rs:9:20
--> $DIR/conditional_array_execution.rs:11:20
|
LL | println!("{}", FOO);
| ^^^ referenced constant has errors
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// build-fail
// compile-flags: -Zunleash-the-miri-inside-of-you

#![feature(const_fn)]
#![allow(const_err)]

Expand Down
6 changes: 3 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,11 +1,11 @@
warning: skipping const checks
--> $DIR/const_fn_ptr_fail2.rs:9:5
--> $DIR/const_fn_ptr_fail2.rs:11:5
|
LL | x(y)
| ^^^^

error[E0080]: evaluation of constant expression failed
--> $DIR/const_fn_ptr_fail2.rs:16:5
--> $DIR/const_fn_ptr_fail2.rs:18:5
|
LL | assert_eq!(Y, 4);
| ^^^^^^^^^^^-^^^^^
Expand All @@ -15,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:18:5
--> $DIR/const_fn_ptr_fail2.rs:20:5
|
LL | assert_eq!(Z, 4);
| ^^^^^^^^^^^-^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// build-fail

// Regression test for #66975
#![warn(const_err)]
#![feature(never_type)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
warning: any use of this value will cause an error
--> $DIR/index-out-of-bounds-never-type.rs:8:61
--> $DIR/index-out-of-bounds-never-type.rs:10:61
|
LL | const VOID: ! = { let x = 0 * std::mem::size_of::<T>(); [][x] };
| --------------------------------------------------------^^^^^---
| |
| index out of bounds: the len is 0 but the index is 0
|
note: lint level defined here
--> $DIR/index-out-of-bounds-never-type.rs:2:9
--> $DIR/index-out-of-bounds-never-type.rs:4:9
|
LL | #![warn(const_err)]
| ^^^^^^^^^

error: erroneous constant encountered
--> $DIR/index-out-of-bounds-never-type.rs:13:13
--> $DIR/index-out-of-bounds-never-type.rs:15:13
|
LL | let _ = PrintName::<T>::VOID;
| ^^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// build-fail

fn main() {
let array = [std::env::args().len()];
array[1]; //~ ERROR index out of bounds
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: index out of bounds: the len is 1 but the index is 1
--> $DIR/index_out_of_bounds_propagated.rs:3:5
--> $DIR/index_out_of_bounds_propagated.rs:5:5
|
LL | array[1];
| ^^^^^^^^
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/consts/const-eval/issue-43197.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// build-fail

#![warn(const_err)]

const fn foo(x: u32) -> u32 {
Expand Down
10 changes: 5 additions & 5 deletions src/test/ui/consts/const-eval/issue-43197.stderr
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
warning: any use of this value will cause an error
--> $DIR/issue-43197.rs:8:20
--> $DIR/issue-43197.rs:10:20
|
LL | const X: u32 = 0-1;
| ---------------^^^-
| |
| attempt to subtract with overflow
|
note: lint level defined here
--> $DIR/issue-43197.rs:1:9
--> $DIR/issue-43197.rs:3:9
|
LL | #![warn(const_err)]
| ^^^^^^^^^

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

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

error[E0080]: evaluation of constant expression failed
--> $DIR/issue-43197.rs:12:26
--> $DIR/issue-43197.rs:14:26
|
LL | println!("{} {}", X, Y);
| ^ referenced constant has errors
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/consts/const-eval/issue-44578.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// build-fail

#![allow(const_err)]

trait Foo {
Expand Down
Loading