From 602f206408bea967f0f3934d14b918a43a11845d Mon Sep 17 00:00:00 2001 From: flip1995 Date: Fri, 24 Apr 2020 00:22:34 +0200 Subject: [PATCH 1/2] Use correct span on while (let) lowering --- src/librustc_ast_lowering/expr.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/librustc_ast_lowering/expr.rs b/src/librustc_ast_lowering/expr.rs index 0eed47050aa..cbe192d35e5 100644 --- a/src/librustc_ast_lowering/expr.rs +++ b/src/librustc_ast_lowering/expr.rs @@ -397,12 +397,8 @@ impl<'hir> LoweringContext<'_, 'hir> { let then_arm = self.arm(then_pat, self.arena.alloc(then_expr)); // `match { ... }` - let match_expr = self.expr_match( - scrutinee.span, - scrutinee, - arena_vec![self; then_arm, else_arm], - desugar, - ); + let match_expr = + self.expr_match(span, scrutinee, arena_vec![self; then_arm, else_arm], desugar); // `[opt_ident]: loop { ... }` hir::ExprKind::Loop(self.block_expr(self.arena.alloc(match_expr)), opt_label, source) From 898cbf265a1bff978a258b0c63028b2df5d4f6c1 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Fri, 24 Apr 2020 00:22:50 +0200 Subject: [PATCH 2/2] update_tests --- .../rustc.while_loop.PreCodegen.after.mir | 4 ++-- .../block-must-not-have-result-while.stderr | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/test/mir-opt/while-storage/rustc.while_loop.PreCodegen.after.mir b/src/test/mir-opt/while-storage/rustc.while_loop.PreCodegen.after.mir index 0ac7989166e..5d9c1f6b230 100644 --- a/src/test/mir-opt/while-storage/rustc.while_loop.PreCodegen.after.mir +++ b/src/test/mir-opt/while-storage/rustc.while_loop.PreCodegen.after.mir @@ -57,7 +57,7 @@ fn while_loop(_1: bool) -> () { bb5: { StorageDead(_4); // bb5[0]: scope 0 at $DIR/while-storage.rs:14:5: 14:6 - StorageDead(_2); // bb5[1]: scope 0 at $DIR/while-storage.rs:10:21: 10:22 + StorageDead(_2); // bb5[1]: scope 0 at $DIR/while-storage.rs:14:5: 14:6 goto -> bb0; // bb5[2]: scope 0 at $DIR/while-storage.rs:10:5: 14:6 } @@ -74,7 +74,7 @@ fn while_loop(_1: bool) -> () { } bb7: { - StorageDead(_2); // bb7[0]: scope 0 at $DIR/while-storage.rs:10:21: 10:22 + StorageDead(_2); // bb7[0]: scope 0 at $DIR/while-storage.rs:14:5: 14:6 return; // bb7[1]: scope 0 at $DIR/while-storage.rs:15:2: 15:2 } } diff --git a/src/test/ui/block-result/block-must-not-have-result-while.stderr b/src/test/ui/block-result/block-must-not-have-result-while.stderr index 5dabaf5e649..d4845290d8a 100644 --- a/src/test/ui/block-result/block-must-not-have-result-while.stderr +++ b/src/test/ui/block-result/block-must-not-have-result-while.stderr @@ -9,8 +9,14 @@ LL | while true { error[E0308]: mismatched types --> $DIR/block-must-not-have-result-while.rs:3:9 | -LL | true - | ^^^^ expected `()`, found `bool` +LL | / while true { +LL | | true + | | ^^^^ expected `()`, found `bool` +LL | | +LL | | } + | | -- help: consider using a semicolon here + | |_____| + | expected this to be `()` error: aborting due to previous error; 1 warning emitted