Skip to content

Commit

Permalink
Auto merge of #59044 - petrochenkov:uiui, r=davidtwco
Browse files Browse the repository at this point in the history
Filter away test annotations from UI test output

If you worked with UI tests for some time you could notice one issue affecting their readability and also readability of diffs when the tests change.
Look at the output of this test.
```rust
fn main() {
    let 1 = 2; //~ ERROR refutable pattern in local binding
}
```
```
error[E0005]: refutable pattern in local binding: `-2147483648i32..=0i32` not covered
 --> src/main.rs:2:9
  |
2 |     let 1 = 2; //~ ERROR refutable pattern in local binding
  |         ^ pattern `-2147483648i32..=0i32` not covered

error: aborting due to previous error

For more information about this error, try `rustc --explain E0005`.
```
You can see that the "refutable pattern in local binding" is duplicated.
One instance is the actual error, and the second instance is the expected error annotation.
This annotation is useful in the test input, but in the output it clutters the text and makes it harder to see what text refers to actual errors and what is just comments, especially if there are many errors in a single test file.

@estebank [reported](#57379 (comment)) using the next trick to avoid the clutter
```rust
fn main() {
    let 1 = 2;
    //~^ ERROR refutable pattern in local binding
}
```
```
error[E0005]: refutable pattern in local binding: `-2147483648i32..=0i32` not covered
 --> src/main.rs:2:9
  |
2 |     let 1 = 2;
  |         ^ pattern `-2147483648i32..=0i32` not covered

error: aborting due to previous error

For more information about this error, try `rustc --explain E0005`.
```
, i.e. using `//~^` and placing the annotation one line below will remove the annotation from the output.

However, this doesn't always works (consider errors with multi-line spans), and shouldn't be necessary in general!
`compiletest` could automatically filter away its own annotations from the output instead.
This is exactly what this PR does.

r? @davidtwco
  • Loading branch information
bors committed Mar 11, 2019
2 parents e68bf8a + 07f99b9 commit 7486b9c
Show file tree
Hide file tree
Showing 2,940 changed files with 7,506 additions and 7,548 deletions.
@@ -1,7 +1,7 @@
error: `[v2]` cannot be resolved, ignoring it...
--> $DIR/deny-intra-link-resolution-failure.rs:3:6
|
LL | /// [v2] //~ ERROR
LL | /// [v2]
| ^^ cannot be resolved, ignoring
|
note: lint level defined here
Expand Down
8 changes: 4 additions & 4 deletions src/test/rustdoc-ui/deny-missing-docs-crate.stderr
@@ -1,21 +1,21 @@
error: missing documentation for crate
--> $DIR/deny-missing-docs-crate.rs:1:1
|
LL | / #![deny(missing_docs)] //~ ERROR
LL | / #![deny(missing_docs)]
LL | |
LL | | pub struct Foo; //~ ERROR
LL | | pub struct Foo;
| |_______________^
|
note: lint level defined here
--> $DIR/deny-missing-docs-crate.rs:1:9
|
LL | #![deny(missing_docs)] //~ ERROR
LL | #![deny(missing_docs)]
| ^^^^^^^^^^^^

error: missing documentation for a struct
--> $DIR/deny-missing-docs-crate.rs:3:1
|
LL | pub struct Foo; //~ ERROR
LL | pub struct Foo;
| ^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/deny-missing-docs-macro.stderr
@@ -1,7 +1,7 @@
error: missing documentation for macro
--> $DIR/deny-missing-docs-macro.rs:6:1
|
LL | macro_rules! foo { //~ ERROR
LL | macro_rules! foo {
| ^^^^^^^^^^^^^^^^
|
note: lint level defined here
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/intra-doc-alias-ice.stderr
@@ -1,7 +1,7 @@
error: `[TypeAlias::hoge]` cannot be resolved, ignoring it...
--> $DIR/intra-doc-alias-ice.rs:5:30
|
LL | /// [broken cross-reference](TypeAlias::hoge) //~ ERROR
LL | /// [broken cross-reference](TypeAlias::hoge)
| ^^^^^^^^^^^^^^^ cannot be resolved, ignoring
|
note: lint level defined here
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui-fulldeps/dropck_tarena_cycle_checked.stderr
Expand Up @@ -3,7 +3,7 @@ error[E0597]: `arena` does not live long enough
|
LL | f(&arena);
| ^^^^^ borrowed value does not live long enough
LL | } //~^ ERROR `arena` does not live long enough
LL | }
| - `arena` dropped here while still borrowed
|
= note: values in a scope are dropped in the opposite order they are created
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui-fulldeps/dropck_tarena_unsound_drop.stderr
Expand Up @@ -3,7 +3,7 @@ error[E0597]: `arena` does not live long enough
|
LL | f(&arena);
| ^^^^^ borrowed value does not live long enough
LL | } //~^ ERROR `arena` does not live long enough
LL | }
| - `arena` dropped here while still borrowed
|
= note: values in a scope are dropped in the opposite order they are created
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui-fulldeps/issue-15778-fail.stderr
@@ -1,7 +1,7 @@
error: crate is not marked with #![crate_okay]
--> $DIR/issue-15778-fail.rs:5:1
|
LL | / #![feature(plugin)] //~ ERROR crate is not marked with #![crate_okay]
LL | / #![feature(plugin)]
LL | | #![plugin(lint_for_crate)]
LL | |
LL | | pub fn main() { }
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui-fulldeps/lint-group-plugin-deny-cmdline.stderr
@@ -1,15 +1,15 @@
error: item is named 'lintme'
--> $DIR/lint-group-plugin-deny-cmdline.rs:8:1
|
LL | fn lintme() { } //~ ERROR item is named 'lintme'
LL | fn lintme() { }
| ^^^^^^^^^^^^^^^
|
= note: `-D test-lint` implied by `-D lint-me`

