Skip to content

Commit e8e76b7

Browse files
author
Sasha Pourcelot
committed
Put the expr error inside the closure body
1 parent eabe41c commit e8e76b7

File tree

1 file changed

+2
-3
lines changed
  • compiler/rustc_parse/src/parser

1 file changed

+2
-3
lines changed

compiler/rustc_parse/src/parser/expr.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,7 +1719,7 @@ impl<'a> Parser<'a> {
17191719
let capture_clause = self.parse_capture_clause()?;
17201720
let decl = self.parse_fn_block_decl()?;
17211721
let decl_hi = self.prev_token.span;
1722-
let body = match decl.output {
1722+
let mut body = match decl.output {
17231723
FnRetTy::Default(_) => {
17241724
let restrictions = self.restrictions - Restrictions::STMT_EXPR;
17251725
self.parse_expr_res(restrictions, None)?
@@ -1744,8 +1744,7 @@ impl<'a> Parser<'a> {
17441744
// It is likely that the closure body is a block but where the
17451745
// braces have been removed. We will recover and eat the next
17461746
// statements later in the parsing process.
1747-
1748-
return Ok(self.mk_expr_err(lo.to(body.span)));
1747+
body = self.mk_expr_err(body.span);
17491748
}
17501749

17511750
Ok(self.mk_expr(

0 commit comments

Comments
 (0)