Skip to content

Commit e0a5260

Browse files
committed
evade unused_variables lint in for-loop desugaring
1 parent 4c0c4e5 commit e0a5260

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/librustc_front/lowering.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1499,8 +1499,9 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P<hir::Expr> {
14991499
hir::MatchSource::ForLoopDesugar,
15001500
None);
15011501

1502-
// `{ let result = ...; result }`
1503-
let result_ident = lctx.str_to_ident("result");
1502+
// `{ let _result = ...; _result }`
1503+
// underscore prevents an unused_variables lint if the head diverges
1504+
let result_ident = lctx.str_to_ident("_result");
15041505
let let_stmt = stmt_let(lctx, e.span, false, result_ident, match_expr, None);
15051506
let result = expr_ident(lctx, e.span, result_ident, None);
15061507
let block = block_all(lctx, e.span, vec![let_stmt], Some(result));

0 commit comments

Comments
 (0)