about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2020-02-29 14:59:37 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2020-02-29 15:00:58 +0300
commit7de9a72ca3769f55b415372f1f59f70ccf1f66fe (patch)
tree980ea542e33fad6a865034866028397a539c48e5
parentd0ba4387c2730b0323bcd42170edf8477a799af7 (diff)
downloadrust-7de9a72ca3769f55b415372f1f59f70ccf1f66fe.tar.gz
rust-7de9a72ca3769f55b415372f1f59f70ccf1f66fe.zip
parser: Remove `Parser::prev_span`
-rw-r--r--src/librustc_parse/parser/expr.rs2
-rw-r--r--src/librustc_parse/parser/item.rs2
-rw-r--r--src/librustc_parse/parser/mod.rs18
3 files changed, 12 insertions, 10 deletions
diff --git a/src/librustc_parse/parser/expr.rs b/src/librustc_parse/parser/expr.rs
index c1158483302..1e52d454e0d 100644
--- a/src/librustc_parse/parser/expr.rs
+++ b/src/librustc_parse/parser/expr.rs
@@ -1348,7 +1348,7 @@ impl<'a> Parser<'a> {
             if self.normalized_token.span.rust_2018() { self.parse_asyncness() } else { Async::No };
         if asyncness.is_async() {
             // 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();
diff --git a/src/librustc_parse/parser/item.rs b/src/librustc_parse/parser/item.rs
index daec6de81fc..3b5130ab29a 100644
--- a/src/librustc_parse/parser/item.rs
+++ b/src/librustc_parse/parser/item.rs
@@ -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.bump(); // `default`
-            Defaultness::Default(self.prev_span)
+            Defaultness::Default(self.normalized_prev_token.span)
         } else {
             Defaultness::Final
         }
diff --git a/src/librustc_parse/parser/mod.rs b/src/librustc_parse/parser/mod.rs
index d33fae7dbe4..fc1c99dedf1 100644
--- a/src/librustc_parse/parser/mod.rs
+++ b/src/librustc_parse/parser/mod.rs
@@ -101,8 +101,6 @@ pub struct Parser<'a> {
     /// Use this if you need to check for `token::Ident` or `token::Lifetime` specifically,
     /// this also includes edition checks for edition-specific keyword identifiers.
     pub normalized_prev_token: Token,
-    /// FIXME: Remove in favor of the equivalent `prev_token.span`.
-    pub prev_span: Span,
     restrictions: Restrictions,
     /// Used to determine the path to externally loaded source files.
     pub(super) directory: Directory,
@@ -377,7 +375,6 @@ impl<'a> Parser<'a> {
             normalized_token: Token::dummy(),
             prev_token: Token::dummy(),
             normalized_prev_token: Token::dummy(),
-            prev_span: DUMMY_SP,
             restrictions: Restrictions::empty(),
             recurse_into_file_modules,
             directory: Directory {
@@ -848,9 +845,6 @@ impl<'a> Parser<'a> {
         self.normalized_prev_token = self.normalized_token.take();
         self.set_token(next_token);
 
-        // Update fields derived from the previous token.
-        self.prev_span = self.prev_token.span;
-
         // Diagnostics.
         self.expected_tokens.clear();
     }
@@ -897,12 +891,20 @@ impl<'a> Parser<'a> {
 
     /// Parses unsafety: `unsafe` or nothing.
     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.
     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).