@@ -72,7 +72,7 @@ use syntax::symbol::{kw, sym, Symbol};
72
72
use syntax:: tokenstream:: { TokenStream , TokenTree } ;
73
73
use syntax:: parse:: token:: { self , Token } ;
74
74
use syntax:: visit:: { self , Visitor } ;
75
- use syntax_pos:: { DUMMY_SP , Span } ;
75
+ use syntax_pos:: Span ;
76
76
77
77
const HIR_ID_COUNTER_LOCKED : u32 = 0xFFFFFFFF ;
78
78
@@ -322,7 +322,7 @@ enum ParenthesizedGenericArgs {
322
322
/// `resolve_lifetime` module. Often we "fallthrough" to that code by generating
323
323
/// an "elided" or "underscore" lifetime name. In the future, we probably want to move
324
324
/// everything into HIR lowering.
325
- #[ derive( Copy , Clone ) ]
325
+ #[ derive( Copy , Clone , Debug ) ]
326
326
enum AnonymousLifetimeMode {
327
327
/// For **Modern** cases, create a new anonymous region parameter
328
328
/// and reference that.
@@ -715,10 +715,16 @@ impl<'a> LoweringContext<'a> {
715
715
anonymous_lifetime_mode : AnonymousLifetimeMode ,
716
716
op : impl FnOnce ( & mut Self ) -> R ,
717
717
) -> R {
718
+ debug ! (
719
+ "with_anonymous_lifetime_mode(anonymous_lifetime_mode={:?})" ,
720
+ anonymous_lifetime_mode,
721
+ ) ;
718
722
let old_anonymous_lifetime_mode = self . anonymous_lifetime_mode ;
719
723
self . anonymous_lifetime_mode = anonymous_lifetime_mode;
720
724
let result = op ( self ) ;
721
725
self . anonymous_lifetime_mode = old_anonymous_lifetime_mode;
726
+ debug ! ( "with_anonymous_lifetime_mode: restoring anonymous_lifetime_mode={:?}" ,
727
+ old_anonymous_lifetime_mode) ;
722
728
result
723
729
}
724
730
@@ -1033,13 +1039,14 @@ impl<'a> LoweringContext<'a> {
1033
1039
/// ```
1034
1040
///
1035
1041
/// 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) ;
1041
1048
1042
- let kind = match c . kind {
1049
+ let kind = match constraint . kind {
1043
1050
AssocTyConstraintKind :: Equality { ref ty } => hir:: TypeBindingKind :: Equality {
1044
1051
ty : self . lower_ty ( ty, itctx)
1045
1052
} ,
@@ -1094,15 +1101,15 @@ impl<'a> LoweringContext<'a> {
1094
1101
impl_trait_node_id,
1095
1102
DefPathData :: ImplTrait ,
1096
1103
ExpnId :: root ( ) ,
1097
- DUMMY_SP
1104
+ constraint . span ,
1098
1105
) ;
1099
1106
1100
1107
self . with_dyn_type_scope ( false , |this| {
1101
1108
let ty = this. lower_ty (
1102
1109
& Ty {
1103
1110
id : this. sess . next_node_id ( ) ,
1104
1111
node : TyKind :: ImplTrait ( impl_trait_node_id, bounds. clone ( ) ) ,
1105
- span : DUMMY_SP ,
1112
+ span : constraint . span ,
1106
1113
} ,
1107
1114
itctx,
1108
1115
) ;
@@ -1124,10 +1131,10 @@ impl<'a> LoweringContext<'a> {
1124
1131
} ;
1125
1132
1126
1133
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 ,
1129
1136
kind,
1130
- span : c . span ,
1137
+ span : constraint . span ,
1131
1138
}
1132
1139
}
1133
1140
@@ -1355,6 +1362,13 @@ impl<'a> LoweringContext<'a> {
1355
1362
opaque_ty_node_id : NodeId ,
1356
1363
lower_bounds : impl FnOnce ( & mut LoweringContext < ' _ > ) -> hir:: GenericBounds ,
1357
1364
) -> 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
+
1358
1372
// Make sure we know that some funky desugaring has been going on here.
1359
1373
// This is a first: there is code in other places like for loop
1360
1374
// desugaring that explicitly states that we don't want to track that.
@@ -1382,6 +1396,14 @@ impl<'a> LoweringContext<'a> {
1382
1396
& hir_bounds,
1383
1397
) ;
1384
1398
1399
+ debug ! (
1400
+ "lower_opaque_impl_trait: lifetimes={:#?}" , lifetimes,
1401
+ ) ;
1402
+
1403
+ debug ! (
1404
+ "lower_opaque_impl_trait: lifetime_defs={:#?}" , lifetime_defs,
1405
+ ) ;
1406
+
1385
1407
self . with_hir_id_owner ( opaque_ty_node_id, |lctx| {
1386
1408
let opaque_ty_item = hir:: OpaqueTy {
1387
1409
generics : hir:: Generics {
@@ -1397,7 +1419,7 @@ impl<'a> LoweringContext<'a> {
1397
1419
origin : hir:: OpaqueTyOrigin :: FnReturn ,
1398
1420
} ;
1399
1421
1400
- trace ! ( "exist ty from impl trait def-index : {:#?}" , opaque_ty_def_index) ;
1422
+ trace ! ( "lower_opaque_impl_trait : {:#?}" , opaque_ty_def_index) ;
1401
1423
let opaque_ty_id = lctx. generate_opaque_type (
1402
1424
opaque_ty_node_id,
1403
1425
opaque_ty_item,
@@ -1445,6 +1467,13 @@ impl<'a> LoweringContext<'a> {
1445
1467
parent_index : DefIndex ,
1446
1468
bounds : & hir:: GenericBounds ,
1447
1469
) -> ( 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
+
1448
1477
// This visitor walks over `impl Trait` bounds and creates defs for all lifetimes that
1449
1478
// appear in the bounds, excluding lifetimes that are created within the bounds.
1450
1479
// E.g., `'a`, `'b`, but not `'c` in `impl for<'c> SomeTrait<'a, 'b, 'c>`.
@@ -1532,6 +1561,11 @@ impl<'a> LoweringContext<'a> {
1532
1561
}
1533
1562
}
1534
1563
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
+
1535
1569
hir:: LifetimeName :: Error | hir:: LifetimeName :: Static => return ,
1536
1570
} ;
1537
1571
@@ -2182,6 +2216,14 @@ impl<'a> LoweringContext<'a> {
2182
2216
fn_def_id : DefId ,
2183
2217
opaque_ty_node_id : NodeId ,
2184
2218
) -> 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
+
2185
2227
let span = output. span ( ) ;
2186
2228
2187
2229
let opaque_ty_span = self . mark_span_with_reason (
@@ -2264,6 +2306,8 @@ impl<'a> LoweringContext<'a> {
2264
2306
) ,
2265
2307
) ;
2266
2308
2309
+ debug ! ( "lower_async_fn_ret_ty: future_bound={:#?}" , future_bound) ;
2310
+
2267
2311
// Calculate all the lifetimes that should be captured
2268
2312
// by the opaque type. This should include all in-scope
2269
2313
// lifetime parameters, including those defined in-band.
@@ -2512,6 +2556,12 @@ impl<'a> LoweringContext<'a> {
2512
2556
hir:: LifetimeName :: Implicit
2513
2557
| hir:: LifetimeName :: Underscore
2514
2558
| 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
+ }
2515
2565
hir:: LifetimeName :: Error => ParamName :: Error ,
2516
2566
} ;
2517
2567
@@ -3255,7 +3305,13 @@ impl<'a> LoweringContext<'a> {
3255
3305
AnonymousLifetimeMode :: PassThrough => { }
3256
3306
}
3257
3307
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
3259
3315
}
3260
3316
3261
3317
fn new_implicit_lifetime ( & mut self , span : Span ) -> hir:: Lifetime {
0 commit comments