@@ -62,14 +62,14 @@ use syntax::errors;
6262use syntax:: ext:: hygiene:: { Mark , SyntaxContext } ;
6363use syntax:: print:: pprust;
6464use syntax:: ptr:: P ;
65- use syntax:: source_map:: { self , respan, CompilerDesugaringKind , Spanned } ;
65+ use syntax:: source_map:: { self , respan, ExpnInfo , CompilerDesugaringKind , Spanned } ;
6666use syntax:: source_map:: CompilerDesugaringKind :: IfTemporary ;
6767use syntax:: std_inject;
6868use syntax:: symbol:: { kw, sym, Symbol } ;
6969use syntax:: tokenstream:: { TokenStream , TokenTree } ;
7070use syntax:: parse:: token:: { self , Token } ;
7171use syntax:: visit:: { self , Visitor } ;
72- use syntax_pos:: { DUMMY_SP , edition , Span } ;
72+ use syntax_pos:: { DUMMY_SP , Span } ;
7373
7474const HIR_ID_COUNTER_LOCKED : u32 = 0xFFFFFFFF ;
7575
@@ -142,6 +142,9 @@ pub struct LoweringContext<'a> {
142142 current_hir_id_owner : Vec < ( DefIndex , u32 ) > ,
143143 item_local_id_counters : NodeMap < u32 > ,
144144 node_id_to_hir_id : IndexVec < NodeId , hir:: HirId > ,
145+
146+ allow_try_trait : Option < Lrc < [ Symbol ] > > ,
147+ allow_gen_future : Option < Lrc < [ Symbol ] > > ,
145148}
146149
147150pub trait Resolver {
@@ -267,6 +270,8 @@ pub fn lower_crate(
267270 lifetimes_to_define : Vec :: new ( ) ,
268271 is_collecting_in_band_lifetimes : false ,
269272 in_scope_lifetimes : Vec :: new ( ) ,
273+ allow_try_trait : Some ( [ sym:: try_trait] [ ..] . into ( ) ) ,
274+ allow_gen_future : Some ( [ sym:: gen_future] [ ..] . into ( ) ) ,
270275 } . lower_crate ( krate)
271276}
272277
@@ -848,14 +853,10 @@ impl<'a> LoweringContext<'a> {
848853 allow_internal_unstable : Option < Lrc < [ Symbol ] > > ,
849854 ) -> Span {
850855 let mark = Mark :: fresh ( Mark :: root ( ) ) ;
851- mark. set_expn_info ( source_map:: ExpnInfo {
852- call_site : span,
856+ mark. set_expn_info ( ExpnInfo {
853857 def_site : Some ( span) ,
854- format : source_map:: CompilerDesugaring ( reason) ,
855858 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 ( ) )
859860 } ) ;
860861 span. with_ctxt ( SyntaxContext :: empty ( ) . apply_mark ( mark) )
861862 }
@@ -1156,7 +1157,7 @@ impl<'a> LoweringContext<'a> {
11561157 let unstable_span = self . mark_span_with_reason (
11571158 CompilerDesugaringKind :: Async ,
11581159 span,
1159- Some ( vec ! [ sym :: gen_future ] . into ( ) ) ,
1160+ self . allow_gen_future . clone ( ) ,
11601161 ) ;
11611162 let gen_future = self . expr_std_path (
11621163 unstable_span, & [ sym:: future, sym:: from_generator] , None , ThinVec :: new ( ) ) ;
@@ -4382,7 +4383,7 @@ impl<'a> LoweringContext<'a> {
43824383 let unstable_span = this. mark_span_with_reason (
43834384 CompilerDesugaringKind :: TryBlock ,
43844385 body. span ,
4385- Some ( vec ! [ sym :: try_trait ] . into ( ) ) ,
4386+ this . allow_try_trait . clone ( ) ,
43864387 ) ;
43874388 let mut block = this. lower_block ( body, true ) . into_inner ( ) ;
43884389 let tail = block. expr . take ( ) . map_or_else (
@@ -4968,13 +4969,13 @@ impl<'a> LoweringContext<'a> {
49684969 let unstable_span = self . mark_span_with_reason (
49694970 CompilerDesugaringKind :: QuestionMark ,
49704971 e. span ,
4971- Some ( vec ! [ sym :: try_trait ] . into ( ) ) ,
4972+ self . allow_try_trait . clone ( ) ,
49724973 ) ;
49734974 let try_span = self . sess . source_map ( ) . end_point ( e. span ) ;
49744975 let try_span = self . mark_span_with_reason (
49754976 CompilerDesugaringKind :: QuestionMark ,
49764977 try_span,
4977- Some ( vec ! [ sym :: try_trait ] . into ( ) ) ,
4978+ self . allow_try_trait . clone ( ) ,
49784979 ) ;
49794980
49804981 // `Try::into_result(<expr>)`
@@ -5776,7 +5777,7 @@ impl<'a> LoweringContext<'a> {
57765777 let gen_future_span = self . mark_span_with_reason (
57775778 CompilerDesugaringKind :: Await ,
57785779 await_span,
5779- Some ( vec ! [ sym :: gen_future ] . into ( ) ) ,
5780+ self . allow_gen_future . clone ( ) ,
57805781 ) ;
57815782
57825783 // let mut pinned = <expr>;
0 commit comments