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

Do not exclusively suggest ; when , is also a choice #98796

Merged
merged 1 commit into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion compiler/rustc_parse/src/parser/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,8 @@ impl<'a> Parser<'a> {
|| (sm.is_multiline(
self.prev_token.span.shrink_to_hi().until(self.token.span.shrink_to_lo())
) && t == &token::Pound)
}) {
}) && !expected.contains(&TokenType::Token(token::Comma))
{
// Missing semicolon typo. This is triggered if the next token could either start a
// new statement or is a block close. For example:
//
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/parser/issues/issue-88770.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// error-pattern:this file contains an unclosed delimiter
// error-pattern:expected one of
// error-pattern:missing `in` in `for` loop
// error-pattern:expected `;`, found `e`
// error-pattern:expected one of `!`, `)`, `,`, `.`, `::`, `;`, `?`, `{`, or an operator, found `e`

fn m(){print!("",(c for&g
u
Expand Down
16 changes: 5 additions & 11 deletions src/test/ui/parser/issues/issue-88770.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,13 @@ error: expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found
LL | fn m(){print!("",(c for&g
| ^^^ expected one of 8 possible tokens

error: expected `;`, found `e`
--> $DIR/issue-88770.rs:10:2
error: expected one of `!`, `)`, `,`, `.`, `::`, `;`, `?`, `{`, or an operator, found `e`
--> $DIR/issue-88770.rs:11:1
|
LL | e
| ^ help: add `;` here
| - expected one of 9 possible tokens
LL | e
| - unexpected token
| ^ unexpected token

error: expected one of `!`, `,`, `.`, `::`, `?`, `{`, or an operator, found `)`
--> $DIR/issue-88770.rs:11:3
|
LL | e
| ^ expected one of 7 possible tokens

error: aborting due to 7 previous errors
error: aborting due to 6 previous errors

5 changes: 5 additions & 0 deletions src/test/ui/parser/suggest-semi-in-array.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fn main() {
let v = [1
2];
//~^ ERROR expected one of `,`, `.`, `;`, `?`, `]`, or an operator, found `2`
}
10 changes: 10 additions & 0 deletions src/test/ui/parser/suggest-semi-in-array.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: expected one of `,`, `.`, `;`, `?`, `]`, or an operator, found `2`
--> $DIR/suggest-semi-in-array.rs:3:5
|
LL | let v = [1
| - expected one of `,`, `.`, `;`, `?`, `]`, or an operator
LL | 2];
| ^ unexpected token

error: aborting due to previous error