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

tests: Do not use -Z parse-only, continue compilation to test recovery #57379

Merged
merged 1 commit into from
Jan 7, 2019

Conversation

petrochenkov
Copy link
Contributor

@petrochenkov petrochenkov commented Jan 6, 2019

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.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 6, 2019
@petrochenkov
Copy link
Contributor Author

cc @nikomatsakis @nrc just in case

@rust-highfive

This comment has been minimized.

@@ -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(..) |
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@estebank estebank left a 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`
Copy link
Contributor

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 :)

Copy link
Contributor Author

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`

?

Copy link
Contributor

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.

Copy link
Contributor Author

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`
Copy link
Contributor

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
Copy link
Contributor

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
| ^^^^^^
Copy link
Contributor

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}`
Copy link
Contributor

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.

Copy link
Contributor

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> >() {}
| ^
Copy link
Contributor

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`
Copy link
Contributor

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
Copy link
Contributor

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 `:`
} {
Copy link
Contributor

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
| ^
Copy link
Contributor

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.

@estebank
Copy link
Contributor

estebank commented Jan 6, 2019

@bors r+

@bors
Copy link
Contributor

bors commented Jan 6, 2019

📌 Commit 1f64f60 has been approved by estebank

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 6, 2019
@bors
Copy link
Contributor

bors commented Jan 7, 2019

⌛ Testing commit 1f64f60 with merge 789a15a...

bors added a commit that referenced this pull request Jan 7, 2019
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.
@bors
Copy link
Contributor

bors commented Jan 7, 2019

☀️ Test successful - status-appveyor, status-travis
Approved by: estebank
Pushing 789a15a to master...

@bors bors merged commit 1f64f60 into rust-lang:master Jan 7, 2019
bors added a commit that referenced this pull request Mar 11, 2019
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
@petrochenkov petrochenkov deleted the parsrecov branch June 5, 2019 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants