Reserve prefix lifetimes too
This commit is contained in:
parent
59d4114b2d
commit
9aaf873396
4 changed files with 51 additions and 9 deletions
|
@ -91,6 +91,12 @@ pub enum TokenKind {
|
|||
/// tokens.
|
||||
UnknownPrefix,
|
||||
|
||||
/// An unknown prefix in a lifetime, like `'foo#`.
|
||||
///
|
||||
/// Note that like above, only the `'` and prefix are included in the token
|
||||
/// and not the separator.
|
||||
UnknownPrefixLifetime,
|
||||
|
||||
/// Similar to the above, but *always* an error on every edition. This is used
|
||||
/// for emoji identifier recovery, as those are not meant to be ever accepted.
|
||||
InvalidPrefix,
|
||||
|
@ -688,15 +694,17 @@ impl Cursor<'_> {
|
|||
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
|
||||
// string with single quotes).
|
||||
if self.first() == '\'' {
|
||||
self.bump();
|
||||
let kind = Char { terminated: true };
|
||||
Literal { kind, suffix_start: self.pos_within_token() }
|
||||
} else {
|
||||
Lifetime { starts_with_number }
|
||||
match self.first() {
|
||||
// Check if after skipping literal contents we've met a closing
|
||||
// single quote (which means that user attempted to create a
|
||||
// string with single quotes).
|
||||
'\'' => {
|
||||
self.bump();
|
||||
let kind = Char { terminated: true };
|
||||
Literal { kind, suffix_start: self.pos_within_token() }
|
||||
}
|
||||
'#' if !starts_with_number => UnknownPrefixLifetime,
|
||||
_ => Lifetime { starts_with_number },
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue