@@ -377,17 +377,13 @@ pub trait BoundVarReplacerDelegate<'tcx> {
377
377
fn replace_const ( & mut self , bv : ty:: BoundVar , ty : Ty < ' tcx > ) -> ty:: Const < ' tcx > ;
378
378
}
379
379
380
- pub struct FnMutDelegate < R , T , C > {
381
- pub regions : R ,
382
- pub types : T ,
383
- pub consts : C ,
380
+ pub struct FnMutDelegate < ' a , ' tcx > {
381
+ pub regions : & ' a mut ( dyn FnMut ( ty :: BoundRegion ) -> ty :: Region < ' tcx > + ' a ) ,
382
+ pub types : & ' a mut ( dyn FnMut ( ty :: BoundTy ) -> Ty < ' tcx > + ' a ) ,
383
+ pub consts : & ' a mut ( dyn FnMut ( ty :: BoundVar , Ty < ' tcx > ) -> ty :: Const < ' tcx > + ' a ) ,
384
384
}
385
- impl < ' tcx , R , T , C > BoundVarReplacerDelegate < ' tcx > for FnMutDelegate < R , T , C >
386
- where
387
- R : FnMut ( ty:: BoundRegion ) -> ty:: Region < ' tcx > ,
388
- T : FnMut ( ty:: BoundTy ) -> Ty < ' tcx > ,
389
- C : FnMut ( ty:: BoundVar , Ty < ' tcx > ) -> ty:: Const < ' tcx > ,
390
- {
385
+
386
+ impl < ' a , ' tcx > BoundVarReplacerDelegate < ' tcx > for FnMutDelegate < ' a , ' tcx > {
391
387
fn replace_region ( & mut self , br : ty:: BoundRegion ) -> ty:: Region < ' tcx > {
392
388
( self . regions ) ( br)
393
389
}
@@ -511,7 +507,7 @@ impl<'tcx> TyCtxt<'tcx> {
511
507
pub fn replace_late_bound_regions_uncached < T , F > (
512
508
self ,
513
509
value : Binder < ' tcx , T > ,
514
- replace_regions : F ,
510
+ mut replace_regions : F ,
515
511
) -> T
516
512
where
517
513
F : FnMut ( ty:: BoundRegion ) -> ty:: Region < ' tcx > ,
@@ -522,9 +518,9 @@ impl<'tcx> TyCtxt<'tcx> {
522
518
value
523
519
} else {
524
520
let delegate = FnMutDelegate {
525
- regions : replace_regions,
526
- types : |b| bug ! ( "unexpected bound ty in binder: {b:?}" ) ,
527
- consts : |b, ty| bug ! ( "unexpected bound ct in binder: {b:?} {ty}" ) ,
521
+ regions : & mut replace_regions,
522
+ types : & mut |b| bug ! ( "unexpected bound ty in binder: {b:?}" ) ,
523
+ consts : & mut |b, ty| bug ! ( "unexpected bound ct in binder: {b:?} {ty}" ) ,
528
524
} ;
529
525
let mut replacer = BoundVarReplacer :: new ( self , delegate) ;
530
526
value. fold_with ( & mut replacer)
@@ -584,19 +580,19 @@ impl<'tcx> TyCtxt<'tcx> {
584
580
self . replace_escaping_bound_vars_uncached (
585
581
value,
586
582
FnMutDelegate {
587
- regions : |r : ty:: BoundRegion | {
583
+ regions : & mut |r : ty:: BoundRegion | {
588
584
self . mk_region ( ty:: ReLateBound (
589
585
ty:: INNERMOST ,
590
586
ty:: BoundRegion { var : shift_bv ( r. var ) , kind : r. kind } ,
591
587
) )
592
588
} ,
593
- types : |t : ty:: BoundTy | {
589
+ types : & mut |t : ty:: BoundTy | {
594
590
self . mk_ty ( ty:: Bound (
595
591
ty:: INNERMOST ,
596
592
ty:: BoundTy { var : shift_bv ( t. var ) , kind : t. kind } ,
597
593
) )
598
594
} ,
599
- consts : |c, ty : Ty < ' tcx > | {
595
+ consts : & mut |c, ty : Ty < ' tcx > | {
600
596
self . mk_const ( ty:: ConstS {
601
597
kind : ty:: ConstKind :: Bound ( ty:: INNERMOST , shift_bv ( c) ) ,
602
598
ty,
0 commit comments