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

Modify some parser diagnostics to continue evaluating beyond the parser #57540

Merged
merged 15 commits into from
Jan 15, 2019

Conversation

estebank
Copy link
Contributor

Continue evaluating further errors after parser errors on:

  • trailing type argument attribute
  • lifetime in incorrect location
  • incorrect binary literal
  • missing for in impl Trait for Foo
  • type argument in where clause
  • incorrect float literal
  • incorrect .. in pattern
  • associated types
  • incorrect discriminator value variant error

and others. All of these were found by making continue-parse-after-error true by default to identify errors that would need few changes. There are now only a handful of errors that have any change with continue-parse-after-error enabled.

These changes make it so rust won't stop evaluation after finishing parsing, enabling type checking errors to be displayed on the existing code without having to fix the parse errors.

Each commit has an individual diagnostic change with their corresponding tests.

CC #48724.

@rust-highfive
Copy link
Collaborator

r? @pnkfelix

(rust_highfive has picked a reviewer for you, use r? to override)

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

Is it possible to flip the default and introduce span_err_irrecoverable or something for errors that stop compilation?
This way it will be obvious what cases still need fixing.
(Also replacing span_err(span, msg) with struct_span_err(span, msg).emit() will be unnecessary.)

@petrochenkov
Copy link
Contributor

In the previous PRs (#57379, #57272 etc) I adjusted tests so they don't report errors that are not related to the point of the test and are not consequences of recovery (e.g. unresolved names, missing main).
I'll go through the tests and mark the errors that I think are "off-topic" and are better avoided.

src/test/ui/parser/issue-14303-fncall.stderr Outdated Show resolved Hide resolved
src/test/ui/parser/issue-14303-path.stderr Outdated Show resolved Hide resolved
src/test/ui/parser/issue-1802-2.stderr Outdated Show resolved Hide resolved
src/test/ui/parser/pat-tuple-2.stderr Outdated Show resolved Hide resolved
src/test/ui/parser/pat-tuple-3.stderr Outdated Show resolved Hide resolved
src/test/ui/parser/tag-variant-disr-non-nullary.stderr Outdated Show resolved Hide resolved
@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 12, 2019
@estebank
Copy link
Contributor Author

estebank commented Jan 13, 2019

r? @petrochenkov

Is it possible to flip the default and introduce span_err_irrecoverable or something for errors that stop compilation?
This way it will be obvious what cases still need fixing.
(Also replacing span_err(span, msg) with struct_span_err(span, msg).emit() will be unnecessary.)

Makes sense.


EDIT: I just realized that we still need to use struct_span_err directly in most places, as we're also adding suggestions/labels. I won't pursue changing span_err as it will have little improvement. The only thing that would be useful is maybe renaming span_err to span_err_irrecoverable as proposed.


In the previous PRs (#57379#57272 etc) I adjusted tests so they don't report errors that are not related to the point of the test and are not consequences of recovery (e.g. unresolved names, missing main).

I'd like to have some regression tests to make sure that the parser doesn't suddenly start blocking further processing again by accident. Do you think it makes sense to have a few marked explicitly that way?

|
LL | where Q: for <#[rustc_1] 'a, 'b, #[oops]> Fn(RefIntPair<'a,'b>) -> &'b u32
| ^^^^^^^
LL | where Q: for <#[allow(unused)] 'a, 'b, #[oops]> Fn(RefIntPair<'a,'b>) -> &'b u32
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I didn't know we could have attributes annotating lifetimes, 2) we have no attributes to annotate lifetimes or type arguments at this time :)

@estebank estebank added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 13, 2019
@petrochenkov
Copy link
Contributor

The only thing that would be useful is maybe renaming span_err to span_err_irrecoverable as proposed.

Hmm, looks like that would require touching a lot of other code because behavior of span_err changes dynamically from irrecoverable to recoverable.
Ok, let is stay as is for now.

I'd like to have some regression tests to make sure that the parser doesn't suddenly start blocking further processing again by accident. Do you think it makes sense to have a few marked explicitly that way?

Yes, it would be good to have a single dedicated test rather than "accidental" errors here and there.

@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Jan 13, 2019

📌 Commit 28ea03e has been approved by petrochenkov

@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 13, 2019
Centril added a commit to Centril/rust that referenced this pull request Jan 14, 2019
Modify some parser diagnostics to continue evaluating beyond the parser

Continue evaluating further errors after parser errors on:
 - trailing type argument attribute
 - lifetime in incorrect location
 - incorrect binary literal
 - missing `for` in `impl Trait for Foo`
 - type argument in `where` clause
 - incorrect float literal
 - incorrect `..` in pattern
 - associated types
 - incorrect discriminator value variant error

and others. All of these were found by making `continue-parse-after-error` `true` by default to identify errors that would need few changes. There are now only a handful of errors that have any change with `continue-parse-after-error` enabled.

These changes make it so `rust` _won't_ stop evaluation after finishing parsing, enabling type checking errors to be displayed on the existing code without having to fix the parse errors.

Each commit has an individual diagnostic change with their corresponding tests.

CC rust-lang#48724.
Centril added a commit to Centril/rust that referenced this pull request Jan 14, 2019
Modify some parser diagnostics to continue evaluating beyond the parser

Continue evaluating further errors after parser errors on:
 - trailing type argument attribute
 - lifetime in incorrect location
 - incorrect binary literal
 - missing `for` in `impl Trait for Foo`
 - type argument in `where` clause
 - incorrect float literal
 - incorrect `..` in pattern
 - associated types
 - incorrect discriminator value variant error

and others. All of these were found by making `continue-parse-after-error` `true` by default to identify errors that would need few changes. There are now only a handful of errors that have any change with `continue-parse-after-error` enabled.

These changes make it so `rust` _won't_ stop evaluation after finishing parsing, enabling type checking errors to be displayed on the existing code without having to fix the parse errors.

Each commit has an individual diagnostic change with their corresponding tests.

CC rust-lang#48724.
bors added a commit that referenced this pull request Jan 14, 2019
Rollup of 8 pull requests

Successful merges:

 - #57043 (Fix poor worst case performance of set intersection)
 - #57480 (Clean up and fix a bug in query plumbing)
 - #57481 (provide suggestion for invalid boolean cast)
 - #57540 (Modify some parser diagnostics to continue evaluating beyond the parser)
 - #57570 (Querify local `plugin_registrar_fn` and `proc_macro_decls_static`)
 - #57572 (Unaccept `extern_in_paths`)
 - #57585 (Recover from item trailing semicolon)
 - #57589 (Add a debug_assert to Vec::set_len)

Failed merges:

r? @ghost
@bors bors merged commit 28ea03e into rust-lang:master Jan 15, 2019
@estebank estebank deleted the eval-more branch November 9, 2023 05:20
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