@@ -151,6 +151,7 @@ enum Scope<'a> {
151
151
s : ScopeRef < ' a > ,
152
152
what : & ' static str ,
153
153
deny_late_regions : bool ,
154
+ deny_late_types_and_consts : bool ,
154
155
} ,
155
156
156
157
Root {
@@ -190,10 +191,11 @@ impl<'a> Scope<'a> {
190
191
. field ( "s" , & ".." )
191
192
. finish ( ) ,
192
193
Self :: TraitRefBoundary { s : _ } => f. debug_struct ( "TraitRefBoundary" ) . finish ( ) ,
193
- Self :: LateBoundary { s : _, what, deny_late_regions } => f
194
+ Self :: LateBoundary { s : _, what, deny_late_regions, deny_late_types_and_consts } => f
194
195
. debug_struct ( "LateBoundary" )
195
196
. field ( "what" , what)
196
197
. field ( "deny_late_regions" , deny_late_regions)
198
+ . field ( "deny_late_types_and_consts" , deny_late_types_and_consts)
197
199
. finish ( ) ,
198
200
Self :: Root { opt_parent_item } => {
199
201
f. debug_struct ( "Root" ) . field ( "opt_parent_item" , & opt_parent_item) . finish ( )
@@ -586,10 +588,9 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
586
588
this. with ( scope, |this| {
587
589
let scope = Scope :: LateBoundary {
588
590
s : this. scope ,
589
- what : "nested `impl Trait`" ,
590
- // We can capture late-bound regions; we just don't duplicate
591
- // lifetime or const params, so we can't allow those.
591
+ what : "associated type bounds" ,
592
592
deny_late_regions : false ,
593
+ deny_late_types_and_consts : false ,
593
594
} ;
594
595
this. with ( scope, |this| intravisit:: walk_opaque_ty ( this, opaque) )
595
596
} )
@@ -809,8 +810,9 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
809
810
self . with ( scope, |this| {
810
811
let scope = Scope :: LateBoundary {
811
812
s : this. scope ,
812
- what : "`impl Trait` in binding" ,
813
- deny_late_regions : true ,
813
+ what : "nested `impl Trait`" ,
814
+ deny_late_regions : false ,
815
+ deny_late_types_and_consts : true ,
814
816
} ;
815
817
this. with ( scope, |this| {
816
818
for bound in bounds {
@@ -999,7 +1001,12 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
999
1001
1000
1002
fn visit_anon_const ( & mut self , c : & ' tcx hir:: AnonConst ) {
1001
1003
self . with (
1002
- Scope :: LateBoundary { s : self . scope , what : "constant" , deny_late_regions : true } ,
1004
+ Scope :: LateBoundary {
1005
+ s : self . scope ,
1006
+ what : "constant" ,
1007
+ deny_late_regions : true ,
1008
+ deny_late_types_and_consts : true ,
1009
+ } ,
1003
1010
|this| {
1004
1011
intravisit:: walk_anon_const ( this, c) ;
1005
1012
} ,
@@ -1298,8 +1305,18 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
1298
1305
scope = s;
1299
1306
}
1300
1307
1301
- Scope :: LateBoundary { s, what, deny_late_regions } => {
1302
- if deny_late_regions {
1308
+ Scope :: LateBoundary {
1309
+ s,
1310
+ what,
1311
+ deny_late_regions : _,
1312
+ deny_late_types_and_consts,
1313
+ } => {
1314
+ // For debugging purposes
1315
+ println ! (
1316
+ "DEBUG: LateBoundary in resolve_type_ref - what: {}, deny_late_types_and_consts: {}" ,
1317
+ what, deny_late_types_and_consts
1318
+ ) ;
1319
+ if deny_late_types_and_consts {
1303
1320
crossed_late_boundary = Some ( what) ;
1304
1321
}
1305
1322
scope = s;
@@ -1518,8 +1535,20 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
1518
1535
scope = s;
1519
1536
}
1520
1537
1521
- Scope :: LateBoundary { s, what, deny_late_regions : _ } => {
1522
- crossed_late_boundary = Some ( what) ;
1538
+ Scope :: LateBoundary {
1539
+ s,
1540
+ what,
1541
+ deny_late_regions : _,
1542
+ deny_late_types_and_consts,
1543
+ } => {
1544
+ // For debugging purposes
1545
+ println ! (
1546
+ "DEBUG: LateBoundary in resolve_type_ref - what: {}, deny_late_types_and_consts: {}" ,
1547
+ what, deny_late_types_and_consts
1548
+ ) ;
1549
+ if deny_late_types_and_consts {
1550
+ crossed_late_boundary = Some ( what) ;
1551
+ }
1523
1552
scope = s;
1524
1553
}
1525
1554
}
@@ -1763,8 +1792,8 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
1763
1792
// trait Foo<'a> {
1764
1793
// type Item: 'a;
1765
1794
// }
1766
- // ```
1767
- //
1795
+ // //
1796
+ //```
1768
1797
// but if we just have `type Item;`, then it would be
1769
1798
// `'static`. However, we don't get all of this logic correct.
1770
1799
//
0 commit comments