@@ -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 }
@@ -536,15 +537,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
536537 this. mark_span_with_reason (
537538 DesugaringKind :: TryBlock ,
538539 expr. span ,
539- Some ( this. allow_try_trait . clone ( ) ) ,
540+ Some ( Lrc :: clone ( & this. allow_try_trait ) ) ,
540541 ) ,
541542 expr,
542543 )
543544 } else {
544545 let try_span = this. mark_span_with_reason (
545546 DesugaringKind :: TryBlock ,
546547 this. tcx . sess . source_map ( ) . end_point ( body. span ) ,
547- Some ( this. allow_try_trait . clone ( ) ) ,
548+ Some ( Lrc :: clone ( & this. allow_try_trait ) ) ,
548549 ) ;
549550
550551 ( try_span, this. expr_unit ( try_span) )
@@ -653,7 +654,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
653654 let unstable_span = self . mark_span_with_reason (
654655 DesugaringKind :: Async ,
655656 self . lower_span ( span) ,
656- Some ( self . allow_gen_future . clone ( ) ) ,
657+ Some ( Lrc :: clone ( & self . allow_gen_future ) ) ,
657658 ) ;
658659 let resume_ty =
659660 self . make_lang_item_qpath ( hir:: LangItem :: ResumeTy , unstable_span, None ) ;
@@ -739,7 +740,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
739740 let unstable_span = self . mark_span_with_reason (
740741 DesugaringKind :: Async ,
741742 span,
742- Some ( self . allow_gen_future . clone ( ) ) ,
743+ Some ( Lrc :: clone ( & self . allow_gen_future ) ) ,
743744 ) ;
744745 self . lower_attrs ( inner_hir_id, & [ Attribute {
745746 kind : AttrKind :: Normal ( ptr:: P ( NormalAttr :: from_ident ( Ident :: new (
@@ -815,13 +816,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
815816
816817 let features = match await_kind {
817818 FutureKind :: Future => None ,
818- FutureKind :: AsyncIterator => Some ( self . allow_for_await . clone ( ) ) ,
819+ FutureKind :: AsyncIterator => Some ( Lrc :: clone ( & self . allow_for_await ) ) ,
819820 } ;
820821 let span = self . mark_span_with_reason ( DesugaringKind :: Await , await_kw_span, features) ;
821822 let gen_future_span = self . mark_span_with_reason (
822823 DesugaringKind :: Await ,
823824 full_span,
824- Some ( self . allow_gen_future . clone ( ) ) ,
825+ Some ( Lrc :: clone ( & self . allow_gen_future ) ) ,
825826 ) ;
826827 let expr_hir_id = expr. hir_id ;
827828
@@ -1841,13 +1842,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
18411842 let unstable_span = self . mark_span_with_reason (
18421843 DesugaringKind :: QuestionMark ,
18431844 span,
1844- Some ( self . allow_try_trait . clone ( ) ) ,
1845+ Some ( Lrc :: clone ( & self . allow_try_trait ) ) ,
18451846 ) ;
18461847 let try_span = self . tcx . sess . source_map ( ) . end_point ( span) ;
18471848 let try_span = self . mark_span_with_reason (
18481849 DesugaringKind :: QuestionMark ,
18491850 try_span,
1850- Some ( self . allow_try_trait . clone ( ) ) ,
1851+ Some ( Lrc :: clone ( & self . allow_try_trait ) ) ,
18511852 ) ;
18521853
18531854 // `Try::branch(<expr>)`
@@ -1941,7 +1942,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
19411942 let unstable_span = self . mark_span_with_reason (
19421943 DesugaringKind :: YeetExpr ,
19431944 span,
1944- Some ( self . allow_try_trait . clone ( ) ) ,
1945+ Some ( Lrc :: clone ( & self . allow_try_trait ) ) ,
19451946 ) ;
19461947
19471948 let from_yeet_expr = self . wrap_in_try_constructor (
0 commit comments