Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Mar 12, 2019
1 parent 79c3651 commit 1ab8ca3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/libsyntax/parse/parser.rs
Expand Up @@ -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 `<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.
Expand All @@ -1896,6 +1898,8 @@ impl<'a> Parser<'a> {
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)?;
Expand All @@ -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)))
}

Expand Down

0 comments on commit 1ab8ca3

Please sign in to comment.