]> git.lizzy.rs Git - rust.git/commitdiff
Address review comments
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Tue, 12 Mar 2019 07:37:15 +0000 (10:37 +0300)
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Tue, 12 Mar 2019 07:37:15 +0000 (10:37 +0300)
src/libsyntax/parse/parser.rs

index bc7cb0403ef93fb07ed70e62023d8450fe6bed0c..cae0be463266c051440a3fac5a52bf032f9cf8fa 100644 (file)
@@ -1884,7 +1884,9 @@ fn maybe_recover_from_bad_type_plus(&mut self, allow_plus: bool, ty: &Ty) -> PRe
         Ok(())
     }
 
-    // Try to recover from associated item paths like `[T]::AssocItem`/`(T, U)::AssocItem`.
+    /// Try to recover from associated item paths like `[T]::AssocItem`/`(T, U)::AssocItem`.
+    /// Attempt to convert the base expression/pattern/type into a type, parse the `::AssocItem`
+    /// tail, and combine them into a `<Ty>::AssocItem` expression/pattern/type.
     fn maybe_recover_from_bad_qpath<T: RecoverQPath>(&mut self, base: P<T>, allow_recovery: bool)
                                                      -> PResult<'a, P<T>> {
         // Do not add `::` to expected tokens.
@@ -1896,6 +1898,8 @@ fn maybe_recover_from_bad_qpath<T: RecoverQPath>(&mut self, base: P<T>, allow_re
         Ok(base)
     }
 
+    /// Given an already parsed `Ty` parse the `::AssocItem` tail and
+    /// combine them into a `<Ty>::AssocItem` expression/pattern/type.
     fn maybe_recover_from_bad_qpath_stage_2<T: RecoverQPath>(&mut self, ty_span: Span, ty: P<Ty>)
                                                              -> PResult<'a, P<T>> {
         self.expect(&token::ModSep)?;
@@ -1912,7 +1916,7 @@ fn maybe_recover_from_bad_qpath_stage_2<T: RecoverQPath>(&mut self, ty_span: Spa
                 path.span, "try", format!("<{}>::{}", ty_str, path), Applicability::MaybeIncorrect
             ).emit();
 
-        let path_span = path.span.to(path.span); // use an empty path since `position` == 0
+        let path_span = ty_span.shrink_to_hi(); // use an empty path since `position` == 0
         Ok(P(T::recovered(Some(QSelf { ty, path_span, position: 0 }), path)))
     }