summaryrefslogtreecommitdiff
path: root/compiler/rustc_lexer/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-04-16 21:37:51 +0000
committerbors <bors@rust-lang.org>2023-04-16 21:37:51 +0000
commit84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc (patch)
tree45864520870b60ee1bb662685becc5f0b4804744 /compiler/rustc_lexer/src
parentf18236dcd3d8191c91aca0c4ef43e1e27b6bc0dc (diff)
parentc2c413f56eca868a5b5335ba21efa08368735d01 (diff)
downloadrust-stable.tar.gz
Auto merge of #110413 - pietroalbini:pa-1.69.0-stable, r=pietroalbini1.69.0stable
[stable] Prepare Rust 1.69.0 Last minute backports: * #109643 * #110135 * #109938 * #109937 * #109266 This PR also bumps the channel to stable, and backports the release notes from master. r? `@ghost` cc `@rust-lang/release`
Diffstat (limited to 'compiler/rustc_lexer/src')
-rw-r--r--compiler/rustc_lexer/src/lib.rs43
-rw-r--r--compiler/rustc_lexer/src/tests.rs2
2 files changed, 11 insertions, 34 deletions
diff --git a/compiler/rustc_lexer/src/lib.rs b/compiler/rustc_lexer/src/lib.rs
index 322ec31fb2c..b3f4b5cd5e5 100644
--- a/compiler/rustc_lexer/src/lib.rs
+++ b/compiler/rustc_lexer/src/lib.rs
@@ -95,7 +95,7 @@ pub enum TokenKind {
Literal { kind: LiteralKind, suffix_start: u32 },
/// "'a"
- Lifetime { starts_with_number: bool, contains_emoji: bool },
+ Lifetime { starts_with_number: bool },
// One-char tokens:
/// ";"
@@ -632,13 +632,7 @@ impl Cursor<'_> {
// If the first symbol is valid for identifier, it can be a lifetime.
// Also check if it's a number for a better error reporting (so '0 will
// be reported as invalid lifetime and not as unterminated char literal).
- // We also have to account for potential `'🐱` emojis to avoid reporting
- // it as an unterminated char literal.
- is_id_start(self.first())
- || self.first().is_digit(10)
- // FIXME(#108019): `unic-emoji-char` seems to have data tables only up to Unicode
- // 5.0, but Unicode is already newer than this.
- || unic_emoji_char::is_emoji(self.first())
+ is_id_start(self.first()) || self.first().is_digit(10)
};
if !can_be_a_lifetime {
@@ -651,33 +645,16 @@ impl Cursor<'_> {
return Literal { kind, suffix_start };
}
- // Either a lifetime or a character literal.
+ // Either a lifetime or a character literal with
+ // length greater than 1.
let starts_with_number = self.first().is_digit(10);
- let mut contains_emoji = false;
- // FIXME(#108019): `unic-emoji-char` seems to have data tables only up to Unicode
- // 5.0, but Unicode is already newer than this.
- if unic_emoji_char::is_emoji(self.first()) {
- contains_emoji = true;
- } else {
- // Skip the literal contents.
- // First symbol can be a number (which isn't a valid identifier start),
- // so skip it without any checks.
- self.bump();
- }
- self.eat_while(|c| {
- if is_id_continue(c) {
- true
- // FIXME(#108019): `unic-emoji-char` seems to have data tables only up to Unicode
- // 5.0, but Unicode is already newer than this.
- } else if unic_emoji_char::is_emoji(c) {
- contains_emoji = true;
- true
- } else {
- false
- }
- });
+ // Skip the literal contents.
+ // First symbol can be a number (which isn't a valid identifier start),
+ // so skip it without any checks.
+ self.bump();
+ self.eat_while(is_id_continue);
// Check if after skipping literal contents we've met a closing
// single quote (which means that user attempted to create a
@@ -687,7 +664,7 @@ impl Cursor<'_> {
let kind = Char { terminated: true };
Literal { kind, suffix_start: self.pos_within_token() }
} else {
- Lifetime { starts_with_number, contains_emoji }
+ Lifetime { starts_with_number }
}
}
diff --git a/compiler/rustc_lexer/src/tests.rs b/compiler/rustc_lexer/src/tests.rs
index 670d64fb983..e4c1787f2cc 100644
--- a/compiler/rustc_lexer/src/tests.rs
+++ b/compiler/rustc_lexer/src/tests.rs
@@ -235,7 +235,7 @@ fn lifetime() {
check_lexing(
"'abc",
expect![[r#"
- Token { kind: Lifetime { starts_with_number: false, contains_emoji: false }, len: 4 }
+ Token { kind: Lifetime { starts_with_number: false }, len: 4 }
"#]],
);
}