@@ -99,10 +99,6 @@ pub enum TokenKind {
99
99
/// several tokens: `'r` and `#` and `foo`.
100
100
RawLifetime ,
101
101
102
- /// Similar to the above, but *always* an error on every edition. This is used
103
- /// for emoji identifier recovery, as those are not meant to be ever accepted.
104
- InvalidPrefix ,
105
-
106
102
/// Guarded string literal prefix: `#"` or `##`.
107
103
///
108
104
/// Used for reserving "guarded strings" (RFC 3598) in edition 2024.
@@ -466,7 +462,7 @@ impl Cursor<'_> {
466
462
Literal { kind, suffix_start }
467
463
}
468
464
// Identifier starting with an emoji. Only lexed for graceful error recovery.
469
- c if !c. is_ascii ( ) && c. is_emoji_char ( ) => self . invalid_ident_or_prefix ( ) ,
465
+ c if !c. is_ascii ( ) && c. is_emoji_char ( ) => self . invalid_ident ( ) ,
470
466
_ => Unknown ,
471
467
} ;
472
468
let res = Token :: new ( token_kind, self . pos_within_token ( ) ) ;
@@ -550,23 +546,22 @@ impl Cursor<'_> {
550
546
// we see a prefix here, it is definitely an unknown prefix.
551
547
match self . first ( ) {
552
548
'#' | '"' | '\'' => UnknownPrefix ,
553
- c if !c. is_ascii ( ) && c. is_emoji_char ( ) => self . invalid_ident_or_prefix ( ) ,
549
+ c if !c. is_ascii ( ) && c. is_emoji_char ( ) => self . invalid_ident ( ) ,
554
550
_ => Ident ,
555
551
}
556
552
}
557
553
558
- fn invalid_ident_or_prefix ( & mut self ) -> TokenKind {
554
+ fn invalid_ident ( & mut self ) -> TokenKind {
559
555
// Start is already eaten, eat the rest of identifier.
560
556
self . eat_while ( |c| {
561
557
const ZERO_WIDTH_JOINER : char = '\u{200d}' ;
562
558
is_id_continue ( c) || ( !c. is_ascii ( ) && c. is_emoji_char ( ) ) || c == ZERO_WIDTH_JOINER
563
559
} ) ;
564
- // Known prefixes must have been handled earlier. So if
565
- // we see a prefix here, it is definitely an unknown prefix.
566
- match self . first ( ) {
567
- '#' | '"' | '\'' => InvalidPrefix ,
568
- _ => InvalidIdent ,
569
- }
560
+ // An invalid identifier followed by '#' or '"' or '\'' could be
561
+ // interpreted as an invalid literal prefix. We don't bother doing that
562
+ // because the treatment of invalid identifiers and invalid prefixes
563
+ // would be the same.
564
+ InvalidIdent
570
565
}
571
566
572
567
fn c_or_byte_string (
0 commit comments