Skip to content

Commit

Permalink
Rollup merge of #127601 - trevyn:issue-127600, r=compiler-errors
Browse files Browse the repository at this point in the history
check is_ident before parse_ident

Closes #127600
  • Loading branch information
matthiaskrgr committed Jul 11, 2024
2 parents 47ab866 + a01f49e commit d433f17
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
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

0 comments on commit d433f17

Please sign in to comment.