@@ -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
}
@@ -521,15 +522,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
521
522
this. mark_span_with_reason (
522
523
DesugaringKind :: TryBlock ,
523
524
expr. span ,
524
- Some ( this. allow_try_trait . clone ( ) ) ,
525
+ Some ( Lrc :: clone ( & this. allow_try_trait ) ) ,
525
526
) ,
526
527
expr,
527
528
)
528
529
} else {
529
530
let try_span = this. mark_span_with_reason (
530
531
DesugaringKind :: TryBlock ,
531
532
this. tcx . sess . source_map ( ) . end_point ( body. span ) ,
532
- Some ( this. allow_try_trait . clone ( ) ) ,
533
+ Some ( Lrc :: clone ( & this. allow_try_trait ) ) ,
533
534
) ;
534
535
535
536
( try_span, this. expr_unit ( try_span) )
@@ -638,7 +639,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
638
639
let unstable_span = self . mark_span_with_reason (
639
640
DesugaringKind :: Async ,
640
641
self . lower_span ( span) ,
641
- Some ( self . allow_gen_future . clone ( ) ) ,
642
+ Some ( Lrc :: clone ( & self . allow_gen_future ) ) ,
642
643
) ;
643
644
let resume_ty = self . make_lang_item_qpath ( hir:: LangItem :: ResumeTy , unstable_span) ;
644
645
let input_ty = hir:: Ty {
@@ -723,7 +724,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
723
724
let unstable_span = self . mark_span_with_reason (
724
725
DesugaringKind :: Async ,
725
726
span,
726
- Some ( self . allow_gen_future . clone ( ) ) ,
727
+ Some ( Lrc :: clone ( & self . allow_gen_future ) ) ,
727
728
) ;
728
729
self . lower_attrs ( inner_hir_id, & [ Attribute {
729
730
kind : AttrKind :: Normal ( ptr:: P ( NormalAttr :: from_ident ( Ident :: new (
@@ -799,13 +800,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
799
800
800
801
let features = match await_kind {
801
802
FutureKind :: Future => None ,
802
- FutureKind :: AsyncIterator => Some ( self . allow_for_await . clone ( ) ) ,
803
+ FutureKind :: AsyncIterator => Some ( Lrc :: clone ( & self . allow_for_await ) ) ,
803
804
} ;
804
805
let span = self . mark_span_with_reason ( DesugaringKind :: Await , await_kw_span, features) ;
805
806
let gen_future_span = self . mark_span_with_reason (
806
807
DesugaringKind :: Await ,
807
808
full_span,
808
- Some ( self . allow_gen_future . clone ( ) ) ,
809
+ Some ( Lrc :: clone ( & self . allow_gen_future ) ) ,
809
810
) ;
810
811
let expr_hir_id = expr. hir_id ;
811
812
@@ -1811,13 +1812,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
1811
1812
let unstable_span = self . mark_span_with_reason (
1812
1813
DesugaringKind :: QuestionMark ,
1813
1814
span,
1814
- Some ( self . allow_try_trait . clone ( ) ) ,
1815
+ Some ( Lrc :: clone ( & self . allow_try_trait ) ) ,
1815
1816
) ;
1816
1817
let try_span = self . tcx . sess . source_map ( ) . end_point ( span) ;
1817
1818
let try_span = self . mark_span_with_reason (
1818
1819
DesugaringKind :: QuestionMark ,
1819
1820
try_span,
1820
- Some ( self . allow_try_trait . clone ( ) ) ,
1821
+ Some ( Lrc :: clone ( & self . allow_try_trait ) ) ,
1821
1822
) ;
1822
1823
1823
1824
// `Try::branch(<expr>)`
@@ -1911,7 +1912,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1911
1912
let unstable_span = self . mark_span_with_reason (
1912
1913
DesugaringKind :: YeetExpr ,
1913
1914
span,
1914
- Some ( self . allow_try_trait . clone ( ) ) ,
1915
+ Some ( Lrc :: clone ( & self . allow_try_trait ) ) ,
1915
1916
) ;
1916
1917
1917
1918
let from_yeet_expr = self . wrap_in_try_constructor (
0 commit comments