1
Fork 0

Auto merge of #65759 - tmiasko:ui, r=petrochenkov

Validate error patterns and error annotation in ui tests when present

Previously, when compilation succeeded, neither error patterns nor error
annotation would be validated. Additionally, when compilation failed,
only error patterns would be validated if both error patterns and error
annotation were present.

Now both error patterns and error annotation are validated when present,
regardless of compilation status. Furthermore, for test that should run,
the error patterns are matched against executable output, which is what
some of tests already expect to happen, and when #65506 is merged even
more ui tests will.

Fixes #56277
This commit is contained in:
bors 2019-11-03 15:14:09 +00:00
commit b43a682259
33 changed files with 283 additions and 268 deletions

View file

@ -3,7 +3,7 @@
// ignore-stage1 // ignore-stage1
#![feature(plugin)] #![feature(plugin)]
#![plugin(lint_group_plugin_test)] #![plugin(lint_group_plugin_test)] //~ WARNING use of deprecated attribute
#![allow(dead_code)] #![allow(dead_code)]
fn lintme() { } //~ WARNING item is named 'lintme' fn lintme() { } //~ WARNING item is named 'lintme'

View file

@ -2,7 +2,7 @@
// aux-build:lint-plugin-test.rs // aux-build:lint-plugin-test.rs
// ignore-stage1 // ignore-stage1
#![feature(plugin)] #![feature(plugin)]
#![plugin(lint_plugin_test)] #![plugin(lint_plugin_test)] //~ WARNING use of deprecated attribute
#![allow(dead_code)] #![allow(dead_code)]
fn lintme() { } //~ WARNING item is named 'lintme' fn lintme() { } //~ WARNING item is named 'lintme'

View file

@ -17,5 +17,5 @@ impl MustUseDeprecated { //~ warning: use of deprecated item
fn main() { fn main() {
MustUseDeprecated::new(); //~ warning: use of deprecated item MustUseDeprecated::new(); //~ warning: use of deprecated item
//| warning: unused `MustUseDeprecated` that must be used //~| warning: unused `MustUseDeprecated` that must be used
} }

View file

@ -8,6 +8,5 @@
struct Foo<const NUM_BYTES: usize>(pub [u8; NUM_BYTES]); struct Foo<const NUM_BYTES: usize>(pub [u8; NUM_BYTES]);
fn main() { fn main() {
let _ = Foo::<3>([1, 2, 3]); //~ ERROR type annotations needed let _ = Foo::<3>([1, 2, 3]);
//~^ ERROR mismatched types
} }

View file

@ -12,5 +12,5 @@ impl<const L: usize> BitLen for [u8; L] {
} }
fn main() { fn main() {
let foo = <[u8; 2]>::BIT_LEN; let foo = <[u8; 2]>::BIT_LEN; //~ WARN unused variable
} }

View file

@ -3,8 +3,8 @@ error[E0601]: `main` function not found in crate `continue_after_missing_main`
| |
LL | / #![allow(dead_code)] LL | / #![allow(dead_code)]
LL | | LL | |
LL | | // error-pattern:`main` function not found in crate LL | | struct Tableau<'a, MP> {
LL | | LL | | provider: &'a MP,
... | ... |
LL | | LL | |
LL | | } LL | | }

View file

@ -1,6 +1,4 @@
#![allow(dead_code)] #![allow(dead_code)] //~ ERROR `main` function not found in crate
// error-pattern:`main` function not found in crate
struct Tableau<'a, MP> { struct Tableau<'a, MP> {
provider: &'a MP, provider: &'a MP,

View file

@ -3,15 +3,15 @@ error[E0601]: `main` function not found in crate `continue_after_missing_main`
| |
LL | / #![allow(dead_code)] LL | / #![allow(dead_code)]
LL | | LL | |
LL | | // error-pattern:`main` function not found in crate LL | | struct Tableau<'a, MP> {
LL | | LL | | provider: &'a MP,
... | ... |
LL | | LL | |
LL | | } LL | | }
| |_^ consider adding a `main` function to `$DIR/continue-after-missing-main.rs` | |_^ consider adding a `main` function to `$DIR/continue-after-missing-main.rs`
error[E0623]: lifetime mismatch error[E0623]: lifetime mismatch
--> $DIR/continue-after-missing-main.rs:30:56 --> $DIR/continue-after-missing-main.rs:28:56
| |
LL | tableau: Tableau<'data_provider, AdaptedMatrixProvider<'original_data, MP>>, LL | tableau: Tableau<'data_provider, AdaptedMatrixProvider<'original_data, MP>>,
| ------------------------------------------------------------------ these two types are declared with different lifetimes... | ------------------------------------------------------------------ these two types are declared with different lifetimes...

