mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-19 11:12:43 +00:00
Rename 'bad prefix' to 'unknown prefix'.
This commit is contained in:
parent
d40be0fc64
commit
0eeeebc990
@ -72,7 +72,7 @@ pub enum TokenKind {
|
|||||||
/// prefixes are reported as errors; in earlier editions, they result in a
|
/// prefixes are reported as errors; in earlier editions, they result in a
|
||||||
/// (allowed by default) lint, and are treated as regular identifier
|
/// (allowed by default) lint, and are treated as regular identifier
|
||||||
/// tokens.
|
/// tokens.
|
||||||
BadPrefix,
|
UnknownPrefix,
|
||||||
/// "12_u8", "1.0e-40", "b"123"". See `LiteralKind` for more details.
|
/// "12_u8", "1.0e-40", "b"123"". See `LiteralKind` for more details.
|
||||||
Literal { kind: LiteralKind, suffix_start: usize },
|
Literal { kind: LiteralKind, suffix_start: usize },
|
||||||
/// "'a"
|
/// "'a"
|
||||||
@ -330,7 +330,7 @@ impl Cursor<'_> {
|
|||||||
let kind = RawStr { n_hashes, err };
|
let kind = RawStr { n_hashes, err };
|
||||||
Literal { kind, suffix_start }
|
Literal { kind, suffix_start }
|
||||||
}
|
}
|
||||||
_ => self.ident_or_bad_prefix(),
|
_ => self.ident_or_unknown_prefix(),
|
||||||
},
|
},
|
||||||
|
|
||||||
// Byte literal, byte string literal, raw byte string literal or identifier.
|
// Byte literal, byte string literal, raw byte string literal or identifier.
|
||||||
@ -365,12 +365,12 @@ impl Cursor<'_> {
|
|||||||
let kind = RawByteStr { n_hashes, err };
|
let kind = RawByteStr { n_hashes, err };
|
||||||
Literal { kind, suffix_start }
|
Literal { kind, suffix_start }
|
||||||
}
|
}
|
||||||
_ => self.ident_or_bad_prefix(),
|
_ => self.ident_or_unknown_prefix(),
|
||||||
},
|
},
|
||||||
|
|
||||||
// Identifier (this should be checked after other variant that can
|
// Identifier (this should be checked after other variant that can
|
||||||
// start as identifier).
|
// start as identifier).
|
||||||
c if is_id_start(c) => self.ident_or_bad_prefix(),
|
c if is_id_start(c) => self.ident_or_unknown_prefix(),
|
||||||
|
|
||||||
// Numeric literal.
|
// Numeric literal.
|
||||||
c @ '0'..='9' => {
|
c @ '0'..='9' => {
|
||||||
@ -494,14 +494,14 @@ impl Cursor<'_> {
|
|||||||
RawIdent
|
RawIdent
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ident_or_bad_prefix(&mut self) -> TokenKind {
|
fn ident_or_unknown_prefix(&mut self) -> TokenKind {
|
||||||
debug_assert!(is_id_start(self.prev()));
|
debug_assert!(is_id_start(self.prev()));
|
||||||
// Start is already eaten, eat the rest of identifier.
|
// Start is already eaten, eat the rest of identifier.
|
||||||
self.eat_while(is_id_continue);
|
self.eat_while(is_id_continue);
|
||||||
// Good prefixes must have been handled earlier. So if
|
// Known prefixes must have been handled earlier. So if
|
||||||
// we see a prefix here, it is definitely a bad prefix.
|
// we see a prefix here, it is definitely a unknown prefix.
|
||||||
match self.first() {
|
match self.first() {
|
||||||
'#' | '"' | '\'' => BadPrefix,
|
'#' | '"' | '\'' => UnknownPrefix,
|
||||||
_ => Ident,
|
_ => Ident,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,15 +170,15 @@ impl<'a> StringReader<'a> {
|
|||||||
rustc_lexer::TokenKind::Whitespace => return None,
|
rustc_lexer::TokenKind::Whitespace => return None,
|
||||||
rustc_lexer::TokenKind::Ident
|
rustc_lexer::TokenKind::Ident
|
||||||
| rustc_lexer::TokenKind::RawIdent
|
| rustc_lexer::TokenKind::RawIdent
|
||||||
| rustc_lexer::TokenKind::BadPrefix => {
|
| rustc_lexer::TokenKind::UnknownPrefix => {
|
||||||
let is_raw_ident = token == rustc_lexer::TokenKind::RawIdent;
|
let is_raw_ident = token == rustc_lexer::TokenKind::RawIdent;
|
||||||
let is_bad_prefix = token == rustc_lexer::TokenKind::BadPrefix;
|
let is_unknown_prefix = token == rustc_lexer::TokenKind::UnknownPrefix;
|
||||||
let mut ident_start = start;
|
let mut ident_start = start;
|
||||||
if is_raw_ident {
|
if is_raw_ident {
|
||||||
ident_start = ident_start + BytePos(2);
|
ident_start = ident_start + BytePos(2);
|
||||||
}
|
}
|
||||||
if is_bad_prefix {
|
if is_unknown_prefix {
|
||||||
self.report_reserved_prefix(start);
|
self.report_unknown_prefix(start);
|
||||||
}
|
}
|
||||||
let sym = nfc_normalize(self.str_from(ident_start));
|
let sym = nfc_normalize(self.str_from(ident_start));
|
||||||
let span = self.mk_sp(start, self.pos);
|
let span = self.mk_sp(start, self.pos);
|
||||||
@ -503,7 +503,7 @@ impl<'a> StringReader<'a> {
|
|||||||
// using a (unknown) prefix is an error. In earlier editions, however, they
|
// using a (unknown) prefix is an error. In earlier editions, however, they
|
||||||
// only result in a (allowed by default) lint, and are treated as regular
|
// only result in a (allowed by default) lint, and are treated as regular
|
||||||
// identifier tokens.
|
// identifier tokens.
|
||||||
fn report_reserved_prefix(&self, start: BytePos) {
|
fn report_unknown_prefix(&self, start: BytePos) {
|
||||||
let prefix_span = self.mk_sp(start, self.pos);
|
let prefix_span = self.mk_sp(start, self.pos);
|
||||||
let msg = format!("prefix `{}` is unknown", self.str_from_to(start, self.pos));
|
let msg = format!("prefix `{}` is unknown", self.str_from_to(start, self.pos));
|
||||||
|
|
||||||
|
@ -413,7 +413,7 @@ impl<'a> Classifier<'a> {
|
|||||||
},
|
},
|
||||||
c => c,
|
c => c,
|
||||||
},
|
},
|
||||||
TokenKind::RawIdent | TokenKind::BadPrefix => Class::Ident,
|
TokenKind::RawIdent | TokenKind::UnknownPrefix => Class::Ident,
|
||||||
TokenKind::Lifetime { .. } => Class::Lifetime,
|
TokenKind::Lifetime { .. } => Class::Lifetime,
|
||||||
};
|
};
|
||||||
// Anything that didn't return above is the simple case where we the
|
// Anything that didn't return above is the simple case where we the
|
||||||
|
Loading…
Reference in New Issue
Block a user