@@ -72,7 +72,7 @@ use syntax::symbol::{kw, sym, Symbol};
7272use syntax:: tokenstream:: { TokenStream , TokenTree } ;
7373use syntax:: parse:: token:: { self , Token } ;
7474use syntax:: visit:: { self , Visitor } ;
75- use syntax_pos:: { DUMMY_SP , Span } ;
75+ use syntax_pos:: Span ;
7676
7777const HIR_ID_COUNTER_LOCKED : u32 = 0xFFFFFFFF ;
7878
@@ -322,7 +322,7 @@ enum ParenthesizedGenericArgs {
322322/// `resolve_lifetime` module. Often we "fallthrough" to that code by generating
323323/// an "elided" or "underscore" lifetime name. In the future, we probably want to move
324324/// everything into HIR lowering.
325- #[ derive( Copy , Clone ) ]
325+ #[ derive( Copy , Clone , Debug ) ]
326326enum AnonymousLifetimeMode {
327327 /// For **Modern** cases, create a new anonymous region parameter
328328 /// and reference that.
@@ -715,10 +715,16 @@ impl<'a> LoweringContext<'a> {
715715 anonymous_lifetime_mode : AnonymousLifetimeMode ,
716716 op : impl FnOnce ( & mut Self ) -> R ,
717717 ) -> R {
718+ debug ! (
719+ "with_anonymous_lifetime_mode(anonymous_lifetime_mode={:?})" ,
720+ anonymous_lifetime_mode,
721+ ) ;
718722 let old_anonymous_lifetime_mode = self . anonymous_lifetime_mode ;
719723 self . anonymous_lifetime_mode = anonymous_lifetime_mode;
720724 let result = op ( self ) ;
721725 self . anonymous_lifetime_mode = old_anonymous_lifetime_mode;
726+ debug ! ( "with_anonymous_lifetime_mode: restoring anonymous_lifetime_mode={:?}" ,
727+ old_anonymous_lifetime_mode) ;
722728 result
723729 }
724730
@@ -1033,13 +1039,14 @@ impl<'a> LoweringContext<'a> {
10331039 /// ```
10341040 ///
10351041 /// returns a `hir::TypeBinding` representing `Item`.
1036- fn lower_assoc_ty_constraint ( & mut self ,
1037- c : & AssocTyConstraint ,
1038- itctx : ImplTraitContext < ' _ > )
1039- -> hir:: TypeBinding {
1040- debug ! ( "lower_assoc_ty_constraint(constraint={:?}, itctx={:?})" , c, itctx) ;
1042+ fn lower_assoc_ty_constraint (
1043+ & mut self ,
1044+ constraint : & AssocTyConstraint ,
1045+ itctx : ImplTraitContext < ' _ > ,
1046+ ) -> hir:: TypeBinding {
1047+ debug ! ( "lower_assoc_ty_constraint(constraint={:?}, itctx={:?})" , constraint, itctx) ;
10411048
1042- let kind = match c . kind {
1049+ let kind = match constraint . kind {
10431050 AssocTyConstraintKind :: Equality { ref ty } => hir:: TypeBindingKind :: Equality {
10441051 ty : self . lower_ty ( ty, itctx)
10451052 } ,
@@ -1094,15 +1101,15 @@ impl<'a> LoweringContext<'a> {
10941101 impl_trait_node_id,
10951102 DefPathData :: ImplTrait ,
10961103 ExpnId :: root ( ) ,
1097- DUMMY_SP
1104+ constraint . span ,
10981105 ) ;
10991106
11001107 self . with_dyn_type_scope ( false , |this| {
11011108 let ty = this. lower_ty (
11021109 & Ty {
11031110 id : this. sess . next_node_id ( ) ,
11041111 node : TyKind :: ImplTrait ( impl_trait_node_id, bounds. clone ( ) ) ,
1105- span : DUMMY_SP ,
1112+ span : constraint . span ,
11061113 } ,
11071114 itctx,
11081115 ) ;
@@ -1124,10 +1131,10 @@ impl<'a> LoweringContext<'a> {
11241131 } ;
11251132
11261133 hir:: TypeBinding {
1127- hir_id : self . lower_node_id ( c . id ) ,
1128- ident : c . ident ,
1134+ hir_id : self . lower_node_id ( constraint . id ) ,
1135+ ident : constraint . ident ,
11291136 kind,
1130- span : c . span ,
1137+ span : constraint . span ,
11311138 }
11321139 }
11331140
@@ -1355,6 +1362,13 @@ impl<'a> LoweringContext<'a> {
13551362 opaque_ty_node_id : NodeId ,
13561363 lower_bounds : impl FnOnce ( & mut LoweringContext < ' _ > ) -> hir:: GenericBounds ,
13571364 ) -> hir:: TyKind {
1365+ debug ! (
1366+ "lower_opaque_impl_trait(fn_def_id={:?}, opaque_ty_node_id={:?}, span={:?})" ,
1367+ fn_def_id,
1368+ opaque_ty_node_id,
1369+ span,
1370+ ) ;
1371+
13581372 // Make sure we know that some funky desugaring has been going on here.
13591373 // This is a first: there is code in other places like for loop
13601374 // desugaring that explicitly states that we don't want to track that.
@@ -1382,6 +1396,14 @@ impl<'a> LoweringContext<'a> {
13821396 & hir_bounds,
13831397 ) ;
13841398
1399+ debug ! (
1400+ "lower_opaque_impl_trait: lifetimes={:#?}" , lifetimes,
1401+ ) ;
1402+
1403+ debug ! (
1404+ "lower_opaque_impl_trait: lifetime_defs={:#?}" , lifetime_defs,
1405+ ) ;
1406+
13851407 self . with_hir_id_owner ( opaque_ty_node_id, |lctx| {
13861408 let opaque_ty_item = hir:: OpaqueTy {
13871409 generics : hir:: Generics {
@@ -1397,7 +1419,7 @@ impl<'a> LoweringContext<'a> {
13971419 origin : hir:: OpaqueTyOrigin :: FnReturn ,
13981420 } ;
13991421
1400- trace ! ( "exist ty from impl trait def-index : {:#?}" , opaque_ty_def_index) ;
1422+ trace ! ( "lower_opaque_impl_trait : {:#?}" , opaque_ty_def_index) ;
14011423 let opaque_ty_id = lctx. generate_opaque_type (
14021424 opaque_ty_node_id,
14031425 opaque_ty_item,
@@ -1445,6 +1467,13 @@ impl<'a> LoweringContext<'a> {
14451467 parent_index : DefIndex ,
14461468 bounds : & hir:: GenericBounds ,
14471469 ) -> ( HirVec < hir:: GenericArg > , HirVec < hir:: GenericParam > ) {
1470+ debug ! (
1471+ "lifetimes_from_impl_trait_bounds(opaque_ty_id={:?}, \
1472+ parent_index={:?}, \
1473+ bounds={:#?})",
1474+ opaque_ty_id, parent_index, bounds,
1475+ ) ;
1476+
14481477 // This visitor walks over `impl Trait` bounds and creates defs for all lifetimes that
14491478 // appear in the bounds, excluding lifetimes that are created within the bounds.
14501479 // E.g., `'a`, `'b`, but not `'c` in `impl for<'c> SomeTrait<'a, 'b, 'c>`.
@@ -1532,6 +1561,11 @@ impl<'a> LoweringContext<'a> {
15321561 }
15331562 }
15341563 hir:: LifetimeName :: Param ( _) => lifetime. name ,
1564+
1565+ // Refers to some other lifetime that is "in
1566+ // scope" within the type.
1567+ hir:: LifetimeName :: ImplicitObjectLifetimeDefault => return ,
1568+
15351569 hir:: LifetimeName :: Error | hir:: LifetimeName :: Static => return ,
15361570 } ;
15371571
@@ -2182,6 +2216,14 @@ impl<'a> LoweringContext<'a> {
21822216 fn_def_id : DefId ,
21832217 opaque_ty_node_id : NodeId ,
21842218 ) -> hir:: FunctionRetTy {
2219+ debug ! (
2220+ "lower_async_fn_ret_ty(\
2221+ output={:?}, \
2222+ fn_def_id={:?}, \
2223+ opaque_ty_node_id={:?})",
2224+ output, fn_def_id, opaque_ty_node_id,
2225+ ) ;
2226+
21852227 let span = output. span ( ) ;
21862228
21872229 let opaque_ty_span = self . mark_span_with_reason (
@@ -2264,6 +2306,8 @@ impl<'a> LoweringContext<'a> {
22642306 ) ,
22652307 ) ;
22662308
2309+ debug ! ( "lower_async_fn_ret_ty: future_bound={:#?}" , future_bound) ;
2310+
22672311 // Calculate all the lifetimes that should be captured
22682312 // by the opaque type. This should include all in-scope
22692313 // lifetime parameters, including those defined in-band.
@@ -2512,6 +2556,12 @@ impl<'a> LoweringContext<'a> {
25122556 hir:: LifetimeName :: Implicit
25132557 | hir:: LifetimeName :: Underscore
25142558 | hir:: LifetimeName :: Static => hir:: ParamName :: Plain ( lt. name . ident ( ) ) ,
2559+ hir:: LifetimeName :: ImplicitObjectLifetimeDefault => {
2560+ span_bug ! (
2561+ param. ident. span,
2562+ "object-lifetime-default should not occur here" ,
2563+ ) ;
2564+ }
25152565 hir:: LifetimeName :: Error => ParamName :: Error ,
25162566 } ;
25172567
@@ -3255,7 +3305,13 @@ impl<'a> LoweringContext<'a> {
32553305 AnonymousLifetimeMode :: PassThrough => { }
32563306 }
32573307
3258- self . new_implicit_lifetime ( span)
3308+ let r = hir:: Lifetime {
3309+ hir_id : self . next_id ( ) ,
3310+ span,
3311+ name : hir:: LifetimeName :: ImplicitObjectLifetimeDefault ,
3312+ } ;
3313+ debug ! ( "elided_dyn_bound: r={:?}" , r) ;
3314+ r
32593315 }
32603316
32613317 fn new_implicit_lifetime ( & mut self , span : Span ) -> hir:: Lifetime {
0 commit comments