@@ -62,6 +62,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
6262
6363 pub ( super ) fn lower_expr_mut ( & mut self , e : & Expr ) -> hir:: Expr < ' hir > {
6464 ensure_sufficient_stack ( || {
65+ let mut span = self . lower_span ( e. span ) ;
6566 match & e. kind {
6667 // Parenthesis expression does not have a HirId and is handled specially.
6768 ExprKind :: Paren ( ex) => {
@@ -287,7 +288,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
287288 self . lower_span ( * brackets_span) ,
288289 ) ,
289290 ExprKind :: Range ( e1, e2, lims) => {
290- self . lower_expr_range ( e. span , e1. as_deref ( ) , e2. as_deref ( ) , * lims)
291+ span = self . mark_span_with_reason ( DesugaringKind :: RangeExpr , span, None ) ;
292+ self . lower_expr_range ( span, e1. as_deref ( ) , e2. as_deref ( ) , * lims)
291293 }
292294 ExprKind :: Underscore => {
293295 let guar = self . dcx ( ) . emit_err ( UnderscoreExprLhsAssign { span : e. span } ) ;
@@ -379,7 +381,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
379381 ExprKind :: MacCall ( _) => panic ! ( "{:?} shouldn't exist here" , e. span) ,
380382 } ;
381383
382- hir:: Expr { hir_id : expr_hir_id, kind, span : self . lower_span ( e . span ) }
384+ hir:: Expr { hir_id : expr_hir_id, kind, span }
383385 } )
384386 }
385387
@@ -1505,7 +1507,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
15051507 fn lower_expr_range_closed ( & mut self , span : Span , e1 : & Expr , e2 : & Expr ) -> hir:: ExprKind < ' hir > {
15061508 let e1 = self . lower_expr_mut ( e1) ;
15071509 let e2 = self . lower_expr_mut ( e2) ;
1508- let fn_path = hir:: QPath :: LangItem ( hir:: LangItem :: RangeInclusiveNew , self . lower_span ( span) ) ;
1510+ let fn_path = hir:: QPath :: LangItem ( hir:: LangItem :: RangeInclusiveNew , span) ;
15091511 let fn_expr = self . arena . alloc ( self . expr ( span, hir:: ExprKind :: Path ( fn_path) ) ) ;
15101512 hir:: ExprKind :: Call ( fn_expr, arena_vec ! [ self ; e1, e2] )
15111513 }
@@ -1562,15 +1564,17 @@ impl<'hir> LoweringContext<'_, 'hir> {
15621564 let fields = self . arena . alloc_from_iter (
15631565 e1. iter ( ) . map ( |e| ( sym:: start, e) ) . chain ( e2. iter ( ) . map ( |e| ( sym:: end, e) ) ) . map (
15641566 |( s, e) | {
1567+ let span = self . lower_span ( e. span ) ;
1568+ let span = self . mark_span_with_reason ( DesugaringKind :: RangeExpr , span, None ) ;
15651569 let expr = self . lower_expr ( e) ;
1566- let ident = Ident :: new ( s, self . lower_span ( e . span ) ) ;
1567- self . expr_field ( ident, expr, e . span )
1570+ let ident = Ident :: new ( s, span) ;
1571+ self . expr_field ( ident, expr, span)
15681572 } ,
15691573 ) ,
15701574 ) ;
15711575
15721576 hir:: ExprKind :: Struct (
1573- self . arena . alloc ( hir:: QPath :: LangItem ( lang_item, self . lower_span ( span) ) ) ,
1577+ self . arena . alloc ( hir:: QPath :: LangItem ( lang_item, span) ) ,
15741578 fields,
15751579 hir:: StructTailExpr :: None ,
15761580 )
0 commit comments