parser: Remove Parser::prev_span
This commit is contained in:
parent
d0ba4387c2
commit
7de9a72ca3
3 changed files with 12 additions and 10 deletions
|
@ -1348,7 +1348,7 @@ impl<'a> Parser<'a> {
|
||||||
if self.normalized_token.span.rust_2018() { self.parse_asyncness() } else { Async::No };
|
if self.normalized_token.span.rust_2018() { self.parse_asyncness() } else { Async::No };
|
||||||
if asyncness.is_async() {
|
if asyncness.is_async() {
|
||||||
// Feature-gate `async ||` closures.
|
// Feature-gate `async ||` closures.
|
||||||
self.sess.gated_spans.gate(sym::async_closure, self.prev_span);
|
self.sess.gated_spans.gate(sym::async_closure, self.normalized_prev_token.span);
|
||||||
}
|
}
|
||||||
|
|
||||||
let capture_clause = self.parse_capture_clause();
|
let capture_clause = self.parse_capture_clause();
|
||||||
|
|
|
@ -568,7 +568,7 @@ impl<'a> Parser<'a> {
|
||||||
&& self.look_ahead(1, |t| t.is_non_raw_ident_where(|i| i.name != kw::As))
|
&& self.look_ahead(1, |t| t.is_non_raw_ident_where(|i| i.name != kw::As))
|
||||||
{
|
{
|
||||||
self.bump(); // `default`
|
self.bump(); // `default`
|
||||||
Defaultness::Default(self.prev_span)
|
Defaultness::Default(self.normalized_prev_token.span)
|
||||||
} else {
|
} else {
|
||||||
Defaultness::Final
|
Defaultness::Final
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,8 +101,6 @@ pub struct Parser<'a> {
|
||||||
/// Use this if you need to check for `token::Ident` or `token::Lifetime` specifically,
|
/// Use this if you need to check for `token::Ident` or `token::Lifetime` specifically,
|
||||||
/// this also includes edition checks for edition-specific keyword identifiers.
|
/// this also includes edition checks for edition-specific keyword identifiers.
|
||||||
pub normalized_prev_token: Token,
|
pub normalized_prev_token: Token,
|
||||||
/// FIXME: Remove in favor of the equivalent `prev_token.span`.
|
|
||||||
pub prev_span: Span,
|
|
||||||
restrictions: Restrictions,
|
restrictions: Restrictions,
|
||||||
/// Used to determine the path to externally loaded source files.
|
/// Used to determine the path to externally loaded source files.
|
||||||
pub(super) directory: Directory,
|
pub(super) directory: Directory,
|
||||||
|
@ -377,7 +375,6 @@ impl<'a> Parser<'a> {
|
||||||
normalized_token: Token::dummy(),
|
normalized_token: Token::dummy(),
|
||||||
prev_token: Token::dummy(),
|
prev_token: Token::dummy(),
|
||||||
normalized_prev_token: Token::dummy(),
|
normalized_prev_token: Token::dummy(),
|
||||||
prev_span: DUMMY_SP,
|
|
||||||
restrictions: Restrictions::empty(),
|
restrictions: Restrictions::empty(),
|
||||||
recurse_into_file_modules,
|
recurse_into_file_modules,
|
||||||
directory: Directory {
|
directory: Directory {
|
||||||
|
@ -848,9 +845,6 @@ impl<'a> Parser<'a> {
|
||||||
self.normalized_prev_token = self.normalized_token.take();
|
self.normalized_prev_token = self.normalized_token.take();
|
||||||
self.set_token(next_token);
|
self.set_token(next_token);
|
||||||
|
|
||||||
// Update fields derived from the previous token.
|
|
||||||
self.prev_span = self.prev_token.span;
|
|
||||||
|
|
||||||
// Diagnostics.
|
// Diagnostics.
|
||||||
self.expected_tokens.clear();
|
self.expected_tokens.clear();
|
||||||
}
|
}
|
||||||
|
@ -897,12 +891,20 @@ impl<'a> Parser<'a> {
|
||||||
|
|
||||||
/// Parses unsafety: `unsafe` or nothing.
|
/// Parses unsafety: `unsafe` or nothing.
|
||||||
fn parse_unsafety(&mut self) -> Unsafe {
|
fn parse_unsafety(&mut self) -> Unsafe {
|
||||||
if self.eat_keyword(kw::Unsafe) { Unsafe::Yes(self.prev_span) } else { Unsafe::No }
|
if self.eat_keyword(kw::Unsafe) {
|
||||||
|
Unsafe::Yes(self.normalized_prev_token.span)
|
||||||
|
} else {
|
||||||
|
Unsafe::No
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parses constness: `const` or nothing.
|
/// Parses constness: `const` or nothing.
|
||||||
fn parse_constness(&mut self) -> Const {
|
fn parse_constness(&mut self) -> Const {
|
||||||
if self.eat_keyword(kw::Const) { Const::Yes(self.prev_span) } else { Const::No }
|
if self.eat_keyword(kw::Const) {
|
||||||
|
Const::Yes(self.normalized_prev_token.span)
|
||||||
|
} else {
|
||||||
|
Const::No
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parses mutability (`mut` or nothing).
|
/// Parses mutability (`mut` or nothing).
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue