@@ -62,13 +62,14 @@ 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) => {
6869 let mut ex = self . lower_expr_mut ( ex) ;
6970 // Include parens in span, but only if it is a super-span.
7071 if e. span . contains ( ex. span ) {
71- ex. span = self . lower_span ( e. span ) ;
72+ ex. span = self . lower_span ( e. span . with_ctxt ( ex . span . ctxt ( ) ) ) ;
7273 }
7374 // Merge attributes into the inner expression.
7475 if !e. attrs . is_empty ( ) {
@@ -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 }
@@ -1582,14 +1584,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
15821584 )
15831585 } ) )
15841586 . map ( |( s, e) | {
1587+ let span = self . lower_span ( e. span ) ;
1588+ let span = self . mark_span_with_reason ( DesugaringKind :: RangeExpr , span, None ) ;
15851589 let expr = self . lower_expr ( e) ;
1586- let ident = Ident :: new ( s, self . lower_span ( e . span ) ) ;
1587- self . expr_field ( ident, expr, e . span )
1590+ let ident = Ident :: new ( s, span) ;
1591+ self . expr_field ( ident, expr, span)
15881592 } ) ,
15891593 ) ;
15901594
15911595 hir:: ExprKind :: Struct (
1592- self . arena . alloc ( hir:: QPath :: LangItem ( lang_item, self . lower_span ( span) ) ) ,
1596+ self . arena . alloc ( hir:: QPath :: LangItem ( lang_item, span) ) ,
15931597 fields,
15941598 hir:: StructTailExpr :: None ,
15951599 )
0 commit comments