From 1ab8ca353237470c2587985279d074c1524e90e1 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Tue, 12 Mar 2019 10:37:15 +0300 Subject: Address review comments --- src/libsyntax/parse/parser.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index bc7cb0403ef..cae0be46326 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1884,7 +1884,9 @@ impl<'a> Parser<'a> { 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 `::AssocItem` expression/pattern/type. fn maybe_recover_from_bad_qpath(&mut self, base: P, allow_recovery: bool) -> PResult<'a, P> { // Do not add `::` to expected tokens. @@ -1896,6 +1898,8 @@ impl<'a> Parser<'a> { Ok(base) } + /// Given an already parsed `Ty` parse the `::AssocItem` tail and + /// combine them into a `::AssocItem` expression/pattern/type. fn maybe_recover_from_bad_qpath_stage_2(&mut self, ty_span: Span, ty: P) -> PResult<'a, P> { self.expect(&token::ModSep)?; @@ -1912,7 +1916,7 @@ impl<'a> Parser<'a> { 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))) } -- cgit 1.4.1-3-g733a5