Skip to content

Commit de2e443

Browse files
committed
make parse_async_block conventional
1 parent f6e2bdc commit de2e443

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/librustc_parse/parser/expr.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,7 @@ impl<'a> Parser<'a> {
15561556
fn parse_match_expr(&mut self, mut attrs: AttrVec) -> PResult<'a, P<Expr>> {
15571557
let match_span = self.prev_span;
15581558
let lo = self.prev_span;
1559-
let discriminant = self.parse_expr_res(Restrictions::NO_STRUCT_LITERAL, None)?;
1559+
let scrutinee = self.parse_expr_res(Restrictions::NO_STRUCT_LITERAL, None)?;
15601560
if let Err(mut e) = self.expect(&token::OpenDelim(token::Brace)) {
15611561
if self.token == token::Semi {
15621562
e.span_suggestion_short(
@@ -1582,13 +1582,13 @@ impl<'a> Parser<'a> {
15821582
if self.token == token::CloseDelim(token::Brace) {
15831583
self.bump();
15841584
}
1585-
return Ok(self.mk_expr(span, ExprKind::Match(discriminant, arms), attrs));
1585+
return Ok(self.mk_expr(span, ExprKind::Match(scrutinee, arms), attrs));
15861586
}
15871587
}
15881588
}
15891589
let hi = self.token.span;
15901590
self.bump();
1591-
return Ok(self.mk_expr(lo.to(hi), ExprKind::Match(discriminant, arms), attrs));
1591+
return Ok(self.mk_expr(lo.to(hi), ExprKind::Match(scrutinee, arms), attrs));
15921592
}
15931593

15941594
pub(super) fn parse_arm(&mut self) -> PResult<'a, Arm> {
@@ -1697,16 +1697,13 @@ impl<'a> Parser<'a> {
16971697

16981698
/// Parses an `async move? {...}` expression.
16991699
fn parse_async_block(&mut self, mut attrs: AttrVec) -> PResult<'a, P<Expr>> {
1700-
let span_lo = self.token.span;
1700+
let lo = self.token.span;
17011701
self.expect_keyword(kw::Async)?;
17021702
let capture_clause = self.parse_capture_clause();
17031703
let (iattrs, body) = self.parse_inner_attrs_and_block()?;
17041704
attrs.extend(iattrs);
1705-
Ok(self.mk_expr(
1706-
span_lo.to(body.span),
1707-
ExprKind::Async(capture_clause, DUMMY_NODE_ID, body),
1708-
attrs,
1709-
))
1705+
let kind = ExprKind::Async(capture_clause, DUMMY_NODE_ID, body);
1706+
Ok(self.mk_expr(lo.to(self.prev_span), kind, attrs))
17101707
}
17111708

17121709
fn is_async_block(&self) -> bool {

0 commit comments

Comments
 (0)