@@ -1884,7 +1884,9 @@ impl<'a> Parser<'a> {
1884
1884
Ok ( ( ) )
1885
1885
}
1886
1886
1887
- // Try to recover from associated item paths like `[T]::AssocItem`/`(T, U)::AssocItem`.
1887
+ /// Try to recover from associated item paths like `[T]::AssocItem`/`(T, U)::AssocItem`.
1888
+ /// Attempt to convert the base expression/pattern/type into a type, parse the `::AssocItem`
1889
+ /// tail, and combine them into a `<Ty>::AssocItem` expression/pattern/type.
1888
1890
fn maybe_recover_from_bad_qpath < T : RecoverQPath > ( & mut self , base : P < T > , allow_recovery : bool )
1889
1891
-> PResult < ' a , P < T > > {
1890
1892
// Do not add `::` to expected tokens.
@@ -1896,6 +1898,8 @@ impl<'a> Parser<'a> {
1896
1898
Ok ( base)
1897
1899
}
1898
1900
1901
+ /// Given an already parsed `Ty` parse the `::AssocItem` tail and
1902
+ /// combine them into a `<Ty>::AssocItem` expression/pattern/type.
1899
1903
fn maybe_recover_from_bad_qpath_stage_2 < T : RecoverQPath > ( & mut self , ty_span : Span , ty : P < Ty > )
1900
1904
-> PResult < ' a , P < T > > {
1901
1905
self . expect ( & token:: ModSep ) ?;
@@ -1912,7 +1916,7 @@ impl<'a> Parser<'a> {
1912
1916
path. span , "try" , format ! ( "<{}>::{}" , ty_str, path) , Applicability :: MaybeIncorrect
1913
1917
) . emit ( ) ;
1914
1918
1915
- let path_span = path . span . to ( path . span ) ; // use an empty path since `position` == 0
1919
+ let path_span = ty_span . shrink_to_hi ( ) ; // use an empty path since `position` == 0
1916
1920
Ok ( P ( T :: recovered ( Some ( QSelf { ty, path_span, position : 0 } ) , path) ) )
1917
1921
}
1918
1922
0 commit comments