-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
tests: Do not use -Z parse-only
, continue compilation to test recovery
#57379
Conversation
cc @nikomatsakis @nrc just in case |
This comment has been minimized.
This comment has been minimized.
9fa2f02
to
1f64f60
Compare
@@ -1543,7 +1543,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { | |||
|
|||
fn visit_item(&mut self, i: &'a ast::Item) { | |||
match i.node { | |||
ast::ItemKind::Static(..) | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this an intentional change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, test ui/parser/underscore_static.rs
uncovered an unnecessary feature-gate error after removing -Z parse-only
, so this change fixed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for taking the time to do this work!
I left a bunch of comments that are not review comments but rather a TODO list for things that we should clean up.
| | ||
LL | let isize x = 5; | ||
LL | let isize x = 5; //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `x` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For future reference, I prefer to have the error comments just outside of view of the stderr
files to make it easier to evaluate them in isolation :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, indeed.
That probably means one line below most of the time, like
let isize x = 5;
//~^ ERROR expected one of `:`, `;`, `=`, or `@`, found `x`
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's usually what I do. I only deviate from that when the line below would somehow still be part of the diagnostic, where I add as many ^
as necessary, but there's a point of diminishing returns.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when the line below would somehow still be part of the diagnostic, where I add as many ^ as necessary
We need //~v ERROR text text text
😄
--> $DIR/bind-struct-early-modifiers.rs:4:9 | ||
| | ||
LL | Foo { ref x: ref x } => {}, //~ ERROR expected `,` | ||
| ^^^^^^^^^^^^^^^^^^^^ missing field `x` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CC #57361.
| -------------------------- `foo` from trait | ||
... | ||
LL | impl Foo for u32 { //~ ERROR not all trait items implemented, missing: `foo` | ||
| ^^^^^^^^^^^^^^^^ missing `foo` in implementation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks suspect, I'm guessing we're currently not continuing with the function as is when we encounter pub
...
@@ -1,5 +1,5 @@ | |||
error[E0585]: found a documentation comment that doesn't document anything | |||
--> $DIR/doc-before-rbrace.rs:4:21 | |||
--> $DIR/doc-before-rbrace.rs:2:21 | |||
| | |||
LL | println!("Hi"); /// hi | |||
| ^^^^^^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing primary label.
| ^^^ expected (), found integer | ||
| | ||
= note: expected type `()` | ||
found type `{integer}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This entire error is unfortunate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LL | pub fn test<W, I: Iterator<Item=(), W> >() {} | ||
| ^ | ||
LL | pub fn test<W, I: Trait<Item=(), W> >() {} | ||
| ^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should suggest the appropriate place for the type parameter, like we do for lifetimes.
| ^^^^ expected char, found reference | ||
| | ||
= note: expected type `char` | ||
found type `&'static str` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should give the recovered value TyErr
(or even keep the char
type with a placeholder value) instead of TyStr
to avoid these.
@@ -1,10 +1,17 @@ | |||
error: expected identifier, found `0` | |||
--> $DIR/struct-field-numeric-shorthand.rs:6:19 | |||
--> $DIR/struct-field-numeric-shorthand.rs:4:19 | |||
| | |||
LL | let _ = Rgb { 0, 1, 2 }; //~ ERROR expected identifier, found `0` | |||
| --- ^ expected identifier | |||
| | | |||
| while parsing this struct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally this should provide appropriate syntax suggestion.
struct Foo { | ||
x: isize, | ||
} | ||
|
||
fn main() { | ||
match Foo { | ||
match Foo { //~ ERROR expected value, found struct `Foo` | ||
x: 3 //~ ERROR expected one of `=>`, `@`, `if`, or `|`, found `:` | ||
} { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ideally would be recovered to avoid the knock down errors, but that's unlikely to happen soon.
LL | fn f<T: Copy + ('a)>() {} //~ ERROR parenthesized lifetime bounds are not supported | ||
| ^ | ||
LL | fn f<'a, T: Trait + ('a)>() {} //~ ERROR parenthesized lifetime bounds are not supported | ||
| ^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should suggest the appropriate syntax.
@bors r+ |
📌 Commit 1f64f60 has been approved by |
tests: Do not use `-Z parse-only`, continue compilation to test recovery Make tests closer to reality! The next step will be enabling `-Z continue-parse-after-error` by default and looking at the regressions. A few instances of `-Z parse-only` are kept when it's appropriate, see e.g `ui/impl-trait/impl-trait-plus-priority.rs`, which tests mostly semantically wrong code and would generate too much useless noise if allowed to continue.
☀️ Test successful - status-appveyor, status-travis |
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
Make tests closer to reality!
The next step will be enabling
-Z continue-parse-after-error
by default and looking at the regressions.A few instances of
-Z parse-only
are kept when it's appropriate, see e.gui/impl-trait/impl-trait-plus-priority.rs
, which tests mostly semantically wrong code and would generate too much useless noise if allowed to continue.