]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_parse/parser/path.rs
Rollup merge of #69554 - GuillaumeGomez:cleanup-e0374, r=Dylan-DPC
[rust.git] / src / librustc_parse / parser / path.rs
index 6a71ebe218342f6ba76d2a63d237e5a22f77c724..355b6429a7494fdc8122120e81b88c766ffeb357 100644 (file)
@@ -50,7 +50,7 @@ impl<'a> Parser<'a> {
     /// `<T as U>::F::a<S>` (without disambiguator)
     /// `<T as U>::F::a::<S>` (with disambiguator)
     pub(super) fn parse_qpath(&mut self, style: PathStyle) -> PResult<'a, (QSelf, Path)> {
-        let lo = self.prev_span;
+        let lo = self.prev_token.span;
         let ty = self.parse_ty()?;
 
         // `path` will contain the prefix of the path up to the `>`,
@@ -61,7 +61,7 @@ pub(super) fn parse_qpath(&mut self, style: PathStyle) -> PResult<'a, (QSelf, Pa
         if self.eat_keyword(kw::As) {
             let path_lo = self.token.span;
             path = self.parse_path(PathStyle::Type)?;
-            path_span = path_lo.to(self.prev_span);
+            path_span = path_lo.to(self.prev_token.span);
         } else {
             path_span = self.token.span.to(self.token.span);
             path = ast::Path { segments: Vec::new(), span: path_span };
@@ -81,7 +81,7 @@ pub(super) fn parse_qpath(&mut self, style: PathStyle) -> PResult<'a, (QSelf, Pa
         let qself = QSelf { ty, path_span, position: path.segments.len() };
         self.parse_path_segments(&mut path.segments, style)?;
 
-        Ok((qself, Path { segments: path.segments, span: lo.to(self.prev_span) }))
+        Ok((qself, Path { segments: path.segments, span: lo.to(self.prev_token.span) }))
     }
 
     /// Recover from an invalid single colon, when the user likely meant a qualified path.
@@ -103,11 +103,11 @@ fn recover_colon_before_qpath_proj(&mut self) -> bool {
 
         self.diagnostic()
             .struct_span_err(
-                self.prev_span,
+                self.prev_token.span,
                 "found single colon before projection in qualified path",
             )
             .span_suggestion(
-                self.prev_span,
+                self.prev_token.span,
                 "use double colon",
                 "::".to_string(),
                 Applicability::MachineApplicable,
@@ -144,7 +144,7 @@ pub fn parse_path(&mut self, style: PathStyle) -> PResult<'a, Path> {
         }
         self.parse_path_segments(&mut segments, style)?;
 
-        Ok(Path { segments, span: lo.to(self.prev_span) })
+        Ok(Path { segments, span: lo.to(self.prev_token.span) })
     }
 
     pub(super) fn parse_path_segments(
@@ -221,12 +221,12 @@ pub(super) fn parse_path_segment(&mut self, style: PathStyle) -> PResult<'a, Pat
                     let (args, constraints) =
                         self.parse_generic_args_with_leading_angle_bracket_recovery(style, lo)?;
                     self.expect_gt()?;
-                    let span = lo.to(self.prev_span);
+                    let span = lo.to(self.prev_token.span);
                     AngleBracketedArgs { args, constraints, span }.into()
                 } else {
                     // `(T, U) -> R`
                     let (inputs, _) = self.parse_paren_comma_seq(|p| p.parse_ty())?;
-                    let span = ident.span.to(self.prev_span);
+                    let span = ident.span.to(self.prev_token.span);
                     let output = self.parse_ret_ty(AllowPlus::No, RecoverQPath::No)?;
                     ParenthesizedArgs { inputs, output, span }.into()
                 };
@@ -412,13 +412,13 @@ fn parse_generic_args(&mut self) -> PResult<'a, (Vec<GenericArg>, Vec<AssocTyCon
                     AssocTyConstraintKind::Equality { ty: self.parse_ty()? }
                 } else if self.eat(&token::Colon) {
                     AssocTyConstraintKind::Bound {
-                        bounds: self.parse_generic_bounds(Some(self.prev_span))?,
+                        bounds: self.parse_generic_bounds(Some(self.prev_token.span))?,
                     }
                 } else {
                     unreachable!();
                 };
 
-                let span = lo.to(self.prev_span);
+                let span = lo.to(self.prev_token.span);
 
                 // Gate associated type bounds, e.g., `Iterator<Item: Ord>`.
                 if let AssocTyConstraintKind::Bound { .. } = kind {
@@ -473,7 +473,7 @@ fn parse_generic_args(&mut self) -> PResult<'a, (Vec<GenericArg>, Vec<AssocTyCon
         // lose that information after parsing.
         if !misplaced_assoc_ty_constraints.is_empty() {
             let mut err = self.struct_span_err(
-                args_lo.to(self.prev_span),
+                args_lo.to(self.prev_token.span),
                 "associated type bindings must be declared after generic parameters",
             );
             for span in misplaced_assoc_ty_constraints {