@@ -63,13 +63,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
6363
6464 pub ( super ) fn lower_expr_mut ( & mut self , e : & Expr ) -> hir:: Expr < ' hir > {
6565 ensure_sufficient_stack ( || {
66+ let mut span = self . lower_span ( e. span ) ;
6667 match & e. kind {
6768 // Parenthesis expression does not have a HirId and is handled specially.
6869 ExprKind :: Paren ( ex) => {
6970 let mut ex = self . lower_expr_mut ( ex) ;
7071 // Include parens in span, but only if it is a super-span.
7172 if e. span . contains ( ex. span ) {
72- ex. span = self . lower_span ( e. span ) ;
73+ ex. span = self . lower_span ( e. span . with_ctxt ( ex . span . ctxt ( ) ) ) ;
7374 }
7475 // Merge attributes into the inner expression.
7576 if !e. attrs . is_empty ( ) {
@@ -288,7 +289,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
288289 self . lower_span ( * brackets_span) ,
289290 ) ,
290291 ExprKind :: Range ( e1, e2, lims) => {
291- self . lower_expr_range ( e. span , e1. as_deref ( ) , e2. as_deref ( ) , * lims)
292+ span = self . mark_span_with_reason ( DesugaringKind :: RangeExpr , span, None ) ;
293+ self . lower_expr_range ( span, e1. as_deref ( ) , e2. as_deref ( ) , * lims)
292294 }
293295 ExprKind :: Underscore => {
294296 let guar = self . dcx ( ) . emit_err ( UnderscoreExprLhsAssign { span : e. span } ) ;
@@ -380,7 +382,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
380382 ExprKind :: MacCall ( _) => panic ! ( "{:?} shouldn't exist here" , e. span) ,
381383 } ;
382384
383- hir:: Expr { hir_id : expr_hir_id, kind, span : self . lower_span ( e . span ) }
385+ hir:: Expr { hir_id : expr_hir_id, kind, span }
384386 } )
385387 }
386388
@@ -1482,7 +1484,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
14821484 fn lower_expr_range_closed ( & mut self , span : Span , e1 : & Expr , e2 : & Expr ) -> hir:: ExprKind < ' hir > {
14831485 let e1 = self . lower_expr_mut ( e1) ;
14841486 let e2 = self . lower_expr_mut ( e2) ;
1485- let fn_path = hir:: QPath :: LangItem ( hir:: LangItem :: RangeInclusiveNew , self . lower_span ( span) ) ;
1487+ let fn_path = hir:: QPath :: LangItem ( hir:: LangItem :: RangeInclusiveNew , span) ;
14861488 let fn_expr = self . arena . alloc ( self . expr ( span, hir:: ExprKind :: Path ( fn_path) ) ) ;
14871489 hir:: ExprKind :: Call ( fn_expr, arena_vec ! [ self ; e1, e2] )
14881490 }
@@ -1559,14 +1561,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
15591561 )
15601562 } ) )
15611563 . map ( |( s, e) | {
1564+ let span = self . lower_span ( e. span ) ;
1565+ let span = self . mark_span_with_reason ( DesugaringKind :: RangeExpr , span, None ) ;
15621566 let expr = self . lower_expr ( e) ;
1563- let ident = Ident :: new ( s, self . lower_span ( e . span ) ) ;
1564- self . expr_field ( ident, expr, e . span )
1567+ let ident = Ident :: new ( s, span) ;
1568+ self . expr_field ( ident, expr, span)
15651569 } ) ,
15661570 ) ;
15671571
15681572 hir:: ExprKind :: Struct (
1569- self . arena . alloc ( hir:: QPath :: LangItem ( lang_item, self . lower_span ( span) ) ) ,
1573+ self . arena . alloc ( hir:: QPath :: LangItem ( lang_item, span) ) ,
15701574 fields,
15711575 hir:: StructTailExpr :: None ,
15721576 )
0 commit comments