diff options
| author | Jubilee <46493976+workingjubilee@users.noreply.github.com> | 2024-04-18 21:38:55 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-18 21:38:55 -0700 |
| commit | 0a0a5a956cfd4acf65f0fcaa4867ff131c6269c7 (patch) | |
| tree | b94462ce53b106a805df4f52f9d5d3a86a1f26a1 /compiler/rustc_parse/src | |
| parent | 3831cbb28f468f271ecffebac960ac4ea644e53a (diff) | |
| parent | 19821ad23474a3d056feac94f11569841764eb87 (diff) | |
| download | rust-0a0a5a956cfd4acf65f0fcaa4867ff131c6269c7.tar.gz rust-0a0a5a956cfd4acf65f0fcaa4867ff131c6269c7.zip | |
Rollup merge of #123752 - estebank:emoji-prefix, r=wesleywiser
Properly handle emojis as literal prefix in macros
Do not accept the following
```rust
macro_rules! lexes {($($_:tt)*) => {}}
lexes!(🐛"foo");
```
Before, invalid emoji identifiers were gated during parsing instead of lexing in all cases, but this didn't account for macro pre-expansion of literal prefixes.
Fix #123696.
Diffstat (limited to 'compiler/rustc_parse/src')
| -rw-r--r-- | compiler/rustc_parse/src/lexer/mod.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index 058539e1717..1abb1d29562 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -204,6 +204,7 @@ impl<'psess, 'src> StringReader<'psess, 'src> { self.ident(start) } rustc_lexer::TokenKind::InvalidIdent + | rustc_lexer::TokenKind::InvalidPrefix // Do not recover an identifier with emoji if the codepoint is a confusable // with a recoverable substitution token, like `➖`. if !UNICODE_ARRAY @@ -301,7 +302,9 @@ impl<'psess, 'src> StringReader<'psess, 'src> { rustc_lexer::TokenKind::Caret => token::BinOp(token::Caret), rustc_lexer::TokenKind::Percent => token::BinOp(token::Percent), - rustc_lexer::TokenKind::Unknown | rustc_lexer::TokenKind::InvalidIdent => { + rustc_lexer::TokenKind::Unknown + | rustc_lexer::TokenKind::InvalidIdent + | rustc_lexer::TokenKind::InvalidPrefix => { // Don't emit diagnostics for sequences of the same invalid token if swallow_next_invalid > 0 { swallow_next_invalid -= 1; |
