Skip to content

Commit 1ab8ca3

Browse files
committed
Address review comments
1 parent 79c3651 commit 1ab8ca3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/libsyntax/parse/parser.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1884,7 +1884,9 @@ impl<'a> Parser<'a> {
18841884
Ok(())
18851885
}
18861886

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.
18881890
fn maybe_recover_from_bad_qpath<T: RecoverQPath>(&mut self, base: P<T>, allow_recovery: bool)
18891891
-> PResult<'a, P<T>> {
18901892
// Do not add `::` to expected tokens.
@@ -1896,6 +1898,8 @@ impl<'a> Parser<'a> {
18961898
Ok(base)
18971899
}
18981900

1901+
/// Given an already parsed `Ty` parse the `::AssocItem` tail and
1902+
/// combine them into a `<Ty>::AssocItem` expression/pattern/type.
18991903
fn maybe_recover_from_bad_qpath_stage_2<T: RecoverQPath>(&mut self, ty_span: Span, ty: P<Ty>)
19001904
-> PResult<'a, P<T>> {
19011905
self.expect(&token::ModSep)?;
@@ -1912,7 +1916,7 @@ impl<'a> Parser<'a> {
19121916
path.span, "try", format!("<{}>::{}", ty_str, path), Applicability::MaybeIncorrect
19131917
).emit();
19141918

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
19161920
Ok(P(T::recovered(Some(QSelf { ty, path_span, position: 0 }), path)))
19171921
}
19181922

0 commit comments

Comments
 (0)