@@ -388,17 +388,13 @@ pub trait BoundVarReplacerDelegate<'tcx> {
388
388
fn replace_const ( & mut self , bv : ty:: BoundVar , ty : Ty < ' tcx > ) -> ty:: Const < ' tcx > ;
389
389
}
390
390
391
- pub struct FnMutDelegate < R , T , C > {
392
- pub regions : R ,
393
- pub types : T ,
394
- pub consts : C ,
391
+ pub struct FnMutDelegate < ' a , ' tcx > {
392
+ pub regions : & ' a mut ( dyn FnMut ( ty :: BoundRegion ) -> ty :: Region < ' tcx > + ' a ) ,
393
+ pub types : & ' a mut ( dyn FnMut ( ty :: BoundTy ) -> Ty < ' tcx > + ' a ) ,
394
+ pub consts : & ' a mut ( dyn FnMut ( ty :: BoundVar , Ty < ' tcx > ) -> ty :: Const < ' tcx > + ' a ) ,
395
395
}
396
- impl < ' tcx , R , T , C > BoundVarReplacerDelegate < ' tcx > for FnMutDelegate < R , T , C >
397
- where
398
- R : FnMut ( ty:: BoundRegion ) -> ty:: Region < ' tcx > ,
399
- T : FnMut ( ty:: BoundTy ) -> Ty < ' tcx > ,
400
- C : FnMut ( ty:: BoundVar , Ty < ' tcx > ) -> ty:: Const < ' tcx > ,
401
- {
396
+
397
+ impl < ' a , ' tcx > BoundVarReplacerDelegate < ' tcx > for FnMutDelegate < ' a , ' tcx > {
402
398
fn replace_region ( & mut self , br : ty:: BoundRegion ) -> ty:: Region < ' tcx > {
403
399
( self . regions ) ( br)
404
400
}
@@ -522,7 +518,7 @@ impl<'tcx> TyCtxt<'tcx> {
522
518
pub fn replace_late_bound_regions_uncached < T , F > (
523
519
self ,
524
520
value : Binder < ' tcx , T > ,
525
- replace_regions : F ,
521
+ mut replace_regions : F ,
526
522
) -> T
527
523
where
528
524
F : FnMut ( ty:: BoundRegion ) -> ty:: Region < ' tcx > ,
@@ -533,9 +529,9 @@ impl<'tcx> TyCtxt<'tcx> {
533
529
value
534
530
} else {
535
531
let delegate = FnMutDelegate {
536
- regions : replace_regions,
537
- types : |b| bug ! ( "unexpected bound ty in binder: {b:?}" ) ,
538
- consts : |b, ty| bug ! ( "unexpected bound ct in binder: {b:?} {ty}" ) ,
532
+ regions : & mut replace_regions,
533
+ types : & mut |b| bug ! ( "unexpected bound ty in binder: {b:?}" ) ,
534
+ consts : & mut |b, ty| bug ! ( "unexpected bound ct in binder: {b:?} {ty}" ) ,
539
535
} ;
540
536
let mut replacer = BoundVarReplacer :: new ( self , delegate) ;
541
537
value. fold_with ( & mut replacer)
@@ -595,19 +591,19 @@ impl<'tcx> TyCtxt<'tcx> {
595
591
self . replace_escaping_bound_vars_uncached (
596
592
value,
597
593
FnMutDelegate {
598
- regions : |r : ty:: BoundRegion | {
594
+ regions : & mut |r : ty:: BoundRegion | {
599
595
self . mk_region ( ty:: ReLateBound (
600
596
ty:: INNERMOST ,
601
597
ty:: BoundRegion { var : shift_bv ( r. var ) , kind : r. kind } ,
602
598
) )
603
599
} ,
604
- types : |t : ty:: BoundTy | {
600
+ types : & mut |t : ty:: BoundTy | {
605
601
self . mk_ty ( ty:: Bound (
606
602
ty:: INNERMOST ,
607
603
ty:: BoundTy { var : shift_bv ( t. var ) , kind : t. kind } ,
608
604
) )
609
605
} ,
610
- consts : |c, ty : Ty < ' tcx > | {
606
+ consts : & mut |c, ty : Ty < ' tcx > | {
611
607
self . mk_const ( ty:: ConstS {
612
608
kind : ty:: ConstKind :: Bound ( ty:: INNERMOST , shift_bv ( c) ) ,
613
609
ty,
0 commit comments