@@ -6686,7 +6686,7 @@ pub fn liberate_late_bound_regions<'tcx, T>(
66866686{
66876687 replace_late_bound_regions (
66886688 tcx, value,
6689- |br, _ | ty:: ReFree ( ty:: FreeRegion { scope : scope, bound_region : br} ) ) . 0
6689+ |br| ty:: ReFree ( ty:: FreeRegion { scope : scope, bound_region : br} ) ) . 0
66906690}
66916691
66926692pub fn count_late_bound_regions < ' tcx , T > (
@@ -6695,7 +6695,7 @@ pub fn count_late_bound_regions<'tcx, T>(
66956695 -> uint
66966696 where T : TypeFoldable < ' tcx > + Repr < ' tcx >
66976697{
6698- let ( _, skol_map) = replace_late_bound_regions ( tcx, value, |_, _ | ty:: ReStatic ) ;
6698+ let ( _, skol_map) = replace_late_bound_regions ( tcx, value, |_| ty:: ReStatic ) ;
66996699 skol_map. len ( )
67006700}
67016701
@@ -6726,7 +6726,7 @@ pub fn erase_late_bound_regions<'tcx, T>(
67266726 -> T
67276727 where T : TypeFoldable < ' tcx > + Repr < ' tcx >
67286728{
6729- replace_late_bound_regions ( tcx, value, |_, _ | ty:: ReStatic ) . 0
6729+ replace_late_bound_regions ( tcx, value, |_| ty:: ReStatic ) . 0
67306730}
67316731
67326732/// Rewrite any late-bound regions so that they are anonymous. Region numbers are
@@ -6744,9 +6744,9 @@ pub fn anonymize_late_bound_regions<'tcx, T>(
67446744 where T : TypeFoldable < ' tcx > + Repr < ' tcx > ,
67456745{
67466746 let mut counter = 0 ;
6747- ty:: Binder ( replace_late_bound_regions ( tcx, sig, |_, db | {
6747+ ty:: Binder ( replace_late_bound_regions ( tcx, sig, |_| {
67486748 counter += 1 ;
6749- ReLateBound ( db , BrAnon ( counter) )
6749+ ReLateBound ( ty :: DebruijnIndex :: new ( 1 ) , BrAnon ( counter) )
67506750 } ) . 0 )
67516751}
67526752
@@ -6757,7 +6757,7 @@ pub fn replace_late_bound_regions<'tcx, T, F>(
67576757 mut mapf : F )
67586758 -> ( T , FnvHashMap < ty:: BoundRegion , ty:: Region > )
67596759 where T : TypeFoldable < ' tcx > + Repr < ' tcx > ,
6760- F : FnMut ( BoundRegion , DebruijnIndex ) -> ty:: Region ,
6760+ F : FnMut ( BoundRegion ) -> ty:: Region ,
67616761{
67626762 debug ! ( "replace_late_bound_regions({})" , binder. repr( tcx) ) ;
67636763
@@ -6769,8 +6769,19 @@ pub fn replace_late_bound_regions<'tcx, T, F>(
67696769 debug ! ( "region={}" , region. repr( tcx) ) ;
67706770 match region {
67716771 ty:: ReLateBound ( debruijn, br) if debruijn. depth == current_depth => {
6772- * map. entry ( br) . get ( ) . unwrap_or_else (
6773- |vacant_entry| vacant_entry. insert ( mapf ( br, debruijn) ) )
6772+ let region =
6773+ * map. entry ( br) . get ( ) . unwrap_or_else (
6774+ |vacant_entry| vacant_entry. insert ( mapf ( br) ) ) ;
6775+
6776+ if let ty:: ReLateBound ( debruijn1, br) = region {
6777+ // If the callback returns a late-bound region,
6778+ // that region should always use depth 1. Then we
6779+ // adjust it to the correct depth.
6780+ assert_eq ! ( debruijn1. depth, 1 ) ;
6781+ ty:: ReLateBound ( debruijn, br)
6782+ } else {
6783+ region
6784+ }
67746785 }
67756786 _ => {
67766787 region
0 commit comments