@@ -160,7 +160,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
160160 self . lower_expr_if ( cond, then, else_opt. as_deref ( ) )
161161 }
162162 ExprKind :: While ( cond, body, opt_label) => self . with_loop_scope ( e. id , |this| {
163- let span = this. mark_span_with_reason ( DesugaringKind :: WhileLoop , e. span , None ) ;
163+ let span =
164+ this. tcx . mark_span_with_reason ( DesugaringKind :: WhileLoop , e. span , None ) ;
164165 this. lower_expr_while_in_loop_scope ( span, cond, body, * opt_label)
165166 } ) ,
166167 ExprKind :: Loop ( body, opt_label, span) => self . with_loop_scope ( e. id , |this| {
@@ -448,7 +449,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
448449 _ => {
449450 let cond = self . lower_expr ( cond) ;
450451 let reason = DesugaringKind :: CondTemporary ;
451- let span_block = self . mark_span_with_reason ( reason, cond. span , None ) ;
452+ let span_block = self . tcx . mark_span_with_reason ( reason, cond. span , None ) ;
452453 self . expr_drop_temps ( span_block, cond)
453454 }
454455 }
@@ -501,15 +502,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
501502 // Final expression of the block (if present) or `()` with span at the end of block
502503 let ( try_span, tail_expr) = if let Some ( expr) = block. expr . take ( ) {
503504 (
504- this. mark_span_with_reason (
505+ this. tcx . mark_span_with_reason (
505506 DesugaringKind :: TryBlock ,
506507 expr. span ,
507508 this. allow_try_trait . clone ( ) ,
508509 ) ,
509510 expr,
510511 )
511512 } else {
512- let try_span = this. mark_span_with_reason (
513+ let try_span = this. tcx . mark_span_with_reason (
513514 DesugaringKind :: TryBlock ,
514515 this. tcx . sess . source_map ( ) . end_point ( body. span ) ,
515516 this. allow_try_trait . clone ( ) ,
@@ -519,7 +520,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
519520 } ;
520521
521522 let ok_wrapped_span =
522- this. mark_span_with_reason ( DesugaringKind :: TryBlock , tail_expr. span , None ) ;
523+ this. tcx . mark_span_with_reason ( DesugaringKind :: TryBlock , tail_expr. span , None ) ;
523524
524525 // `::std::ops::Try::from_output($tail_expr)`
525526 block. expr = Some ( this. wrap_in_try_constructor (
@@ -591,8 +592,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
591592 let output = ret_ty. unwrap_or_else ( || hir:: FnRetTy :: DefaultReturn ( self . lower_span ( span) ) ) ;
592593
593594 // Resume argument type: `ResumeTy`
594- let unstable_span =
595- self . mark_span_with_reason ( DesugaringKind :: Async , span, self . allow_gen_future . clone ( ) ) ;
595+ let unstable_span = self . tcx . mark_span_with_reason (
596+ DesugaringKind :: Async ,
597+ span,
598+ self . allow_gen_future . clone ( ) ,
599+ ) ;
596600 let resume_ty = hir:: QPath :: LangItem ( hir:: LangItem :: ResumeTy , unstable_span, None ) ;
597601 let input_ty = hir:: Ty {
598602 hir_id : self . next_id ( ) ,
@@ -661,7 +665,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
661665 && attrs. into_iter ( ) . any ( |attr| attr. has_name ( sym:: track_caller) )
662666 {
663667 let unstable_span =
664- self . mark_span_with_reason ( DesugaringKind :: Async , span, self . allow_gen_future . clone ( ) ) ;
668+ self . tcx . mark_span_with_reason ( DesugaringKind :: Async , span, self . allow_gen_future . clone ( ) ) ;
665669 self . lower_attrs (
666670 inner_hir_id,
667671 & [ Attribute {
@@ -707,8 +711,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
707711 } ) ;
708712 }
709713 }
710- let span = self . mark_span_with_reason ( DesugaringKind :: Await , await_kw_span, None ) ;
711- let gen_future_span = self . mark_span_with_reason (
714+ let span = self . tcx . mark_span_with_reason ( DesugaringKind :: Await , await_kw_span, None ) ;
715+ let gen_future_span = self . tcx . mark_span_with_reason (
712716 DesugaringKind :: Await ,
713717 full_span,
714718 self . allow_gen_future . clone ( ) ,
@@ -1466,9 +1470,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
14661470 let head = self . lower_expr_mut ( head) ;
14671471 let pat = self . lower_pat ( pat) ;
14681472 let for_span =
1469- self . mark_span_with_reason ( DesugaringKind :: ForLoop , self . lower_span ( e. span ) , None ) ;
1470- let head_span = self . mark_span_with_reason ( DesugaringKind :: ForLoop , head. span , None ) ;
1471- let pat_span = self . mark_span_with_reason ( DesugaringKind :: ForLoop , pat. span , None ) ;
1473+ self . tcx . mark_span_with_reason ( DesugaringKind :: ForLoop , self . lower_span ( e. span ) , None ) ;
1474+ let head_span = self . tcx . mark_span_with_reason ( DesugaringKind :: ForLoop , head. span , None ) ;
1475+ let pat_span = self . tcx . mark_span_with_reason ( DesugaringKind :: ForLoop , pat. span , None ) ;
14721476
14731477 // `None => break`
14741478 let none_arm = {
@@ -1562,13 +1566,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
15621566 /// }
15631567 /// ```
15641568 fn lower_expr_try ( & mut self , span : Span , sub_expr : & Expr ) -> hir:: ExprKind < ' hir > {
1565- let unstable_span = self . mark_span_with_reason (
1569+ let unstable_span = self . tcx . mark_span_with_reason (
15661570 DesugaringKind :: QuestionMark ,
15671571 span,
15681572 self . allow_try_trait . clone ( ) ,
15691573 ) ;
15701574 let try_span = self . tcx . sess . source_map ( ) . end_point ( span) ;
1571- let try_span = self . mark_span_with_reason (
1575+ let try_span = self . tcx . mark_span_with_reason (
15721576 DesugaringKind :: QuestionMark ,
15731577 try_span,
15741578 self . allow_try_trait . clone ( ) ,
@@ -1659,10 +1663,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
16591663 let ( yeeted_span, yeeted_expr) = if let Some ( sub_expr) = sub_expr {
16601664 ( sub_expr. span , self . lower_expr ( sub_expr) )
16611665 } else {
1662- ( self . mark_span_with_reason ( DesugaringKind :: YeetExpr , span, None ) , self . expr_unit ( span) )
1666+ (
1667+ self . tcx . mark_span_with_reason ( DesugaringKind :: YeetExpr , span, None ) ,
1668+ self . expr_unit ( span) ,
1669+ )
16631670 } ;
16641671
1665- let unstable_span = self . mark_span_with_reason (
1672+ let unstable_span = self . tcx . mark_span_with_reason (
16661673 DesugaringKind :: YeetExpr ,
16671674 span,
16681675 self . allow_try_trait . clone ( ) ,
0 commit comments