diff options
| author | Alex Burka <aburka@seas.upenn.edu> | 2015-12-14 13:36:45 -0500 |
|---|---|---|
| committer | Alex Burka <aburka@seas.upenn.edu> | 2015-12-14 17:51:52 -0500 |
| commit | e0a526015da284588dba24bf9446636d50bfbf81 (patch) | |
| tree | dff9ba1e707fbc9b42cb41d36c94e38f84fc34dc | |
| parent | 4c0c4e554631b01280d29a0a951fb804e319e7d9 (diff) | |
| download | rust-e0a526015da284588dba24bf9446636d50bfbf81.tar.gz rust-e0a526015da284588dba24bf9446636d50bfbf81.zip | |
evade unused_variables lint in for-loop desugaring
| -rw-r--r-- | src/librustc_front/lowering.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/librustc_front/lowering.rs b/src/librustc_front/lowering.rs index c0b10fb8912..da561a0b322 100644 --- a/src/librustc_front/lowering.rs +++ b/src/librustc_front/lowering.rs @@ -1499,8 +1499,9 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P<hir::Expr> { hir::MatchSource::ForLoopDesugar, None); - // `{ let result = ...; result }` - let result_ident = lctx.str_to_ident("result"); + // `{ let _result = ...; _result }` + // underscore prevents an unused_variables lint if the head diverges + let result_ident = lctx.str_to_ident("_result"); let let_stmt = stmt_let(lctx, e.span, false, result_ident, match_expr, None); let result = expr_ident(lctx, e.span, result_ident, None); let block = block_all(lctx, e.span, vec![let_stmt], Some(result)); |
