Try to recover from path sep error in parser
This commit is contained in:
parent
d8810e3e2d
commit
0aa2e6b606
10 changed files with 92 additions and 40 deletions
|
@ -246,8 +246,19 @@ impl<'a> Parser<'a> {
|
|||
segments.push(segment);
|
||||
|
||||
if self.is_import_coupler() || !self.eat_path_sep() {
|
||||
if style == PathStyle::Expr
|
||||
&& self.may_recover()
|
||||
let ok_for_recovery = self.may_recover()
|
||||
&& match style {
|
||||
PathStyle::Expr => true,
|
||||
PathStyle::Type if let Some((ident, _)) = self.prev_token.ident() => {
|
||||
self.token == token::Colon
|
||||
&& ident.as_str().chars().all(|c| c.is_lowercase())
|
||||
&& self.token.span.lo() == self.prev_token.span.hi()
|
||||
&& self
|
||||
.look_ahead(1, |token| self.token.span.hi() == token.span.lo())
|
||||
}
|
||||
_ => false,
|
||||
};
|
||||
if ok_for_recovery
|
||||
&& self.token == token::Colon
|
||||
&& self.look_ahead(1, |token| token.is_ident() && !token.is_reserved_ident())
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue