diff options
| author | Deadbeef <ent3rm4n@gmail.com> | 2025-08-22 13:06:49 +0800 |
|---|---|---|
| committer | Deadbeef <ent3rm4n@gmail.com> | 2025-08-22 13:16:44 +0800 |
| commit | 4970127c33a2cfd7b7035daedba7cac512a2e201 (patch) | |
| tree | 08a7479f29ebe9ec547e311a7e0e381f9134f53a /compiler/rustc_span/src | |
| parent | 30bb7045d6b80b979b235396626f3b405cfec160 (diff) | |
| download | rust-4970127c33a2cfd7b7035daedba7cac512a2e201.tar.gz rust-4970127c33a2cfd7b7035daedba7cac512a2e201.zip | |
address review comments
Diffstat (limited to 'compiler/rustc_span/src')
| -rw-r--r-- | compiler/rustc_span/src/symbol.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index d6acd902c7c..744a4771aae 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -3045,13 +3045,17 @@ impl Ident { self.name.can_be_raw() && self.is_reserved() } + /// Given the name of a lifetime without the first quote (`'`), + /// returns whether the lifetime name is reserved (therefore invalid) + pub fn is_reserved_lifetime(self) -> bool { + self.is_reserved() && ![kw::Underscore, kw::Static].contains(&self.name) + } + pub fn is_raw_lifetime_guess(self) -> bool { - // this should be kept consistent with `Parser::expect_lifetime` found under - // compiler/rustc_parse/src/parser/ty.rs let name_without_apostrophe = self.without_first_quote(); name_without_apostrophe.name != self.name - && ![kw::UnderscoreLifetime, kw::StaticLifetime].contains(&self.name) - && name_without_apostrophe.is_raw_guess() + && name_without_apostrophe.name.can_be_raw() + && name_without_apostrophe.is_reserved_lifetime() } pub fn guess_print_mode(self) -> IdentPrintMode { |
