@@ -62,14 +62,14 @@ use syntax::errors;
62
62
use syntax:: ext:: hygiene:: { Mark , SyntaxContext } ;
63
63
use syntax:: print:: pprust;
64
64
use syntax:: ptr:: P ;
65
- use syntax:: source_map:: { self , respan, CompilerDesugaringKind , Spanned } ;
65
+ use syntax:: source_map:: { self , respan, ExpnInfo , CompilerDesugaringKind , Spanned } ;
66
66
use syntax:: source_map:: CompilerDesugaringKind :: IfTemporary ;
67
67
use syntax:: std_inject;
68
68
use syntax:: symbol:: { kw, sym, Symbol } ;
69
69
use syntax:: tokenstream:: { TokenStream , TokenTree } ;
70
70
use syntax:: parse:: token:: { self , Token } ;
71
71
use syntax:: visit:: { self , Visitor } ;
72
- use syntax_pos:: { DUMMY_SP , edition , Span } ;
72
+ use syntax_pos:: { DUMMY_SP , Span } ;
73
73
74
74
const HIR_ID_COUNTER_LOCKED : u32 = 0xFFFFFFFF ;
75
75
@@ -142,6 +142,9 @@ pub struct LoweringContext<'a> {
142
142
current_hir_id_owner : Vec < ( DefIndex , u32 ) > ,
143
143
item_local_id_counters : NodeMap < u32 > ,
144
144
node_id_to_hir_id : IndexVec < NodeId , hir:: HirId > ,
145
+
146
+ allow_try_trait : Option < Lrc < [ Symbol ] > > ,
147
+ allow_gen_future : Option < Lrc < [ Symbol ] > > ,
145
148
}
146
149
147
150
pub trait Resolver {
@@ -267,6 +270,8 @@ pub fn lower_crate(
267
270
lifetimes_to_define : Vec :: new ( ) ,
268
271
is_collecting_in_band_lifetimes : false ,
269
272
in_scope_lifetimes : Vec :: new ( ) ,
273
+ allow_try_trait : Some ( [ sym:: try_trait] [ ..] . into ( ) ) ,
274
+ allow_gen_future : Some ( [ sym:: gen_future] [ ..] . into ( ) ) ,
270
275
} . lower_crate ( krate)
271
276
}
272
277
@@ -848,14 +853,10 @@ impl<'a> LoweringContext<'a> {
848
853
allow_internal_unstable : Option < Lrc < [ Symbol ] > > ,
849
854
) -> Span {
850
855
let mark = Mark :: fresh ( Mark :: root ( ) ) ;
851
- mark. set_expn_info ( source_map:: ExpnInfo {
852
- call_site : span,
856
+ mark. set_expn_info ( ExpnInfo {
853
857
def_site : Some ( span) ,
854
- format : source_map:: CompilerDesugaring ( reason) ,
855
858
allow_internal_unstable,
856
- allow_internal_unsafe : false ,
857
- local_inner_macros : false ,
858
- edition : edition:: Edition :: from_session ( ) ,
859
+ ..ExpnInfo :: default ( source_map:: CompilerDesugaring ( reason) , span, self . sess . edition ( ) )
859
860
} ) ;
860
861
span. with_ctxt ( SyntaxContext :: empty ( ) . apply_mark ( mark) )
861
862
}
@@ -1156,7 +1157,7 @@ impl<'a> LoweringContext<'a> {
1156
1157
let unstable_span = self . mark_span_with_reason (
1157
1158
CompilerDesugaringKind :: Async ,
1158
1159
span,
1159
- Some ( vec ! [ sym :: gen_future ] . into ( ) ) ,
1160
+ self . allow_gen_future . clone ( ) ,
1160
1161
) ;
1161
1162
let gen_future = self . expr_std_path (
1162
1163
unstable_span, & [ sym:: future, sym:: from_generator] , None , ThinVec :: new ( ) ) ;
@@ -4382,7 +4383,7 @@ impl<'a> LoweringContext<'a> {
4382
4383
let unstable_span = this. mark_span_with_reason (
4383
4384
CompilerDesugaringKind :: TryBlock ,
4384
4385
body. span ,
4385
- Some ( vec ! [ sym :: try_trait ] . into ( ) ) ,
4386
+ this . allow_try_trait . clone ( ) ,
4386
4387
) ;
4387
4388
let mut block = this. lower_block ( body, true ) . into_inner ( ) ;
4388
4389
let tail = block. expr . take ( ) . map_or_else (
@@ -4968,13 +4969,13 @@ impl<'a> LoweringContext<'a> {
4968
4969
let unstable_span = self . mark_span_with_reason (
4969
4970
CompilerDesugaringKind :: QuestionMark ,
4970
4971
e. span ,
4971
- Some ( vec ! [ sym :: try_trait ] . into ( ) ) ,
4972
+ self . allow_try_trait . clone ( ) ,
4972
4973
) ;
4973
4974
let try_span = self . sess . source_map ( ) . end_point ( e. span ) ;
4974
4975
let try_span = self . mark_span_with_reason (
4975
4976
CompilerDesugaringKind :: QuestionMark ,
4976
4977
try_span,
4977
- Some ( vec ! [ sym :: try_trait ] . into ( ) ) ,
4978
+ self . allow_try_trait . clone ( ) ,
4978
4979
) ;
4979
4980
4980
4981
// `Try::into_result(<expr>)`
@@ -5776,7 +5777,7 @@ impl<'a> LoweringContext<'a> {
5776
5777
let gen_future_span = self . mark_span_with_reason (
5777
5778
CompilerDesugaringKind :: Await ,
5778
5779
await_span,
5779
- Some ( vec ! [ sym :: gen_future ] . into ( ) ) ,
5780
+ self . allow_gen_future . clone ( ) ,
5780
5781
) ;
5781
5782
5782
5783
// let mut pinned = <expr>;
0 commit comments