Skip to content

Commit 281c2fd

Browse files
committed
Inline and remove parse_local_mk.
It has a single use. This makes the `let` handling case in `parse_stmt_without_recovery` more similar to the statement path and statement expression cases.
1 parent 66e5852 commit 281c2fd

File tree

1 file changed

+6
-16
lines changed
  • compiler/rustc_parse/src/parser

1 file changed

+6
-16
lines changed

compiler/rustc_parse/src/parser/stmt.rs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@ impl<'a> Parser<'a> {
6666
}
6767

6868
Ok(Some(if self.token.is_keyword(kw::Let) {
69-
self.parse_local_mk(lo, attrs, capture_semi, force_collect)?
69+
self.collect_tokens_trailing_token(attrs, force_collect, |this, attrs| {
70+
this.expect_keyword(kw::Let)?;
71+
let local = this.parse_local(attrs)?;
72+
let trailing = capture_semi && this.token.kind == token::Semi;
73+
Ok((this.mk_stmt(lo.to(this.prev_token.span), StmtKind::Let(local)), trailing))
74+
})?
7075
} else if self.is_kw_followed_by_ident(kw::Mut) && self.may_recover() {
7176
self.recover_stmt_local_after_let(
7277
lo,
@@ -247,21 +252,6 @@ impl<'a> Parser<'a> {
247252
Ok(stmt)
248253
}
249254

250-
fn parse_local_mk(
251-
&mut self,
252-
lo: Span,
253-
attrs: AttrWrapper,
254-
capture_semi: bool,
255-
force_collect: ForceCollect,
256-
) -> PResult<'a, Stmt> {
257-
self.collect_tokens_trailing_token(attrs, force_collect, |this, attrs| {
258-
this.expect_keyword(kw::Let)?;
259-
let local = this.parse_local(attrs)?;
260-
let trailing = capture_semi && this.token.kind == token::Semi;
261-
Ok((this.mk_stmt(lo.to(this.prev_token.span), StmtKind::Let(local)), trailing))
262-
})
263-
}
264-
265255
/// Parses a local variable declaration.
266256
fn parse_local(&mut self, attrs: AttrVec) -> PResult<'a, P<Local>> {
267257
let lo = self.prev_token.span;

0 commit comments

Comments
 (0)