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

Reduce amount of errors given unclosed delimiter #65838

Merged
merged 2 commits into from
Nov 4, 2019

Conversation

estebank
Copy link
Contributor

When in a file with a non-terminated item, catch the error and consume
the block instead of trying to recover it on a more granular way in order to
reduce the amount of unrelated errors that would be fixed after adding
the missing closing brace. Also point out the possible location of the
missing closing brace.

Fix #63690.

@rust-highfive
Copy link
Collaborator

r? @eddyb

(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 Oct 26, 2019
@estebank
Copy link
Contributor Author

r? @Centril @petrochenkov

@rust-highfive rust-highfive assigned Centril and unassigned eddyb Oct 26, 2019
src/libsyntax/parse/parser.rs Outdated Show resolved Hide resolved
src/libsyntax/parse/mod.rs Outdated Show resolved Hide resolved
src/libsyntax/parse/parser/diagnostics.rs Outdated Show resolved Hide resolved
src/libsyntax/parse/parser/diagnostics.rs Outdated Show resolved Hide resolved
src/libsyntax/parse/parser/diagnostics.rs Outdated Show resolved Hide resolved
src/libsyntax/parse/parser/diagnostics.rs Show resolved Hide resolved
@@ -1520,14 +1522,15 @@ impl<'a> Parser<'a> {
if self.eat(&token::OpenDelim(token::Brace)) {
while self.token != token::CloseDelim(token::Brace) {
let field = self.parse_struct_decl_field().map_err(|e| {
self.recover_stmt();
self.consume_block(token::Brace, false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Btw... this function and friends are a mess; I tried to convert this to use the list parsing utilities before but the success was not complete; I'll probably give it a go some time in the future.

src/test/ui/did_you_mean/issue-40006.rs Show resolved Hide resolved
src/test/ui/parser/issue-62973.stderr Show resolved Hide resolved
@Centril
Copy link
Contributor

Centril commented Oct 26, 2019

cc @matklad

@Centril Centril 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 Oct 26, 2019
@rust-highfive

This comment has been minimized.

@Centril Centril 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 Oct 27, 2019
@estebank estebank changed the title Reduce ammount of errors given unclosed delimiter Reduce amount of errors given unclosed delimiter Oct 29, 2019
src/libsyntax/parse/mod.rs Outdated Show resolved Hide resolved
src/librustc_passes/entry.rs Show resolved Hide resolved
@Centril Centril 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 Oct 29, 2019
@rust-highfive

This comment has been minimized.

@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 Oct 29, 2019
@Centril
Copy link
Contributor

Centril commented Oct 30, 2019

Thanks; this looks good. r=me with commits reasonably squashed in some manner (into one or as you see fit).

@Centril Centril 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 Oct 30, 2019
When in a file with a non-terminated item, catch the error and consume
the block instead of trying to recover it more granularly in order to
reduce the amount of unrelated errors that would be fixed after adding
the missing closing brace. Also point out the possible location of the
missing closing brace.
@estebank
Copy link
Contributor Author

@bors r=Centril

@bors
Copy link
Contributor

bors commented Oct 30, 2019

📌 Commit 454e2aa has been approved by Centril

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 30, 2019
tmandry added a commit to tmandry/rust that referenced this pull request Nov 1, 2019
Reduce amount of errors given unclosed delimiter

When in a file with a non-terminated item, catch the error and consume
the block instead of trying to recover it on a more granular way in order to
reduce the amount of unrelated errors that would be fixed after adding
the missing closing brace. Also point out the possible location of the
missing closing brace.

Fix rust-lang#63690.
tmandry added a commit to tmandry/rust that referenced this pull request Nov 1, 2019
Reduce amount of errors given unclosed delimiter

When in a file with a non-terminated item, catch the error and consume
the block instead of trying to recover it on a more granular way in order to
reduce the amount of unrelated errors that would be fixed after adding
the missing closing brace. Also point out the possible location of the
missing closing brace.

Fix rust-lang#63690.
@bors
Copy link
Contributor

bors commented Nov 4, 2019

⌛ Testing commit 454e2aa with merge f49f388...

bors added a commit that referenced this pull request Nov 4, 2019
Reduce amount of errors given unclosed delimiter

When in a file with a non-terminated item, catch the error and consume
the block instead of trying to recover it on a more granular way in order to
reduce the amount of unrelated errors that would be fixed after adding
the missing closing brace. Also point out the possible location of the
missing closing brace.

Fix #63690.
@bors
Copy link
Contributor

bors commented Nov 4, 2019

☀️ Test successful - checks-azure
Approved by: Centril
Pushing f49f388 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 4, 2019
@bors bors merged commit 454e2aa into rust-lang:master Nov 4, 2019
@estebank estebank deleted the resilient-recovery branch November 9, 2023 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.

Diagnostics could be better for unclosed delimiters
5 participants