@@ -303,34 +303,16 @@ struct Canonicalizer<'cx, 'tcx> {
303303 sub_root_lookup_table : SsoHashMap < ty:: TyVid , usize > ,
304304 canonicalize_mode : & ' cx dyn CanonicalizeMode ,
305305 needs_canonical_flags : TypeFlags ,
306-
307- binder_index : ty:: DebruijnIndex ,
308306}
309307
310308impl < ' cx , ' tcx > TypeFolder < TyCtxt < ' tcx > > for Canonicalizer < ' cx , ' tcx > {
311309 fn cx ( & self ) -> TyCtxt < ' tcx > {
312310 self . tcx
313311 }
314312
315- fn fold_binder < T > ( & mut self , t : ty:: Binder < ' tcx , T > ) -> ty:: Binder < ' tcx , T >
316- where
317- T : TypeFoldable < TyCtxt < ' tcx > > ,
318- {
319- self . binder_index . shift_in ( 1 ) ;
320- let t = t. super_fold_with ( self ) ;
321- self . binder_index . shift_out ( 1 ) ;
322- t
323- }
324-
325313 fn fold_region ( & mut self , r : ty:: Region < ' tcx > ) -> ty:: Region < ' tcx > {
326314 match r. kind ( ) {
327- ty:: ReBound ( ty:: BoundVarIndexKind :: Bound ( index) , ..) => {
328- if index >= self . binder_index {
329- bug ! ( "escaping late-bound region during canonicalization" ) ;
330- } else {
331- r
332- }
333- }
315+ ty:: ReBound ( ty:: BoundVarIndexKind :: Bound ( _) , ..) => r,
334316
335317 ty:: ReBound ( ty:: BoundVarIndexKind :: Canonical , _) => {
336318 bug ! ( "canonicalized bound var found during canonicalization" ) ;
@@ -407,13 +389,7 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
407389 self . canonicalize_ty_var ( CanonicalVarKind :: PlaceholderTy ( placeholder) , t)
408390 }
409391
410- ty:: Bound ( ty:: BoundVarIndexKind :: Bound ( debruijn) , _) => {
411- if debruijn >= self . binder_index {
412- bug ! ( "escaping bound type during canonicalization" )
413- } else {
414- t
415- }
416- }
392+ ty:: Bound ( ty:: BoundVarIndexKind :: Bound ( _) , _) => t,
417393
418394 ty:: Bound ( ty:: BoundVarIndexKind :: Canonical , _) => {
419395 bug ! ( "canonicalized bound var found during canonicalization" ) ;
@@ -487,12 +463,8 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
487463 ty:: ConstKind :: Infer ( InferConst :: Fresh ( _) ) => {
488464 bug ! ( "encountered a fresh const during canonicalization" )
489465 }
490- ty:: ConstKind :: Bound ( ty:: BoundVarIndexKind :: Bound ( debruijn) , _) => {
491- if debruijn >= self . binder_index {
492- bug ! ( "escaping bound const during canonicalization" )
493- } else {
494- return ct;
495- }
466+ ty:: ConstKind :: Bound ( ty:: BoundVarIndexKind :: Bound ( _) , _) => {
467+ return ct;
496468 }
497469 ty:: ConstKind :: Bound ( ty:: BoundVarIndexKind :: Canonical , _) => {
498470 bug ! ( "canonicalized bound var found during canonicalization" ) ;
@@ -580,7 +552,6 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
580552 query_state,
581553 indices : FxHashMap :: default ( ) ,
582554 sub_root_lookup_table : Default :: default ( ) ,
583- binder_index : ty:: INNERMOST ,
584555 } ;
585556 if canonicalizer. query_state . var_values . spilled ( ) {
586557 canonicalizer. indices = canonicalizer
0 commit comments