View file

@ -10,7 +10,7 @@ enum Void {}
#[derive(Debug)] #[derive(Debug)]
enum Foo { enum Foo {
Bar(u8), Bar(u8),
Void(Void), //~ WARN never used Void(Void), //~ WARN never constructed
} }
fn main() { fn main() {

View file

@ -38,6 +38,7 @@
// Exception, a gated and deprecated attribute. // Exception, a gated and deprecated attribute.
#![plugin_registrar] //~ WARN unused attribute #![plugin_registrar] //~ WARN unused attribute
//~| WARN use of deprecated attribute
// UNGATED WHITE-LISTED BUILT-IN ATTRIBUTES // UNGATED WHITE-LISTED BUILT-IN ATTRIBUTES
@ -90,7 +91,7 @@
#![crate_id = "10"] //~ WARN use of deprecated attribute #![crate_id = "10"] //~ WARN use of deprecated attribute
// FIXME(#44232) we should warn that this isn't used. // FIXME(#44232) we should warn that this isn't used.
#![feature(rust1)] #![feature(rust1)] //~ WARN no longer requires an attribute to enable
#![no_start] //~ WARN use of deprecated attribute #![no_start] //~ WARN use of deprecated attribute
@ -215,20 +216,25 @@ mod macro_export {
#[plugin_registrar] #[plugin_registrar]
//~^ WARN unused attribute //~^ WARN unused attribute
//~| WARN use of deprecated attribute
mod plugin_registrar { mod plugin_registrar {
mod inner { #![plugin_registrar] } mod inner { #![plugin_registrar] }
//~^ WARN unused attribute //~^ WARN unused attribute
//~| WARN use of deprecated attribute
// for `fn f()` case, see gated-plugin_registrar.rs // for `fn f()` case, see gated-plugin_registrar.rs
#[plugin_registrar] struct S; #[plugin_registrar] struct S;
//~^ WARN unused attribute //~^ WARN unused attribute
//~| WARN use of deprecated attribute
#[plugin_registrar] type T = S; #[plugin_registrar] type T = S;
//~^ WARN unused attribute //~^ WARN unused attribute
//~| WARN use of deprecated attribute
#[plugin_registrar] impl S { } #[plugin_registrar] impl S { }
//~^ WARN unused attribute //~^ WARN unused attribute
//~| WARN use of deprecated attribute
} }
#[main] #[main]

View file

@ -47,6 +47,6 @@ struct S1M<T> { val: S1k<S1k<T>> }
fn main() { fn main() {
let fat: Option<S1M<S1M<S1M<u32>>>> = None; let fat: Option<S1M<S1M<S1M<u32>>>> = None;
//~^ ERROR the type `S32<S1M<S1M<u32>>>` is too big for the current architecture //~^ ERROR is too big for the current architecture
} }

View file

@ -4,6 +4,8 @@ fn macros() {
macro_rules! foo{ macro_rules! foo{
($p:pat, $e:expr, $b:block) => {{ ($p:pat, $e:expr, $b:block) => {{
if let $p = $e $b if let $p = $e $b
//~^ WARN irrefutable if-let
//~| WARN irrefutable if-let
}} }}
} }
macro_rules! bar{ macro_rules! bar{
@ -12,10 +14,10 @@ fn macros() {
}} }}
} }
foo!(a, 1, { //~ WARN irrefutable if-let foo!(a, 1, {
println!("irrefutable pattern"); println!("irrefutable pattern");
}); });
bar!(a, 1, { //~ WARN irrefutable if-let bar!(a, 1, {
println!("irrefutable pattern"); println!("irrefutable pattern");
}); });
} }

View file

