@@ -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 = self . make_lang_item_qpath ( hir:: LangItem :: ResumeTy , unstable_span) ;
644645 let input_ty = hir:: Ty {
@@ -723,7 +724,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
723724 let unstable_span = self . mark_span_with_reason (
724725 DesugaringKind :: Async ,
725726 span,
726- Some ( self . allow_gen_future . clone ( ) ) ,
727+ Some ( Lrc :: clone ( & self . allow_gen_future ) ) ,
727728 ) ;
728729 self . lower_attrs ( inner_hir_id, & [ Attribute {
729730 kind : AttrKind :: Normal ( ptr:: P ( NormalAttr :: from_ident ( Ident :: new (
@@ -799,13 +800,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
799800
800801 let features = match await_kind {
801802 FutureKind :: Future => None ,
802- FutureKind :: AsyncIterator => Some ( self . allow_for_await . clone ( ) ) ,
803+ FutureKind :: AsyncIterator => Some ( Lrc :: clone ( & self . allow_for_await ) ) ,
803804 } ;
804805 let span = self . mark_span_with_reason ( DesugaringKind :: Await , await_kw_span, features) ;
805806 let gen_future_span = self . mark_span_with_reason (
806807 DesugaringKind :: Await ,
807808 full_span,
808- Some ( self . allow_gen_future . clone ( ) ) ,
809+ Some ( Lrc :: clone ( & self . allow_gen_future ) ) ,
809810 ) ;
810811 let expr_hir_id = expr. hir_id ;
811812
@@ -1811,13 +1812,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
18111812 let unstable_span = self . mark_span_with_reason (
18121813 DesugaringKind :: QuestionMark ,
18131814 span,
1814- Some ( self . allow_try_trait . clone ( ) ) ,
1815+ Some ( Lrc :: clone ( & self . allow_try_trait ) ) ,
18151816 ) ;
18161817 let try_span = self . tcx . sess . source_map ( ) . end_point ( span) ;
18171818 let try_span = self . mark_span_with_reason (
18181819 DesugaringKind :: QuestionMark ,
18191820 try_span,
1820- Some ( self . allow_try_trait . clone ( ) ) ,
1821+ Some ( Lrc :: clone ( & self . allow_try_trait ) ) ,
18211822 ) ;
18221823
18231824 // `Try::branch(<expr>)`
@@ -1911,7 +1912,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
19111912 let unstable_span = self . mark_span_with_reason (
19121913 DesugaringKind :: YeetExpr ,
19131914 span,
1914- Some ( self . allow_try_trait . clone ( ) ) ,
1915+ Some ( Lrc :: clone ( & self . allow_try_trait ) ) ,
19151916 ) ;
19161917
19171918 let from_yeet_expr = self . wrap_in_try_constructor (
0 commit comments