@@ -9,7 +9,7 @@ use rustc_data_structures::thin_vec::ThinVec;
9
9
use rustc_errors:: struct_span_err;
10
10
use rustc_hir as hir;
11
11
use rustc_hir:: def:: Res ;
12
- use rustc_span:: source_map:: { respan, DesugaringKind , ForLoopLoc , Span , Spanned } ;
12
+ use rustc_span:: source_map:: { respan, DesugaringKind , Span , Spanned } ;
13
13
use rustc_span:: symbol:: { sym, Ident , Symbol } ;
14
14
use rustc_target:: asm;
15
15
use std:: collections:: hash_map:: Entry ;
@@ -25,7 +25,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
25
25
}
26
26
27
27
pub ( super ) fn lower_expr_mut ( & mut self , e : & Expr ) -> hir:: Expr < ' hir > {
28
- let mut span = e. span ;
29
28
ensure_sufficient_stack ( || {
30
29
let kind = match e. kind {
31
30
ExprKind :: Box ( ref inner) => hir:: ExprKind :: Box ( self . lower_expr ( inner) ) ,
@@ -54,7 +53,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
54
53
hir:: ExprKind :: MethodCall ( hir_seg, seg. ident . span , args, span)
55
54
}
56
55
ExprKind :: Binary ( binop, ref lhs, ref rhs) => {
57
- span = self . mark_span_with_reason ( DesugaringKind :: Operator , e. span , None ) ;
58
56
let binop = self . lower_binop ( binop) ;
59
57
let lhs = self . lower_expr ( lhs) ;
60
58
let rhs = self . lower_expr ( rhs) ;
@@ -224,7 +222,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
224
222
hir:: Expr {
225
223
hir_id : self . lower_node_id ( e. id ) ,
226
224
kind,
227
- span,
225
+ span : e . span ,
228
226
attrs : e. attrs . iter ( ) . map ( |a| self . lower_attr ( a) ) . collect :: < Vec < _ > > ( ) . into ( ) ,
229
227
}
230
228
} )
@@ -239,7 +237,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
239
237
}
240
238
241
239
fn lower_binop ( & mut self , b : BinOp ) -> hir:: BinOp {
242
- let span = self . mark_span_with_reason ( DesugaringKind :: Operator , b. span , None ) ;
243
240
Spanned {
244
241
node : match b. node {
245
242
BinOpKind :: Add => hir:: BinOpKind :: Add ,
@@ -261,7 +258,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
261
258
BinOpKind :: Ge => hir:: BinOpKind :: Ge ,
262
259
BinOpKind :: Gt => hir:: BinOpKind :: Gt ,
263
260
} ,
264
- span,
261
+ span : b . span ,
265
262
}
266
263
}
267
264
@@ -1363,14 +1360,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
1363
1360
body : & Block ,
1364
1361
opt_label : Option < Label > ,
1365
1362
) -> hir:: Expr < ' hir > {
1366
- let orig_head_span = head. span ;
1367
1363
// expand <head>
1368
1364
let mut head = self . lower_expr_mut ( head) ;
1369
- let desugared_span = self . mark_span_with_reason (
1370
- DesugaringKind :: ForLoop ( ForLoopLoc :: Head ) ,
1371
- orig_head_span,
1372
- None ,
1373
- ) ;
1365
+ let desugared_span = self . mark_span_with_reason ( DesugaringKind :: ForLoop , head. span , None ) ;
1374
1366
head. span = desugared_span;
1375
1367
1376
1368
let iter = Ident :: with_dummy_span ( sym:: iter) ;
@@ -1465,16 +1457,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
1465
1457
// `mut iter => { ... }`
1466
1458
let iter_arm = self . arm ( iter_pat, loop_expr) ;
1467
1459
1468
- let into_iter_span = self . mark_span_with_reason (
1469
- DesugaringKind :: ForLoop ( ForLoopLoc :: IntoIter ) ,
1470
- orig_head_span,
1471
- None ,
1472
- ) ;
1473
-
1474
1460
// `match ::std::iter::IntoIterator::into_iter(<head>) { ... }`
1475
1461
let into_iter_expr = {
1476
1462
let into_iter_path = & [ sym:: iter, sym:: IntoIterator , sym:: into_iter] ;
1477
- self . expr_call_std_path ( into_iter_span , into_iter_path, arena_vec ! [ self ; head] )
1463
+ self . expr_call_std_path ( desugared_span , into_iter_path, arena_vec ! [ self ; head] )
1478
1464
} ;
1479
1465
1480
1466
let match_expr = self . arena . alloc ( self . expr_match (
0 commit comments