@ -23,7 +23,7 @@ LL | | });
| |_______- in this macro invocation | |_______- in this macro invocation
warning: irrefutable if-let pattern warning: irrefutable if-let pattern
--> $DIR/if-let.rs:24:5 --> $DIR/if-let.rs:26:5
| |
LL | / if let a = 1 { LL | / if let a = 1 {
LL | | println!("irrefutable pattern"); LL | | println!("irrefutable pattern");
@ -31,7 +31,7 @@ LL | | }
| |_____^ | |_____^
warning: irrefutable if-let pattern warning: irrefutable if-let pattern
--> $DIR/if-let.rs:28:5 --> $DIR/if-let.rs:30:5
| |
LL | / if let a = 1 { LL | / if let a = 1 {
LL | | println!("irrefutable pattern"); LL | | println!("irrefutable pattern");
@ -43,7 +43,7 @@ LL | | }
| |_____^ | |_____^
warning: irrefutable if-let pattern warning: irrefutable if-let pattern
--> $DIR/if-let.rs:38:12 --> $DIR/if-let.rs:40:12
| |
LL | } else if let a = 1 { LL | } else if let a = 1 {
| ____________^ | ____________^
@ -52,7 +52,7 @@ LL | | }
| |_____^ | |_____^
warning: irrefutable if-let pattern warning: irrefutable if-let pattern
--> $DIR/if-let.rs:44:12 --> $DIR/if-let.rs:46:12
| |
LL | } else if let a = 1 { LL | } else if let a = 1 {
| ____________^ | ____________^

View file

@ -15,7 +15,6 @@ fn bar<'a>() {
return; return;
let _x = foo::<Vec<_>>(Vec::<&'a u32>::new()); let _x = foo::<Vec<_>>(Vec::<&'a u32>::new());
//~^ ERROR the type `&'a u32` does not fulfill the required lifetime [E0477]
} }
fn main() {} fn main() {}

View file

