Move colon-check to recover_colon_before_qpath_proj()
This commit is contained in:
parent
88d64a0931
commit
45fb7232ab
1 changed files with 23 additions and 15 deletions
|
@ -71,7 +71,21 @@ impl<'a> Parser<'a> {
|
||||||
debug!("parse_qpath: (decrement) count={:?}", self.unmatched_angle_bracket_count);
|
debug!("parse_qpath: (decrement) count={:?}", self.unmatched_angle_bracket_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.token.kind == token::Colon {
|
if !self.recover_colon_before_qpath_proj() {
|
||||||
|
self.expect(&token::ModSep)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
let qself = QSelf { ty, path_span, position: path.segments.len() };
|
||||||
|
self.parse_path_segments(&mut path.segments, style)?;
|
||||||
|
|
||||||
|
Ok((qself, Path { segments: path.segments, span: lo.to(self.prev_span) }))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn recover_colon_before_qpath_proj(&mut self) -> bool {
|
||||||
|
if self.token.kind != token::Colon {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// <Bar as Baz<T>>:Qux
|
// <Bar as Baz<T>>:Qux
|
||||||
// ^
|
// ^
|
||||||
self.bump();
|
self.bump();
|
||||||
|
@ -85,14 +99,8 @@ impl<'a> Parser<'a> {
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
} else {
|
|
||||||
self.expect(&token::ModSep)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
let qself = QSelf { ty, path_span, position: path.segments.len() };
|
true
|
||||||
self.parse_path_segments(&mut path.segments, style)?;
|
|
||||||
|
|
||||||
Ok((qself, Path { segments: path.segments, span: lo.to(self.prev_span) }))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parses simple paths.
|
/// Parses simple paths.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue