diff options
| author | Michael Goulet <michael@errs.io> | 2024-06-20 16:36:35 -0400 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-07-16 12:06:25 -0400 |
| commit | d0a1851ec2cf84bdb41bc4d788b3995a8463c543 (patch) | |
| tree | 6b7333a6eb3800ad80d39cfb57080251d7e5db3d /compiler/rustc_parse/src/parser/ty.rs | |
| parent | a91f7d72f12efcc00ecf71591f066c534d45ddf7 (diff) | |
| download | rust-d0a1851ec2cf84bdb41bc4d788b3995a8463c543.tar.gz rust-d0a1851ec2cf84bdb41bc4d788b3995a8463c543.zip | |
Deny keyword lifetimes pre-expansion
Diffstat (limited to 'compiler/rustc_parse/src/parser/ty.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/ty.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs index 94321b1dddd..68b8af7d20e 100644 --- a/compiler/rustc_parse/src/parser/ty.rs +++ b/compiler/rustc_parse/src/parser/ty.rs @@ -1230,6 +1230,12 @@ impl<'a> Parser<'a> { /// Parses a single lifetime `'a` or panics. pub(super) fn expect_lifetime(&mut self) -> Lifetime { if let Some(ident) = self.token.lifetime() { + if ident.without_first_quote().is_reserved() + && ![kw::UnderscoreLifetime, kw::StaticLifetime].contains(&ident.name) + { + self.dcx().emit_err(errors::KeywordLifetime { span: ident.span }); + } + self.bump(); Lifetime { ident, id: ast::DUMMY_NODE_ID } } else { |
