@@ -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 =
644
645
self . make_lang_item_qpath ( hir:: LangItem :: ResumeTy , unstable_span, None ) ;
@@ -724,7 +725,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
724
725
let unstable_span = self . mark_span_with_reason (
725
726
DesugaringKind :: Async ,
726
727
span,
727
- Some ( self . allow_gen_future . clone ( ) ) ,
728
+ Some ( Lrc :: clone ( & self . allow_gen_future ) ) ,
728
729
) ;
729
730
self . lower_attrs ( inner_hir_id, & [ Attribute {
730
731
kind : AttrKind :: Normal ( ptr:: P ( NormalAttr :: from_ident ( Ident :: new (
@@ -800,13 +801,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
800
801
801
802
let features = match await_kind {
802
803
FutureKind :: Future => None ,
803
- FutureKind :: AsyncIterator => Some ( self . allow_for_await . clone ( ) ) ,
804
+ FutureKind :: AsyncIterator => Some ( Lrc :: clone ( & self . allow_for_await ) ) ,
804
805
} ;
805
806
let span = self . mark_span_with_reason ( DesugaringKind :: Await , await_kw_span, features) ;
806
807
let gen_future_span = self . mark_span_with_reason (
807
808
DesugaringKind :: Await ,
808
809
full_span,
809
- Some ( self . allow_gen_future . clone ( ) ) ,
810
+ Some ( Lrc :: clone ( & self . allow_gen_future ) ) ,
810
811
) ;
811
812
let expr_hir_id = expr. hir_id ;
812
813
@@ -1812,13 +1813,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
1812
1813
let unstable_span = self . mark_span_with_reason (
1813
1814
DesugaringKind :: QuestionMark ,
1814
1815
span,
1815
- Some ( self . allow_try_trait . clone ( ) ) ,
1816
+ Some ( Lrc :: clone ( & self . allow_try_trait ) ) ,
1816
1817
) ;
1817
1818
let try_span = self . tcx . sess . source_map ( ) . end_point ( span) ;
1818
1819
let try_span = self . mark_span_with_reason (
1819
1820
DesugaringKind :: QuestionMark ,
1820
1821
try_span,
1821
- Some ( self . allow_try_trait . clone ( ) ) ,
1822
+ Some ( Lrc :: clone ( & self . allow_try_trait ) ) ,
1822
1823
) ;
1823
1824
1824
1825
// `Try::branch(<expr>)`
@@ -1912,7 +1913,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1912
1913
let unstable_span = self . mark_span_with_reason (
1913
1914
DesugaringKind :: YeetExpr ,
1914
1915
span,
1915
- Some ( self . allow_try_trait . clone ( ) ) ,
1916
+ Some ( Lrc :: clone ( & self . allow_try_trait ) ) ,
1916
1917
) ;
1917
1918
1918
1919
let from_yeet_expr = self . wrap_in_try_constructor (
0 commit comments