@@ -3,6 +3,7 @@ use std::assert_matches::assert_matches;
33use rustc_ast:: ptr:: P as AstP ;
44use rustc_ast:: * ;
55use rustc_data_structures:: stack:: ensure_sufficient_stack;
6+ use rustc_data_structures:: sync:: Lrc ;
67use rustc_hir as hir;
78use rustc_hir:: HirId ;
89use rustc_hir:: def:: { DefKind , Res } ;
@@ -143,7 +144,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
143144 ExprKind :: IncludedBytes ( bytes) => {
144145 let lit = self . arena . alloc ( respan (
145146 self . lower_span ( e. span ) ,
146- LitKind :: ByteStr ( bytes . clone ( ) , StrStyle :: Cooked ) ,
147+ LitKind :: ByteStr ( Lrc :: clone ( bytes ) , StrStyle :: Cooked ) ,
147148 ) ) ;
148149 hir:: ExprKind :: Lit ( lit)
149150 }
@@ -521,15 +522,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
521522 this. mark_span_with_reason (
522523 DesugaringKind :: TryBlock ,
523524 expr. span ,
524- Some ( this. allow_try_trait . clone ( ) ) ,
525+ Some ( Lrc :: clone ( & this. allow_try_trait ) ) ,
525526 ) ,
526527 expr,
527528 )
528529 } else {
529530 let try_span = this. mark_span_with_reason (
530531 DesugaringKind :: TryBlock ,
531532 this. tcx . sess . source_map ( ) . end_point ( body. span ) ,
532- Some ( this. allow_try_trait . clone ( ) ) ,
533+ Some ( Lrc :: clone ( & this. allow_try_trait ) ) ,
533534 ) ;
534535
535536 ( try_span, this. expr_unit ( try_span) )
@@ -638,7 +639,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
638639 let unstable_span = self . mark_span_with_reason (
639640 DesugaringKind :: Async ,
640641 self . lower_span ( span) ,
641- Some ( self . allow_gen_future . clone ( ) ) ,
642+ Some ( Lrc :: clone ( & self . allow_gen_future ) ) ,
642643 ) ;
643644 let resume_ty =
644645 self . make_lang_item_qpath ( hir:: LangItem :: ResumeTy , unstable_span, None ) ;
@@ -724,7 +725,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
724725 let unstable_span = self . mark_span_with_reason (
725726 DesugaringKind :: Async ,
726727 span,
727- Some ( self . allow_gen_future . clone ( ) ) ,
728+ Some ( Lrc :: clone ( & self . allow_gen_future ) ) ,
728729 ) ;
729730 self . lower_attrs ( inner_hir_id, & [ Attribute {
730731 kind : AttrKind :: Normal ( ptr:: P ( NormalAttr :: from_ident ( Ident :: new (
@@ -800,13 +801,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
800801
801802 let features = match await_kind {
802803 FutureKind :: Future => None ,
803- FutureKind :: AsyncIterator => Some ( self . allow_for_await . clone ( ) ) ,
804+ FutureKind :: AsyncIterator => Some ( Lrc :: clone ( & self . allow_for_await ) ) ,
804805 } ;
805806 let span = self . mark_span_with_reason ( DesugaringKind :: Await , await_kw_span, features) ;
806807 let gen_future_span = self . mark_span_with_reason (
807808 DesugaringKind :: Await ,
808809 full_span,
809- Some ( self . allow_gen_future . clone ( ) ) ,
810+ Some ( Lrc :: clone ( & self . allow_gen_future ) ) ,
810811 ) ;
811812 let expr_hir_id = expr. hir_id ;
812813
@@ -1812,13 +1813,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
18121813 let unstable_span = self . mark_span_with_reason (
18131814 DesugaringKind :: QuestionMark ,
18141815 span,
1815- Some ( self . allow_try_trait . clone ( ) ) ,
1816+ Some ( Lrc :: clone ( & self . allow_try_trait ) ) ,
18161817 ) ;
18171818 let try_span = self . tcx . sess . source_map ( ) . end_point ( span) ;
18181819 let try_span = self . mark_span_with_reason (
18191820 DesugaringKind :: QuestionMark ,
18201821 try_span,
1821- Some ( self . allow_try_trait . clone ( ) ) ,
1822+ Some ( Lrc :: clone ( & self . allow_try_trait ) ) ,
18221823 ) ;
18231824
18241825 // `Try::branch(<expr>)`
@@ -1912,7 +1913,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
19121913 let unstable_span = self . mark_span_with_reason (
19131914 DesugaringKind :: YeetExpr ,
19141915 span,
1915- Some ( self . allow_try_trait . clone ( ) ) ,
1916+ Some ( Lrc :: clone ( & self . allow_try_trait ) ) ,
19161917 ) ;
19171918
19181919 let from_yeet_expr = self . wrap_in_try_constructor (
0 commit comments