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:
commit
b43a682259
33 changed files with 283 additions and 268 deletions
|
@ -3,7 +3,7 @@
|
|||
// ignore-stage1
|
||||
|
||||
#![feature(plugin)]
|
||||
#![plugin(lint_group_plugin_test)]
|
||||
#![plugin(lint_group_plugin_test)] //~ WARNING use of deprecated attribute
|
||||
#![allow(dead_code)]
|
||||
|
||||
fn lintme() { } //~ WARNING item is named 'lintme'
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// aux-build:lint-plugin-test.rs
|
||||
// ignore-stage1
|
||||
#![feature(plugin)]
|
||||
#![plugin(lint_plugin_test)]
|
||||
#![plugin(lint_plugin_test)] //~ WARNING use of deprecated attribute
|
||||
#![allow(dead_code)]
|
||||
|
||||
fn lintme() { } //~ WARNING item is named 'lintme'
|
||||
|
|
|
@ -17,5 +17,5 @@ impl MustUseDeprecated { //~ warning: use of deprecated item
|
|||
|
||||
fn main() {
|
||||
MustUseDeprecated::new(); //~ warning: use of deprecated item
|
||||
//| warning: unused `MustUseDeprecated` that must be used
|
||||
//~| warning: unused `MustUseDeprecated` that must be used
|
||||
}
|
||||
|
|
|
@ -8,6 +8,5 @@
|
|||
struct Foo<const NUM_BYTES: usize>(pub [u8; NUM_BYTES]);
|
||||
|
||||
fn main() {
|
||||
let _ = Foo::<3>([1, 2, 3]); //~ ERROR type annotations needed
|
||||
//~^ ERROR mismatched types
|
||||
let _ = Foo::<3>([1, 2, 3]);
|
||||
}
|
||||
|
|
|
@ -12,5 +12,5 @@ impl<const L: usize> BitLen for [u8; L] {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let foo = <[u8; 2]>::BIT_LEN;
|
||||
let foo = <[u8; 2]>::BIT_LEN; //~ WARN unused variable
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ error[E0601]: `main` function not found in crate `continue_after_missing_main`
|
|||
|
|
||||
LL | / #![allow(dead_code)]
|
||||
LL | |
|
||||
LL | | // error-pattern:`main` function not found in crate
|
||||
LL | |
|
||||
LL | | struct Tableau<'a, MP> {
|
||||
LL | | provider: &'a MP,
|
||||
... |
|
||||
LL | |
|
||||
LL | | }
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
#![allow(dead_code)]
|
||||
|
||||
// error-pattern:`main` function not found in crate
|
||||
#![allow(dead_code)] //~ ERROR `main` function not found in crate
|
||||
|
||||
struct Tableau<'a, MP> {
|
||||
provider: &'a MP,
|
||||
|
|
|
@ -3,15 +3,15 @@ error[E0601]: `main` function not found in crate `continue_after_missing_main`
|
|||
|
|
||||
LL | / #![allow(dead_code)]
|
||||
LL | |
|
||||
LL | | // error-pattern:`main` function not found in crate
|
||||
LL | |
|
||||
LL | | struct Tableau<'a, MP> {
|
||||
LL | | provider: &'a MP,
|
||||
... |
|
||||
LL | |
|
||||
LL | | }
|
||||
| |_^ consider adding a `main` function to `$DIR/continue-after-missing-main.rs`
|
||||
|
||||
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>>,
|
||||
| ------------------------------------------------------------------ these two types are declared with different lifetimes...
|
||||
|
|
|
@ -10,7 +10,7 @@ enum Void {}
|
|||
#[derive(Debug)]
|
||||
enum Foo {
|
||||
Bar(u8),
|
||||
Void(Void), //~ WARN never used
|
||||
Void(Void), //~ WARN never constructed
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
// Exception, a gated and deprecated attribute.
|
||||
|
||||
#![plugin_registrar] //~ WARN unused attribute
|
||||
//~| WARN use of deprecated attribute
|
||||
|
||||
// UNGATED WHITE-LISTED BUILT-IN ATTRIBUTES
|
||||
|
||||
|
@ -90,7 +91,7 @@
|
|||
#![crate_id = "10"] //~ WARN use of deprecated attribute
|
||||
|
||||
// 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
|
||||
|
||||
|
@ -215,20 +216,25 @@ mod macro_export {
|
|||
|
||||
#[plugin_registrar]
|
||||
//~^ WARN unused attribute
|
||||
//~| WARN use of deprecated attribute
|
||||
mod plugin_registrar {
|
||||
mod inner { #![plugin_registrar] }
|
||||
//~^ WARN unused attribute
|
||||
//~| WARN use of deprecated attribute
|
||||
|
||||
// for `fn f()` case, see gated-plugin_registrar.rs
|
||||
|
||||
#[plugin_registrar] struct S;
|
||||
//~^ WARN unused attribute
|
||||
//~| WARN use of deprecated attribute
|
||||
|
||||
#[plugin_registrar] type T = S;
|
||||
//~^ WARN unused attribute
|
||||
//~| WARN use of deprecated attribute
|
||||
|
||||
#[plugin_registrar] impl S { }
|
||||
//~^ WARN unused attribute
|
||||
//~| WARN use of deprecated attribute
|
||||
}
|
||||
|
||||
#[main]
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -47,6 +47,6 @@ struct S1M<T> { val: S1k<S1k<T>> }
|
|||
|
||||
fn main() {
|
||||
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
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ fn macros() {
|
|||
macro_rules! foo{
|
||||
($p:pat, $e:expr, $b:block) => {{
|
||||
if let $p = $e $b
|
||||
//~^ WARN irrefutable if-let
|
||||
//~| WARN irrefutable if-let
|
||||
}}
|
||||
}
|
||||
macro_rules! bar{
|
||||
|
@ -12,10 +14,10 @@ fn macros() {
|
|||
}}
|
||||
}
|
||||
|
||||
foo!(a, 1, { //~ WARN irrefutable if-let
|
||||
foo!(a, 1, {
|
||||
println!("irrefutable pattern");
|
||||
});
|
||||
bar!(a, 1, { //~ WARN irrefutable if-let
|
||||
bar!(a, 1, {
|
||||
println!("irrefutable pattern");
|
||||
});
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ LL | | });
|
|||
| |_______- in this macro invocation
|
||||
|
||||
warning: irrefutable if-let pattern
|
||||
--> $DIR/if-let.rs:24:5
|
||||
--> $DIR/if-let.rs:26:5
|
||||
|
|
||||
LL | / if let a = 1 {
|
||||
LL | | println!("irrefutable pattern");
|
||||
|
@ -31,7 +31,7 @@ LL | | }
|
|||
| |_____^
|
||||
|
||||
warning: irrefutable if-let pattern
|
||||
--> $DIR/if-let.rs:28:5
|
||||
--> $DIR/if-let.rs:30:5
|
||||
|
|
||||
LL | / if let a = 1 {
|
||||
LL | | println!("irrefutable pattern");
|
||||
|
@ -43,7 +43,7 @@ LL | | }
|
|||
| |_____^
|
||||
|
||||
warning: irrefutable if-let pattern
|
||||
--> $DIR/if-let.rs:38:12
|
||||
--> $DIR/if-let.rs:40:12
|
||||
|
|
||||
LL | } else if let a = 1 {
|
||||
| ____________^
|
||||
|
@ -52,7 +52,7 @@ LL | | }
|
|||
| |_____^
|
||||
|
||||
warning: irrefutable if-let pattern
|
||||
--> $DIR/if-let.rs:44:12
|
||||
--> $DIR/if-let.rs:46:12
|
||||
|
|
||||
LL | } else if let a = 1 {
|
||||
| ____________^
|
||||
|
|
|
@ -15,7 +15,6 @@ fn bar<'a>() {
|
|||
return;
|
||||
|
||||
let _x = foo::<Vec<_>>(Vec::<&'a u32>::new());
|
||||
//~^ ERROR the type `&'a u32` does not fulfill the required lifetime [E0477]
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -28,6 +28,8 @@ impl fmt::Debug for CheaterDetectionMechanism {
|
|||
|
||||
fn main() {
|
||||
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
|
||||
//~| HELP convert the identifier to snake case
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#![warn(overflowing_literals)]
|
||||
|
||||
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 = 0b0111_1111i8; // should be ok -> 127i8
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// build-pass (FIXME(62277): could be check-pass?)
|
||||
#![warn(unused_imports)]
|
||||
|
||||
use crate::foo::Bar; //~ WARNING first import
|
||||
use crate::foo::Bar;
|
||||
|
||||
mod foo {
|
||||
pub type Bar = i32;
|
||||
|
@ -14,14 +14,14 @@ fn baz() -> Bar {
|
|||
mod m1 { pub struct S {} }
|
||||
mod m2 { pub struct S {} }
|
||||
|
||||
use m1::*;
|
||||
use m2::*;
|
||||
use m1::*; //~ WARNING unused import
|
||||
use m2::*; //~ WARNING unused import
|
||||
|
||||
fn main() {
|
||||
use crate::foo::Bar; //~ WARNING redundant import
|
||||
use crate::foo::Bar; //~ WARNING imported redundantly
|
||||
let _a: Bar = 3;
|
||||
baz();
|
||||
|
||||
use m1::S; //~ WARNING redundant import
|
||||
use m1::S;
|
||||
let _s = S {};
|
||||
}
|
||||
|
|
|
@ -1,8 +1,18 @@
|
|||
// build-pass (FIXME(62277): could be check-pass?)
|
||||
|
||||
#[doc] //~ WARN attribute must be of the form
|
||||
#[ignore()] //~ WARN attribute must be of the form
|
||||
#[inline = ""] //~ WARN attribute must be of the form
|
||||
#[link] //~ WARN attribute must be of the form
|
||||
#[link = ""] //~ WARN attribute must be of the form
|
||||
#[doc]
|
||||
//~^ WARN attribute must be of the form
|
||||
//~| WARN this was previously accepted
|
||||
#[ignore()]
|
||||
//~^ 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() {}
|
||||
|
|
|
@ -9,7 +9,7 @@ LL | #[doc]
|
|||
= 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"]`
|
||||
--> $DIR/malformed-regressions.rs:4:1
|
||||
--> $DIR/malformed-regressions.rs:6:1
|
||||
|
|
||||
LL | #[ignore()]
|
||||
| ^^^^^^^^^^^
|
||||
|
@ -18,7 +18,7 @@ LL | #[ignore()]
|
|||
= 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)]`
|
||||
--> $DIR/malformed-regressions.rs:5:1
|
||||
--> $DIR/malformed-regressions.rs:9:1
|
||||
|
|
||||
LL | #[inline = ""]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
@ -27,7 +27,7 @@ LL | #[inline = ""]
|
|||
= 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 = "...")]`
|
||||
--> $DIR/malformed-regressions.rs:6:1
|
||||
--> $DIR/malformed-regressions.rs:12:1
|
||||
|
|
||||
LL | #[link]
|
||||
| ^^^^^^^
|
||||
|
@ -36,7 +36,7 @@ LL | #[link]
|
|||
= 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 = "...")]`
|
||||
--> $DIR/malformed-regressions.rs:7:1
|
||||
--> $DIR/malformed-regressions.rs:15:1
|
||||
|
|
||||
LL | #[link = ""]
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Test that a variable of type ! can coerce to another type.
|
||||
|
||||
// run-fail
|
||||
// error-pattern:explicit
|
||||
// check-pass
|
||||
|
||||
#![feature(never_type)]
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Test that we can use a ! for an argument of type !
|
||||
|
||||
// run-fail
|
||||
// error-pattern:wowzers!
|
||||
// check-pass
|
||||
|
||||
#![feature(never_type)]
|
||||
#![allow(unreachable_code)]
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Test that we can explicitly cast ! to another type
|
||||
|
||||
// run-fail
|
||||
// error-pattern:explicit
|
||||
// check-pass
|
||||
|
||||
#![feature(never_type)]
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Test that we can use ! as an associated type.
|
||||
|
||||
// run-fail
|
||||
// error-pattern:kapow!
|
||||
// check-pass
|
||||
|
||||
#![feature(never_type)]
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Test that we can use ! as an argument to a trait impl.
|
||||
|
||||
// run-fail
|
||||
// error-pattern:oh no!
|
||||
// check-pass
|
||||
|
||||
#![feature(never_type)]
|
||||
|
||||
|
|
|
@ -32,14 +32,14 @@ fn main() {
|
|||
|
||||
match 10 {
|
||||
1..10 => {},
|
||||
8..=9 => {}, //~ WARNING multiple patterns covering the same range
|
||||
8..=9 => {}, //~ WARNING unreachable pattern
|
||||
_ => {},
|
||||
}
|
||||
|
||||
match 10 {
|
||||
5..7 => {},
|
||||
6 => {}, //~ WARNING unreachable pattern
|
||||
1..10 => {}, //~ WARNING multiple patterns covering the same range
|
||||
1..10 => {},
|
||||
9..=9 => {}, //~ WARNING unreachable pattern
|
||||
6 => {}, //~ WARNING unreachable pattern
|
||||
_ => {},
|
||||
|
|
|
@ -13,7 +13,7 @@ mod variant_struct_region {
|
|||
x: &'a i32,
|
||||
}
|
||||
struct Bar<'a,'b> {
|
||||
f: &'a Foo<'b> //~ ERROR reference has a longer lifetime
|
||||
f: &'a Foo<'b>
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ mod rev_variant_struct_type {
|
|||
x: fn(T)
|
||||
}
|
||||
struct Bar<'a,'b> {
|
||||
f: &'a Foo<&'b i32> //~ ERROR reference has a longer lifetime
|
||||
f: &'a Foo<&'b i32>
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ mod variant_struct_type {
|
|||
x: T
|
||||
}
|
||||
struct Bar<'a,'b> {
|
||||
f: &'a Foo<&'b i32> //~ ERROR reference has a longer lifetime
|
||||
f: &'a Foo<&'b i32>
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// run-pass
|
||||
// ignore-emscripten
|
||||
// min-llvm-version 7.0
|
||||
// error-pattern: panicked
|
||||
|
||||
// Test that the simd_f{min,max} intrinsics produce the correct results.
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@ fn macros() {
|
|||
macro_rules! foo{
|
||||
($p:pat, $e:expr, $b:block) => {{
|
||||
while let $p = $e $b
|
||||
//~^ WARN irrefutable while-let
|
||||
//~| WARN irrefutable while-let
|
||||
}}
|
||||
}
|
||||
macro_rules! bar{
|
||||
|
@ -13,10 +15,10 @@ fn macros() {
|
|||
}}
|
||||
}
|
||||
|
||||
foo!(_a, 1, { //~ WARN irrefutable while-let
|
||||
foo!(_a, 1, {
|
||||
println!("irrefutable pattern");
|
||||
});
|
||||
bar!(_a, 1, { //~ WARN irrefutable while-let
|
||||
bar!(_a, 1, {
|
||||
println!("irrefutable pattern");
|
||||
});
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ LL | | });
|
|||
| |_______- in this macro invocation
|
||||
|
||||
warning: irrefutable while-let pattern
|
||||
--> $DIR/while-let.rs:25:5
|
||||
--> $DIR/while-let.rs:27:5
|
||||
|
|
||||
LL | / while let _a = 1 {
|
||||
LL | | println!("irrefutable pattern");
|
||||
|
|
|
@ -3137,6 +3137,10 @@ impl<'test> TestCx<'test> {
|
|||
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={:?} \
|
||||
|
@ -3144,14 +3148,13 @@ impl<'test> TestCx<'test> {
|
|||
explicit, self.config.compare_mode, expected_errors, proc_res.status,
|
||||
self.props.error_patterns);
|
||||
if !explicit && self.config.compare_mode.is_none() {
|
||||
if !proc_res.status.success() {
|
||||
if !self.props.error_patterns.is_empty() {
|
||||
// "// error-pattern" comments
|
||||
self.check_error_patterns(&proc_res.stderr, &proc_res);
|
||||
} else {
|
||||
// "//~ERROR comments"
|
||||
self.check_expected_errors(expected_errors, &proc_res);
|
||||
}
|
||||
if !self.should_run() && !self.props.error_patterns.is_empty() {
|
||||
// "// error-pattern" comments
|
||||
self.check_error_patterns(&proc_res.stderr, &proc_res);
|
||||
}
|
||||
if !expected_errors.is_empty() {
|
||||
// "//~ERROR comments"
|
||||
self.check_expected_errors(expected_errors, &proc_res);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue