@@ -6672,7 +6672,7 @@ pub fn liberate_late_bound_regions<'tcx, T>(
6672
6672
{
6673
6673
replace_late_bound_regions (
6674
6674
tcx, value,
6675
- |br, _ | ty:: ReFree ( ty:: FreeRegion { scope : scope, bound_region : br} ) ) . 0
6675
+ |br| ty:: ReFree ( ty:: FreeRegion { scope : scope, bound_region : br} ) ) . 0
6676
6676
}
6677
6677
6678
6678
pub fn count_late_bound_regions < ' tcx , T > (
@@ -6681,7 +6681,7 @@ pub fn count_late_bound_regions<'tcx, T>(
6681
6681
-> uint
6682
6682
where T : TypeFoldable < ' tcx > + Repr < ' tcx >
6683
6683
{
6684
- let ( _, skol_map) = replace_late_bound_regions ( tcx, value, |_, _ | ty:: ReStatic ) ;
6684
+ let ( _, skol_map) = replace_late_bound_regions ( tcx, value, |_| ty:: ReStatic ) ;
6685
6685
skol_map. len ( )
6686
6686
}
6687
6687
@@ -6712,7 +6712,7 @@ pub fn erase_late_bound_regions<'tcx, T>(
6712
6712
-> T
6713
6713
where T : TypeFoldable < ' tcx > + Repr < ' tcx >
6714
6714
{
6715
- replace_late_bound_regions ( tcx, value, |_, _ | ty:: ReStatic ) . 0
6715
+ replace_late_bound_regions ( tcx, value, |_| ty:: ReStatic ) . 0
6716
6716
}
6717
6717
6718
6718
/// Rewrite any late-bound regions so that they are anonymous. Region numbers are
@@ -6730,9 +6730,9 @@ pub fn anonymize_late_bound_regions<'tcx, T>(
6730
6730
where T : TypeFoldable < ' tcx > + Repr < ' tcx > ,
6731
6731
{
6732
6732
let mut counter = 0 ;
6733
- ty:: Binder ( replace_late_bound_regions ( tcx, sig, |_, db | {
6733
+ ty:: Binder ( replace_late_bound_regions ( tcx, sig, |_| {
6734
6734
counter += 1 ;
6735
- ReLateBound ( db , BrAnon ( counter) )
6735
+ ReLateBound ( ty :: DebruijnIndex :: new ( 1 ) , BrAnon ( counter) )
6736
6736
} ) . 0 )
6737
6737
}
6738
6738
@@ -6743,7 +6743,7 @@ pub fn replace_late_bound_regions<'tcx, T, F>(
6743
6743
mut mapf : F )
6744
6744
-> ( T , FnvHashMap < ty:: BoundRegion , ty:: Region > )
6745
6745
where T : TypeFoldable < ' tcx > + Repr < ' tcx > ,
6746
- F : FnMut ( BoundRegion , DebruijnIndex ) -> ty:: Region ,
6746
+ F : FnMut ( BoundRegion ) -> ty:: Region ,
6747
6747
{
6748
6748
debug ! ( "replace_late_bound_regions({})" , binder. repr( tcx) ) ;
6749
6749
@@ -6755,8 +6755,19 @@ pub fn replace_late_bound_regions<'tcx, T, F>(
6755
6755
debug ! ( "region={}" , region. repr( tcx) ) ;
6756
6756
match region {
6757
6757
ty:: ReLateBound ( debruijn, br) if debruijn. depth == current_depth => {
6758
- * map. entry ( br) . get ( ) . unwrap_or_else (
6759
- |vacant_entry| vacant_entry. insert ( mapf ( br, debruijn) ) )
6758
+ let region =
6759
+ * map. entry ( br) . get ( ) . unwrap_or_else (
6760
+ |vacant_entry| vacant_entry. insert ( mapf ( br) ) ) ;
6761
+
6762
+ if let ty:: ReLateBound ( debruijn1, br) = region {
6763
+ // If the callback returns a late-bound region,
6764
+ // that region should always use depth 1. Then we
6765
+ // adjust it to the correct depth.
6766
+ assert_eq ! ( debruijn1. depth, 1 ) ;
6767
+ ty:: ReLateBound ( debruijn, br)
6768
+ } else {
6769
+ region
6770
+ }
6760
6771
}
6761
6772
_ => {
6762
6773
region
0 commit comments