@@ -3,6 +3,7 @@ use std::assert_matches::assert_matches;
3
3
use rustc_ast:: ptr:: P as AstP ;
4
4
use rustc_ast:: * ;
5
5
use rustc_data_structures:: stack:: ensure_sufficient_stack;
6
+ use rustc_data_structures:: sync:: Lrc ;
6
7
use rustc_hir as hir;
7
8
use rustc_hir:: HirId ;
8
9
use rustc_hir:: def:: { DefKind , Res } ;
@@ -143,7 +144,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
143
144
ExprKind :: IncludedBytes ( bytes) => {
144
145
let lit = self . arena . alloc ( respan (
145
146
self . lower_span ( e. span ) ,
146
- LitKind :: ByteStr ( bytes . clone ( ) , StrStyle :: Cooked ) ,
147
+ LitKind :: ByteStr ( Lrc :: clone ( bytes ) , StrStyle :: Cooked ) ,
147
148
) ) ;
148
149
hir:: ExprKind :: Lit ( lit)
149
150
}
@@ -536,15 +537,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
536
537
this. mark_span_with_reason (
537
538
DesugaringKind :: TryBlock ,
538
539
expr. span ,
539
- Some ( this. allow_try_trait . clone ( ) ) ,
540
+ Some ( Lrc :: clone ( & this. allow_try_trait ) ) ,
540
541
) ,
541
542
expr,
542
543
)
543
544
} else {
544
545
let try_span = this. mark_span_with_reason (
545
546
DesugaringKind :: TryBlock ,
546
547
this. tcx . sess . source_map ( ) . end_point ( body. span ) ,
547
- Some ( this. allow_try_trait . clone ( ) ) ,
548
+ Some ( Lrc :: clone ( & this. allow_try_trait ) ) ,
548
549
) ;
549
550
550
551
( try_span, this. expr_unit ( try_span) )
@@ -653,7 +654,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
653
654
let unstable_span = self . mark_span_with_reason (
654
655
DesugaringKind :: Async ,
655
656
self . lower_span ( span) ,
656
- Some ( self . allow_gen_future . clone ( ) ) ,
657
+ Some ( Lrc :: clone ( & self . allow_gen_future ) ) ,
657
658
) ;
658
659
let resume_ty =
659
660
self . make_lang_item_qpath ( hir:: LangItem :: ResumeTy , unstable_span, None ) ;
@@ -739,7 +740,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
739
740
let unstable_span = self . mark_span_with_reason (
740
741
DesugaringKind :: Async ,
741
742
span,
742
- Some ( self . allow_gen_future . clone ( ) ) ,
743
+ Some ( Lrc :: clone ( & self . allow_gen_future ) ) ,
743
744
) ;
744
745
self . lower_attrs ( inner_hir_id, & [ Attribute {
745
746
kind : AttrKind :: Normal ( ptr:: P ( NormalAttr :: from_ident ( Ident :: new (
@@ -815,13 +816,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
815
816
816
817
let features = match await_kind {
817
818
FutureKind :: Future => None ,
818
- FutureKind :: AsyncIterator => Some ( self . allow_for_await . clone ( ) ) ,
819
+ FutureKind :: AsyncIterator => Some ( Lrc :: clone ( & self . allow_for_await ) ) ,
819
820
} ;
820
821
let span = self . mark_span_with_reason ( DesugaringKind :: Await , await_kw_span, features) ;
821
822
let gen_future_span = self . mark_span_with_reason (
822
823
DesugaringKind :: Await ,
823
824
full_span,
824
- Some ( self . allow_gen_future . clone ( ) ) ,
825
+ Some ( Lrc :: clone ( & self . allow_gen_future ) ) ,
825
826
) ;
826
827
let expr_hir_id = expr. hir_id ;
827
828
@@ -1841,13 +1842,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
1841
1842
let unstable_span = self . mark_span_with_reason (
1842
1843
DesugaringKind :: QuestionMark ,
1843
1844
span,
1844
- Some ( self . allow_try_trait . clone ( ) ) ,
1845
+ Some ( Lrc :: clone ( & self . allow_try_trait ) ) ,
1845
1846
) ;
1846
1847
let try_span = self . tcx . sess . source_map ( ) . end_point ( span) ;
1847
1848
let try_span = self . mark_span_with_reason (
1848
1849
DesugaringKind :: QuestionMark ,
1849
1850
try_span,
1850
- Some ( self . allow_try_trait . clone ( ) ) ,
1851
+ Some ( Lrc :: clone ( & self . allow_try_trait ) ) ,
1851
1852
) ;
1852
1853
1853
1854
// `Try::branch(<expr>)`
@@ -1941,7 +1942,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1941
1942
let unstable_span = self . mark_span_with_reason (
1942
1943
DesugaringKind :: YeetExpr ,
1943
1944
span,
1944
- Some ( self . allow_try_trait . clone ( ) ) ,
1945
+ Some ( Lrc :: clone ( & self . allow_try_trait ) ) ,
1945
1946
) ;
1946
1947
1947
1948
let from_yeet_expr = self . wrap_in_try_constructor (
0 commit comments