@ -28,6 +28,8 @@ impl fmt::Debug for CheaterDetectionMechanism {
fn main() { fn main() {
let Social_exchange_psychology = CheaterDetectionMechanism {}; let Social_exchange_psychology = CheaterDetectionMechanism {};
//~^ WARN should have a snake case name such as //~^ WARN should have a snake case name
//~| NOTE #[warn(non_snake_case)]` implied by `#[warn(nonstandard_style)]
//~| NOTE people shouldn't have to change their usual style habits //~| NOTE people shouldn't have to change their usual style habits
//~| HELP convert the identifier to snake case
} }

View file

@ -2,7 +2,7 @@
#![warn(overflowing_literals)] #![warn(overflowing_literals)]
fn main() { fn main() {
let error = 255i8; //~WARNING literal out of range for i8 let error = 255i8; //~WARNING literal out of range for `i8`
let ok = 0b1000_0001; // should be ok -> i32 let ok = 0b1000_0001; // should be ok -> i32
let ok = 0b0111_1111i8; // should be ok -> 127i8 let ok = 0b0111_1111i8; // should be ok -> 127i8

View file

@ -1,7 +1,7 @@
// build-pass (FIXME(62277): could be check-pass?) // build-pass (FIXME(62277): could be check-pass?)
#![warn(unused_imports)] #![warn(unused_imports)]
use crate::foo::Bar; //~ WARNING first import use crate::foo::Bar;
mod foo { mod foo {
pub type Bar = i32; pub type Bar = i32;
@ -14,14 +14,14 @@ fn baz() -> Bar {
mod m1 { pub struct S {} } mod m1 { pub struct S {} }
mod m2 { pub struct S {} } mod m2 { pub struct S {} }
use m1::*; use m1::*; //~ WARNING unused import
use m2::*; use m2::*; //~ WARNING unused import
fn main() { fn main() {
use crate::foo::Bar; //~ WARNING redundant import use crate::foo::Bar; //~ WARNING imported redundantly
let _a: Bar = 3; let _a: Bar = 3;
baz(); baz();
use m1::S; //~ WARNING redundant import use m1::S;
let _s = S {}; let _s = S {};
} }

View file

@ -1,8 +1,18 @@
// build-pass (FIXME(62277): could be check-pass?) // build-pass (FIXME(62277): could be check-pass?)
#[doc] //~ WARN attribute must be of the form #[doc]
#[ignore()] //~ WARN attribute must be of the form //~^ WARN attribute must be of the form
#[inline = ""] //~ WARN attribute must be of the form //~| WARN this was previously accepted
#[link] //~ WARN attribute must be of the form #[ignore()]
#[link = ""] //~ WARN attribute must be of the form //~^ WARN attribute must be of the form
//~| WARN this was previously accepted
#[inline = ""]
//~^ WARN attribute must be of the form
//~| WARN this was previously accepted
#[link]
//~^WARN attribute must be of the form
//~| WARN this was previously accepted
#[link = ""]
//~^ WARN attribute must be of the form
//~| WARN this was previously accepted
fn main() {} fn main() {}

View file

@ -9,7 +9,7 @@ LL | #[doc]
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
warning: attribute must be of the form `#[ignore]` or `#[ignore = "reason"]` warning: attribute must be of the form `#[ignore]` or `#[ignore = "reason"]`
--> $DIR/malformed-regressions.rs:4:1 --> $DIR/malformed-regressions.rs:6:1
| |
LL | #[ignore()] LL | #[ignore()]
| ^^^^^^^^^^^ | ^^^^^^^^^^^
@ -18,7 +18,7 @@ LL | #[ignore()]
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
warning: attribute must be of the form `#[inline]` or `#[inline(always|never)]` warning: attribute must be of the form `#[inline]` or `#[inline(always|never)]`
--> $DIR/malformed-regressions.rs:5:1 --> $DIR/malformed-regressions.rs:9:1
| |
LL | #[inline = ""] LL | #[inline = ""]
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^
@ -27,7 +27,7 @@ LL | #[inline = ""]
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
warning: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ cfg = "...")]` warning: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ cfg = "...")]`
--> $DIR/malformed-regressions.rs:6:1 --> $DIR/malformed-regressions.rs:12:1
| |
LL | #[link] LL | #[link]
| ^^^^^^^ | ^^^^^^^
@ -36,7 +36,7 @@ LL | #[link]
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
warning: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ cfg = "...")]` warning: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ cfg = "...")]`
--> $DIR/malformed-regressions.rs:7:1 --> $DIR/malformed-regressions.rs:15:1
| |
LL | #[link = ""] LL | #[link = ""]
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^

View file

@ -1,7 +1,6 @@
// Test that a variable of type ! can coerce to another type. // Test that a variable of type ! can coerce to another type.
// run-fail // check-pass
// error-pattern:explicit
#![feature(never_type)] #![feature(never_type)]

View file

@ -1,7 +1,6 @@
// Test that we can use a ! for an argument of type ! // Test that we can use a ! for an argument of type !
// run-fail // check-pass
// error-pattern:wowzers!
#![feature(never_type)] #![feature(never_type)]
#![allow(unreachable_code)] #![allow(unreachable_code)]

View file

@ -1,7 +1,6 @@
// Test that we can explicitly cast ! to another type // Test that we can explicitly cast ! to another type
// run-fail // check-pass
// error-pattern:explicit
#![feature(never_type)] #![feature(never_type)]

View file

@ -1,7 +1,6 @@
// Test that we can use ! as an associated type. // Test that we can use ! as an associated type.
// run-fail // check-pass
// error-pattern:kapow!
#![feature(never_type)] #![feature(never_type)]

View file

@ -1,7 +1,6 @@
// Test that we can use ! as an argument to a trait impl. // Test that we can use ! as an argument to a trait impl.
// run-fail // check-pass
// error-pattern:oh no!
#![feature(never_type)] #![feature(never_type)]

View file

@ -32,14 +32,14 @@ fn main() {
match 10 { match 10 {
1..10 => {}, 1..10 => {},
8..=9 => {}, //~ WARNING multiple patterns covering the same range 8..=9 => {}, //~ WARNING unreachable pattern
_ => {}, _ => {},
} }
match 10 { match 10 {
5..7 => {}, 5..7 => {},
6 => {}, //~ WARNING unreachable pattern 6 => {}, //~ WARNING unreachable pattern
1..10 => {}, //~ WARNING multiple patterns covering the same range 1..10 => {},
9..=9 => {}, //~ WARNING unreachable pattern 9..=9 => {}, //~ WARNING unreachable pattern
6 => {}, //~ WARNING unreachable pattern 6 => {}, //~ WARNING unreachable pattern
_ => {}, _ => {},

View file

@ -13,7 +13,7 @@ mod variant_struct_region {
x: &'a i32, x: &'a i32,
} }
struct Bar<'a,'b> { struct Bar<'a,'b> {
f: &'a Foo<'b> //~ ERROR reference has a longer lifetime f: &'a Foo<'b>
} }
} }

View file

@ -13,7 +13,7 @@ mod rev_variant_struct_type {
x: fn(T) x: fn(T)
} }
struct Bar<'a,'b> { struct Bar<'a,'b> {
f: &'a Foo<&'b i32> //~ ERROR reference has a longer lifetime f: &'a Foo<&'b i32>
} }
} }

