check is_ident before parse_ident

This commit is contained in:
trevyn 2024-07-11 12:12:00 +04:00
parent 8c39ac9ecc
commit a01f49e7f3
3 changed files with 12 additions and 2 deletions

View File

@ -387,8 +387,8 @@ fn recover_missing_kw_before_item(&mut self) -> PResult<'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,

View File

@ -0,0 +1,2 @@
const!(&raw mut a);
//~^ ERROR expected identifier, found `!`

View File

@ -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