Don't always force collect tokens in recover_stmt_local_after_let
.
Use a parameter to decide whether to force collect, as is done for the closely related `parse_local_mk` method.
This commit is contained in:
parent
e69ff1c106
commit
7d7e2a173a
@ -72,6 +72,7 @@ impl<'a> Parser<'a> {
|
|||||||
lo,
|
lo,
|
||||||
attrs,
|
attrs,
|
||||||
errors::InvalidVariableDeclarationSub::MissingLet,
|
errors::InvalidVariableDeclarationSub::MissingLet,
|
||||||
|
force_collect,
|
||||||
)?
|
)?
|
||||||
} else if self.is_kw_followed_by_ident(kw::Auto) && self.may_recover() {
|
} else if self.is_kw_followed_by_ident(kw::Auto) && self.may_recover() {
|
||||||
self.bump(); // `auto`
|
self.bump(); // `auto`
|
||||||
@ -79,6 +80,7 @@ impl<'a> Parser<'a> {
|
|||||||
lo,
|
lo,
|
||||||
attrs,
|
attrs,
|
||||||
errors::InvalidVariableDeclarationSub::UseLetNotAuto,
|
errors::InvalidVariableDeclarationSub::UseLetNotAuto,
|
||||||
|
force_collect,
|
||||||
)?
|
)?
|
||||||
} else if self.is_kw_followed_by_ident(sym::var) && self.may_recover() {
|
} else if self.is_kw_followed_by_ident(sym::var) && self.may_recover() {
|
||||||
self.bump(); // `var`
|
self.bump(); // `var`
|
||||||
@ -86,6 +88,7 @@ impl<'a> Parser<'a> {
|
|||||||
lo,
|
lo,
|
||||||
attrs,
|
attrs,
|
||||||
errors::InvalidVariableDeclarationSub::UseLetNotVar,
|
errors::InvalidVariableDeclarationSub::UseLetNotVar,
|
||||||
|
force_collect,
|
||||||
)?
|
)?
|
||||||
} else if self.check_path()
|
} else if self.check_path()
|
||||||
&& !self.token.is_qpath_start()
|
&& !self.token.is_qpath_start()
|
||||||
@ -231,13 +234,13 @@ impl<'a> Parser<'a> {
|
|||||||
lo: Span,
|
lo: Span,
|
||||||
attrs: AttrWrapper,
|
attrs: AttrWrapper,
|
||||||
subdiagnostic: fn(Span) -> errors::InvalidVariableDeclarationSub,
|
subdiagnostic: fn(Span) -> errors::InvalidVariableDeclarationSub,
|
||||||
|
force_collect: ForceCollect,
|
||||||
) -> PResult<'a, Stmt> {
|
) -> PResult<'a, Stmt> {
|
||||||
let stmt =
|
let stmt = self.collect_tokens_trailing_token(attrs, force_collect, |this, attrs| {
|
||||||
self.collect_tokens_trailing_token(attrs, ForceCollect::Yes, |this, attrs| {
|
let local = this.parse_local(attrs)?;
|
||||||
let local = this.parse_local(attrs)?;
|
// FIXME - maybe capture semicolon in recovery?
|
||||||
// FIXME - maybe capture semicolon in recovery?
|
Ok((this.mk_stmt(lo.to(this.prev_token.span), StmtKind::Let(local)), false))
|
||||||
Ok((this.mk_stmt(lo.to(this.prev_token.span), StmtKind::Let(local)), false))
|
})?;
|
||||||
})?;
|
|
||||||
self.dcx()
|
self.dcx()
|
||||||
.emit_err(errors::InvalidVariableDeclaration { span: lo, sub: subdiagnostic(lo) });
|
.emit_err(errors::InvalidVariableDeclaration { span: lo, sub: subdiagnostic(lo) });
|
||||||
Ok(stmt)
|
Ok(stmt)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user