@@ -9,7 +9,7 @@ use rustc_data_structures::thin_vec::ThinVec;
99use rustc_errors:: struct_span_err;
1010use rustc_hir as hir;
1111use 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 } ;
1313use rustc_span:: symbol:: { sym, Ident , Symbol } ;
1414use rustc_target:: asm;
1515use std:: collections:: hash_map:: Entry ;
@@ -25,7 +25,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
2525 }
2626
2727 pub ( super ) fn lower_expr_mut ( & mut self , e : & Expr ) -> hir:: Expr < ' hir > {
28- let mut span = e. span ;
2928 ensure_sufficient_stack ( || {
3029 let kind = match e. kind {
3130 ExprKind :: Box ( ref inner) => hir:: ExprKind :: Box ( self . lower_expr ( inner) ) ,
@@ -54,7 +53,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
5453 hir:: ExprKind :: MethodCall ( hir_seg, seg. ident . span , args, span)
5554 }
5655 ExprKind :: Binary ( binop, ref lhs, ref rhs) => {
57- span = self . mark_span_with_reason ( DesugaringKind :: Operator , e. span , None ) ;
5856 let binop = self . lower_binop ( binop) ;
5957 let lhs = self . lower_expr ( lhs) ;
6058 let rhs = self . lower_expr ( rhs) ;
@@ -224,7 +222,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
224222 hir:: Expr {
225223 hir_id : self . lower_node_id ( e. id ) ,
226224 kind,
227- span,
225+ span : e . span ,
228226 attrs : e. attrs . iter ( ) . map ( |a| self . lower_attr ( a) ) . collect :: < Vec < _ > > ( ) . into ( ) ,
229227 }
230228 } )
@@ -239,7 +237,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
239237 }
240238
241239 fn lower_binop ( & mut self , b : BinOp ) -> hir:: BinOp {
242- let span = self . mark_span_with_reason ( DesugaringKind :: Operator , b. span , None ) ;
243240 Spanned {
244241 node : match b. node {
245242 BinOpKind :: Add => hir:: BinOpKind :: Add ,
@@ -261,7 +258,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
261258 BinOpKind :: Ge => hir:: BinOpKind :: Ge ,
262259 BinOpKind :: Gt => hir:: BinOpKind :: Gt ,
263260 } ,
264- span,
261+ span : b . span ,
265262 }
266263 }
267264
@@ -1363,14 +1360,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
13631360 body : & Block ,
13641361 opt_label : Option < Label > ,
13651362 ) -> hir:: Expr < ' hir > {
1366- let orig_head_span = head. span ;
13671363 // expand <head>
13681364 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 ) ;
13741366 head. span = desugared_span;
13751367
13761368 let iter = Ident :: with_dummy_span ( sym:: iter) ;
@@ -1465,16 +1457,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
14651457 // `mut iter => { ... }`
14661458 let iter_arm = self . arm ( iter_pat, loop_expr) ;
14671459
1468- let into_iter_span = self . mark_span_with_reason (
1469- DesugaringKind :: ForLoop ( ForLoopLoc :: IntoIter ) ,
1470- orig_head_span,
1471- None ,
1472- ) ;
1473-
14741460 // `match ::std::iter::IntoIterator::into_iter(<head>) { ... }`
14751461 let into_iter_expr = {
14761462 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] )
14781464 } ;
14791465
14801466 let match_expr = self . arena . alloc ( self . expr_match (
0 commit comments