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

check is_ident before parse_ident #127601

Merged
merged 1 commit into from
Jul 12, 2024
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
4 changes: 2 additions & 2 deletions compiler/rustc_parse/src/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ impl<'a> Parser<'a> {
let span = if is_pub { self.prev_token.span.to(ident_span) } else { ident_span };
let insert_span = ident_span.shrink_to_lo();

let ident = if (!is_const
|| self.look_ahead(1, |t| *t == token::OpenDelim(Delimiter::Parenthesis)))
let ident = if self.token.is_ident()
&& (!is_const || self.look_ahead(1, |t| *t == token::OpenDelim(Delimiter::Parenthesis)))
&& self.look_ahead(1, |t| {
[
token::Lt,
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/parser/ice-issue-127600.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const!(&raw mut a);
//~^ ERROR expected identifier, found `!`
8 changes: 8 additions & 0 deletions tests/ui/parser/ice-issue-127600.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: expected identifier, found `!`
--> $DIR/ice-issue-127600.rs:1:6
|
LL | const!(&raw mut a);
| ^ expected identifier

error: aborting due to 1 previous error

Loading