diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-02-18 13:26:46 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-18 13:26:46 +0100 |
| commit | 3035ccbcb972a7d762c8e3f64a6b200434677209 (patch) | |
| tree | 14e538a50e8187007e1d40e81ad8b37c42b4ed48 /compiler/rustc_parse/src | |
| parent | 3701bdc6333145410f009c83bd03f424eca05009 (diff) | |
| parent | e3f9db5fc319c6d8eee5d47d216ea6a426070c41 (diff) | |
| download | rust-3035ccbcb972a7d762c8e3f64a6b200434677209.tar.gz rust-3035ccbcb972a7d762c8e3f64a6b200434677209.zip | |
Rollup merge of #108031 - jieyouxu:issue-108019, r=estebank
Don't recover lifetimes/labels containing emojis as character literals Fixes #108019. Note that at the time of this commit, `unic-emoji-char` seems to have data tables only up to Unicode 5.0, but Unicode is already newer than this. A newer emoji such as `🥺` will not be recognized as an emoji but older emojis such as `🐱` will. This PR leaves a couple of FIXMEs where `unic_emoji_char::is_emoji` is used.
Diffstat (limited to 'compiler/rustc_parse/src')
| -rw-r--r-- | compiler/rustc_parse/src/lexer/mod.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index bd998ed91d9..37449aaabed 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -200,16 +200,21 @@ impl<'a> StringReader<'a> { }; token::Literal(token::Lit { kind, symbol, suffix }) } - rustc_lexer::TokenKind::Lifetime { starts_with_number } => { + rustc_lexer::TokenKind::Lifetime { starts_with_number, contains_emoji } => { // Include the leading `'` in the real identifier, for macro // expansion purposes. See #12512 for the gory details of why // this is necessary. let lifetime_name = self.str_from(start); if starts_with_number { let span = self.mk_sp(start, self.pos); - let mut diag = self.sess.struct_err("lifetimes cannot start with a number"); + let mut diag = self.sess.struct_err("lifetimes or labels cannot start with a number"); diag.set_span(span); diag.stash(span, StashKey::LifetimeIsChar); + } else if contains_emoji { + let span = self.mk_sp(start, self.pos); + let mut diag = self.sess.struct_err("lifetimes or labels cannot contain emojis"); + diag.set_span(span); + diag.stash(span, StashKey::LifetimeContainsEmoji); } let ident = Symbol::intern(lifetime_name); token::Lifetime(ident) |