View file

@ -13,7 +13,7 @@ mod variant_struct_type {
x: T x: T
} }
struct Bar<'a,'b> { struct Bar<'a,'b> {
f: &'a Foo<&'b i32> //~ ERROR reference has a longer lifetime f: &'a Foo<&'b i32>
} }
} }

View file

@ -1,7 +1,6 @@
// run-pass // run-pass
// ignore-emscripten // ignore-emscripten
// min-llvm-version 7.0 // min-llvm-version 7.0
// error-pattern: panicked
// Test that the simd_f{min,max} intrinsics produce the correct results. // Test that the simd_f{min,max} intrinsics produce the correct results.

View file

@ -5,6 +5,8 @@ fn macros() {
macro_rules! foo{ macro_rules! foo{
($p:pat, $e:expr, $b:block) => {{ ($p:pat, $e:expr, $b:block) => {{
while let $p = $e $b while let $p = $e $b
//~^ WARN irrefutable while-let
//~| WARN irrefutable while-let
}} }}
} }
macro_rules! bar{ macro_rules! bar{
@ -13,10 +15,10 @@ fn macros() {
}} }}
} }
foo!(_a, 1, { //~ WARN irrefutable while-let foo!(_a, 1, {
println!("irrefutable pattern"); println!("irrefutable pattern");
}); });
bar!(_a, 1, { //~ WARN irrefutable while-let bar!(_a, 1, {
println!("irrefutable pattern"); println!("irrefutable pattern");
}); });
} }

View file

@ -23,7 +23,7 @@ LL | | });
| |_______- in this macro invocation | |_______- in this macro invocation
warning: irrefutable while-let pattern warning: irrefutable while-let pattern
--> $DIR/while-let.rs:25:5 --> $DIR/while-let.rs:27:5
| |
LL | / while let _a = 1 { LL | / while let _a = 1 {
LL | | println!("irrefutable pattern"); LL | | println!("irrefutable pattern");

View file

@ -3137,6 +3137,10 @@ impl<'test> TestCx<'test> {
self.fatal_proc_rec("test run succeeded!", &proc_res); self.fatal_proc_rec("test run succeeded!", &proc_res);
} }
} }
if !self.props.error_patterns.is_empty() {
// "// error-pattern" comments
self.check_error_patterns(&proc_res.stderr, &proc_res);
}
} }
debug!("run_ui_test: explicit={:?} config.compare_mode={:?} expected_errors={:?} \ debug!("run_ui_test: explicit={:?} config.compare_mode={:?} expected_errors={:?} \
@ -3144,16 +3148,15 @@ impl<'test> TestCx<'test> {
explicit, self.config.compare_mode, expected_errors, proc_res.status, explicit, self.config.compare_mode, expected_errors, proc_res.status,
self.props.error_patterns); self.props.error_patterns);
if !explicit && self.config.compare_mode.is_none() { if !explicit && self.config.compare_mode.is_none() {
if !proc_res.status.success() { if !self.should_run() && !self.props.error_patterns.is_empty() {
if !self.props.error_patterns.is_empty() {
// "// error-pattern" comments // "// error-pattern" comments
self.check_error_patterns(&proc_res.stderr, &proc_res); self.check_error_patterns(&proc_res.stderr, &proc_res);
} else { }
if !expected_errors.is_empty() {
// "//~ERROR comments" // "//~ERROR comments"
self.check_expected_errors(expected_errors, &proc_res); self.check_expected_errors(expected_errors, &proc_res);
} }
} }
}
if self.props.run_rustfix && self.config.compare_mode.is_none() { if self.props.run_rustfix && self.config.compare_mode.is_none() {
// And finally, compile the fixed code and make sure it both // And finally, compile the fixed code and make sure it both