error: item is named 'pleaselintme'
--> $DIR/lint-group-plugin-deny-cmdline.rs:10:1
|
LL | fn pleaselintme() { } //~ ERROR item is named 'pleaselintme'
LL | fn pleaselintme() { }
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D please-lint` implied by `-D lint-me`
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui-fulldeps/lint-group-plugin.stderr
@@ -1,15 +1,15 @@
warning: item is named 'lintme'
--> $DIR/lint-group-plugin.rs:9:1
|
LL | fn lintme() { } //~ WARNING item is named 'lintme'
LL | fn lintme() { }
| ^^^^^^^^^^^^^^^
|
= note: #[warn(test_lint)] on by default

warning: item is named 'pleaselintme'
--> $DIR/lint-group-plugin.rs:10:1
|
LL | fn pleaselintme() { } //~ WARNING item is named 'pleaselintme'
LL | fn pleaselintme() { }
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(please_lint)] on by default
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui-fulldeps/lint-plugin-cmdline-load.stderr
@@ -1,7 +1,7 @@
warning: item is named 'lintme'
--> $DIR/lint-plugin-cmdline-load.rs:8:1
|
LL | fn lintme() { } //~ WARNING item is named 'lintme'
LL | fn lintme() { }
| ^^^^^^^^^^^^^^^
|
= note: #[warn(test_lint)] on by default
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui-fulldeps/lint-plugin-deny-attr.stderr
@@ -1,7 +1,7 @@
error: item is named 'lintme'
--> $DIR/lint-plugin-deny-attr.rs:8:1
|
LL | fn lintme() { } //~ ERROR item is named 'lintme'
LL | fn lintme() { }
| ^^^^^^^^^^^^^^^
|
note: lint level defined here
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui-fulldeps/lint-plugin-deny-cmdline.stderr
@@ -1,7 +1,7 @@
error: item is named 'lintme'
--> $DIR/lint-plugin-deny-cmdline.rs:8:1
|
LL | fn lintme() { } //~ ERROR item is named 'lintme'
LL | fn lintme() { }
| ^^^^^^^^^^^^^^^
|
= note: requested on the command line with `-D test-lint`
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui-fulldeps/lint-plugin-forbid-attrs.stderr
Expand Up @@ -10,7 +10,7 @@ LL | #[allow(test_lint)]
error: item is named 'lintme'
--> $DIR/lint-plugin-forbid-attrs.rs:8:1
|
LL | fn lintme() { } //~ ERROR item is named 'lintme'
LL | fn lintme() { }
| ^^^^^^^^^^^^^^^
|
note: lint level defined here
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui-fulldeps/lint-plugin-forbid-cmdline.stderr
@@ -1,15 +1,15 @@
error[E0453]: allow(test_lint) overruled by outer forbid(test_lint)
--> $DIR/lint-plugin-forbid-cmdline.rs:10:9
|
LL | #[allow(test_lint)] //~ ERROR allow(test_lint) overruled by outer forbid(test_lint)
LL | #[allow(test_lint)]
| ^^^^^^^^^ overruled by previous forbid
|
= note: `forbid` lint level was set on command line

error: item is named 'lintme'
--> $DIR/lint-plugin-forbid-cmdline.rs:8:1
|
LL | fn lintme() { } //~ ERROR item is named 'lintme'
LL | fn lintme() { }
| ^^^^^^^^^^^^^^^
|
= note: requested on the command line with `-F test-lint`
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui-fulldeps/lint-plugin.stderr
@@ -1,7 +1,7 @@
warning: item is named 'lintme'
--> $DIR/lint-plugin.rs:8:1
|
LL | fn lintme() { } //~ WARNING item is named 'lintme'
LL | fn lintme() { }
| ^^^^^^^^^^^^^^^
|
= note: #[warn(test_lint)] on by default
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui-fulldeps/lint_tool_test.stderr
Expand Up @@ -21,7 +21,7 @@ LL | #[allow(test_group)]
warning: unknown lint: `this_lint_does_not_exist`
--> $DIR/lint_tool_test.rs:27:8
|
LL | #[deny(this_lint_does_not_exist)] //~ WARNING unknown lint: `this_lint_does_not_exist`
LL | #[deny(this_lint_does_not_exist)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(unknown_lints)] on by default
Expand All @@ -35,7 +35,7 @@ LL | #![cfg_attr(foo, warn(test_lint))]
error: item is named 'lintme'
--> $DIR/lint_tool_test.rs:14:1
|
LL | fn lintme() { } //~ ERROR item is named 'lintme'
LL | fn lintme() { }
| ^^^^^^^^^^^^^^^
|
note: lint level defined here
Expand All @@ -48,7 +48,7 @@ LL | #![deny(clippy_group)]
error: item is named 'lintmetoo'
--> $DIR/lint_tool_test.rs:22:5
|
LL | fn lintmetoo() { } //~ ERROR item is named 'lintmetoo'
LL | fn lintmetoo() { }
| ^^^^^^^^^^^^^^^^^^
|
note: lint level defined here
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui-fulldeps/plugin-as-extern-crate.stderr
@@ -1,7 +1,7 @@
error: compiler plugin used as an ordinary library
--> $DIR/plugin-as-extern-crate.rs:10:1
|
LL | extern crate attr_plugin_test; //~ ERROR compiler plugin used as an ordinary library
LL | extern crate attr_plugin_test;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: lint level defined here
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/E0508.nll.stderr
@@ -1,7 +1,7 @@
error[E0508]: cannot move out of type `[NonCopy; 1]`, a non-copy array
--> $DIR/E0508.rs:5:18
|
LL | let _value = array[0]; //~ ERROR [E0508]
LL | let _value = array[0];
| ^^^^^^^^
| |
| cannot move out of here
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/E0508.stderr
@@ -1,7 +1,7 @@
error[E0508]: cannot move out of type `[NonCopy; 1]`, a non-copy array
--> $DIR/E0508.rs:5:18
|
LL | let _value = array[0]; //~ ERROR [E0508]
LL | let _value = array[0];
| ^^^^^^^^
| |
| cannot move out of here
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/E0583.stderr
@@ -1,7 +1,7 @@
error[E0583]: file not found for module `module_that_doesnt_exist`
--> $DIR/E0583.rs:1:5
|
LL | mod module_that_doesnt_exist; //~ ERROR E0583
LL | mod module_that_doesnt_exist;
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: name the file either module_that_doesnt_exist.rs or module_that_doesnt_exist/mod.rs inside the directory "$DIR"
Expand Down
12 changes: 6 additions & 6 deletions src/test/ui/E0642.stderr
@@ -1,31 +1,31 @@
error[E0642]: patterns aren't allowed in methods without bodies
--> $DIR/E0642.rs:5:12
|
LL | fn foo((x, y): (i32, i32)); //~ ERROR patterns aren't allowed in methods without bodies
LL | fn foo((x, y): (i32, i32));
| ^^^^^^
help: give this argument a name or use an underscore to ignore it
|
LL | fn foo(_: (i32, i32)); //~ ERROR patterns aren't allowed in methods without bodies
LL | fn foo(_: (i32, i32));
| ^

error[E0642]: patterns aren't allowed in methods without bodies
--> $DIR/E0642.rs:7:12
|
LL | fn bar((x, y): (i32, i32)) {} //~ ERROR patterns aren't allowed in methods without bodies
LL | fn bar((x, y): (i32, i32)) {}
| ^^^^^^
help: give this argument a name or use an underscore to ignore it
|
LL | fn bar(_: (i32, i32)) {} //~ ERROR patterns aren't allowed in methods without bodies
LL | fn bar(_: (i32, i32)) {}
| ^

error[E0642]: patterns aren't allowed in methods without bodies
--> $DIR/E0642.rs:9:15
|
LL | fn method(S { .. }: S) {} //~ ERROR patterns aren't allowed in methods without bodies
LL | fn method(S { .. }: S) {}
| ^^^^^^^^
help: give this argument a name or use an underscore to ignore it
|
LL | fn method(_: S) {} //~ ERROR patterns aren't allowed in methods without bodies
LL | fn method(_: S) {}
| ^

error: aborting due to 3 previous errors
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/E0662.stderr
@@ -1,7 +1,7 @@
error[E0662]: input operand constraint contains '='
--> $DIR/E0662.rs:6:12
|
LL | : "=test"("a") //~ ERROR E0662
LL | : "=test"("a")
| ^^^^^^^

error: aborting due to previous error
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/E0663.stderr
@@ -1,7 +1,7 @@
error[E0663]: input operand constraint contains '+'
--> $DIR/E0663.rs:6:12
|
LL | : "+test"("a") //~ ERROR E0663
LL | : "+test"("a")
| ^^^^^^^

error: aborting due to previous error
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/E0664.stderr
@@ -1,7 +1,7 @@
error[E0664]: clobber should not be surrounded by braces
--> $DIR/E0664.rs:7:12
|
LL | : "{eax}" //~ ERROR E0664
LL | : "{eax}"
| ^^^^^^^

error: aborting due to previous error
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/E0665.stderr
@@ -1,7 +1,7 @@
error[E0665]: `Default` cannot be derived for enums, only structs
--> $DIR/E0665.rs:1:10
|
LL | #[derive(Default)] //~ ERROR E0665
LL | #[derive(Default)]
| ^^^^^^^

error: aborting due to previous error
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/absolute-paths-in-nested-use-groups.stderr
@@ -1,19 +1,19 @@
error[E0433]: failed to resolve: crate root in paths can only be used in start position
--> $DIR/absolute-paths-in-nested-use-groups.rs:6:5
|
LL | ::bar, //~ ERROR crate root in paths can only be used in start position
LL | ::bar,
| ^ crate root in paths can only be used in start position

error[E0433]: failed to resolve: `super` in paths can only be used in start position
--> $DIR/absolute-paths-in-nested-use-groups.rs:7:5
|
LL | super::bar, //~ ERROR `super` in paths can only be used in start position
LL | super::bar,
| ^^^^^ `super` in paths can only be used in start position

error[E0433]: failed to resolve: `self` in paths can only be used in start position
--> $DIR/absolute-paths-in-nested-use-groups.rs:8:5
|
LL | self::bar, //~ ERROR `self` in paths can only be used in start position
LL | self::bar,
| ^^^^ `self` in paths can only be used in start position

error: aborting due to 3 previous errors
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/access-mode-in-closures.nll.stderr
@@ -1,7 +1,7 @@
error[E0507]: cannot move out of borrowed content
--> $DIR/access-mode-in-closures.rs:8:15
|
LL | match *s { S(v) => v } //~ ERROR cannot move out
LL | match *s { S(v) => v }
| ^^ - data moved here
| |
| cannot move out of borrowed content
Expand All @@ -10,7 +10,7 @@ LL | match *s { S(v) => v } //~ ERROR cannot move out
note: move occurs because `v` has type `std::vec::Vec<isize>`, which does not implement the `Copy` trait
--> $DIR/access-mode-in-closures.rs:8:22
|
LL | match *s { S(v) => v } //~ ERROR cannot move out
LL | match *s { S(v) => v }
| ^

error: aborting due to previous error
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/access-mode-in-closures.stderr
@@ -1,7 +1,7 @@
error[E0507]: cannot move out of borrowed content
--> $DIR/access-mode-in-closures.rs:8:15
|
LL | match *s { S(v) => v } //~ ERROR cannot move out
LL | match *s { S(v) => v }
| ^^ - hint: to prevent move, use `ref v` or `ref mut v`
| |
| cannot move out of borrowed content
Expand Down
@@ -1,13 +1,13 @@
error: return type should be `!`
--> $DIR/alloc-error-handler-bad-signature-1.rs:12:6
|
LL | ) -> () //~ ERROR return type should be `!`
LL | ) -> ()
| ^^

error: argument should be `Layout`
--> $DIR/alloc-error-handler-bad-signature-1.rs:11:11
|
LL | info: &Layout, //~ ERROR argument should be `Layout`
LL | info: &Layout,
| ^^^^^^^

error: aborting due to 2 previous errors
Expand Down
@@ -1,13 +1,13 @@
error: return type should be `!`
--> $DIR/alloc-error-handler-bad-signature-2.rs:12:3
|
LL | ) { //~ ERROR return type should be `!`
LL | ) {
| ^

error: argument should be `Layout`
--> $DIR/alloc-error-handler-bad-signature-2.rs:11:11
|
LL | info: Layout, //~ ERROR argument should be `Layout`
LL | info: Layout,
| ^^^^^^

error: aborting due to 2 previous errors
Expand Down

0 comments on commit 7486b9c

Please sign in to comment.