-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Improve parser diagnostics #95211
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
Improve parser diagnostics #95211
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -548,6 +548,22 @@ impl<'a> Parser<'a> { | |
is_present | ||
} | ||
|
||
fn check_noexpect(&self, tok: &TokenKind) -> bool { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you double check if the parser has other There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that i am able to do that as from what I was able to see that would require a decent amount of work and I just wanted to finish up the changes in this pr. |
||
self.token == *tok | ||
} | ||
|
||
/// Consumes a token 'tok' if it exists. Returns whether the given token was present. | ||
/// | ||
/// the main purpose of this function is to reduce the cluttering of the suggestions list | ||
/// which using the normal eat method could introduce in some cases. | ||
pub fn eat_noexpect(&mut self, tok: &TokenKind) -> bool { | ||
let is_present = self.check_noexpect(tok); | ||
if is_present { | ||
self.bump() | ||
} | ||
is_present | ||
} | ||
|
||
/// Consumes a token 'tok' if it exists. Returns whether the given token was present. | ||
pub fn eat(&mut self, tok: &TokenKind) -> bool { | ||
let is_present = self.check(tok); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
error: expected one of `.`, `;`, `?`, `}`, or an operator, found keyword `enum` | ||
error: expected one of `;`, `}`, or an operator, found keyword `enum` | ||
--> $DIR/can-begin-expr-check.rs:19:12 | ||
| | ||
LL | return enum; | ||
| ^^^^ expected one of `.`, `;`, `?`, `}`, or an operator | ||
| ^^^^ expected one of `;`, `}`, or an operator | ||
|
||
error: aborting due to previous error | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
pub struct Entry<'a, K, V> { | ||
k: &'a mut K, | ||
v: V, | ||
} | ||
|
||
pub fn entry<'a, K, V>() -> Entry<'a K, V> { | ||
// ^ missing comma | ||
//~^^ expected one of `,` or `>`, found `K` | ||
unimplemented!() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
error: expected one of `,` or `>`, found `K` | ||
--> $DIR/issue-93867.rs:6:38 | ||
| | ||
LL | pub fn entry<'a, K, V>() -> Entry<'a K, V> { | ||
| ^ expected one of `,` or `>` | ||
| | ||
help: you might have meant to end the type parameters here | ||
| | ||
LL | pub fn entry<'a, K, V>() -> Entry<'a> K, V> { | ||
| + | ||
|
||
error: aborting due to previous error | ||
|
Uh oh!
There was an error while loading. Please reload this page.