Skip to content

Commit d433f17

Browse files
authored
Rollup merge of #127601 - trevyn:issue-127600, r=compiler-errors
check is_ident before parse_ident Closes #127600
2 parents 47ab866 + a01f49e commit d433f17

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

compiler/rustc_parse/src/parser/item.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,8 @@ impl<'a> Parser<'a> {
387387
let span = if is_pub { self.prev_token.span.to(ident_span) } else { ident_span };
388388
let insert_span = ident_span.shrink_to_lo();
389389

390-
let ident = if (!is_const
391-
|| self.look_ahead(1, |t| *t == token::OpenDelim(Delimiter::Parenthesis)))
390+
let ident = if self.token.is_ident()
391+
&& (!is_const || self.look_ahead(1, |t| *t == token::OpenDelim(Delimiter::Parenthesis)))
392392
&& self.look_ahead(1, |t| {
393393
[
394394
token::Lt,

tests/ui/parser/ice-issue-127600.rs

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const!(&raw mut a);
2+
//~^ ERROR expected identifier, found `!`
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: expected identifier, found `!`
2+
--> $DIR/ice-issue-127600.rs:1:6
3+
|
4+
LL | const!(&raw mut a);
5+
| ^ expected identifier
6+
7+
error: aborting due to 1 previous error
8+

0 commit comments

Comments
 (0)