@@ -337,6 +337,9 @@ pub struct InferCtxt<'a, 'tcx> {
337
337
/// when we enter into a higher-ranked (`for<..>`) type or trait
338
338
/// bound.
339
339
universe : Cell < ty:: UniverseIndex > ,
340
+
341
+ normalize_fn_sig_for_diagnostic :
342
+ Option < Lrc < dyn Fn ( & InferCtxt < ' _ , ' tcx > , ty:: PolyFnSig < ' tcx > ) -> ty:: PolyFnSig < ' tcx > > > ,
340
343
}
341
344
342
345
/// See the `error_reporting` module for more details.
@@ -540,6 +543,8 @@ pub struct InferCtxtBuilder<'tcx> {
540
543
defining_use_anchor : DefiningAnchor ,
541
544
considering_regions : bool ,
542
545
fresh_typeck_results : Option < RefCell < ty:: TypeckResults < ' tcx > > > ,
546
+ normalize_fn_sig_for_diagnostic :
547
+ Option < Lrc < dyn Fn ( & InferCtxt < ' _ , ' tcx > , ty:: PolyFnSig < ' tcx > ) -> ty:: PolyFnSig < ' tcx > > > ,
543
548
}
544
549
545
550
pub trait TyCtxtInferExt < ' tcx > {
@@ -553,6 +558,7 @@ impl<'tcx> TyCtxtInferExt<'tcx> for TyCtxt<'tcx> {
553
558
defining_use_anchor : DefiningAnchor :: Error ,
554
559
considering_regions : true ,
555
560
fresh_typeck_results : None ,
561
+ normalize_fn_sig_for_diagnostic : None ,
556
562
}
557
563
}
558
564
}
@@ -582,6 +588,14 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
582
588
self
583
589
}
584
590
591
+ pub fn with_normalize_fn_sig_for_diagnostic (
592
+ mut self ,
593
+ fun : Lrc < dyn Fn ( & InferCtxt < ' _ , ' tcx > , ty:: PolyFnSig < ' tcx > ) -> ty:: PolyFnSig < ' tcx > > ,
594
+ ) -> Self {
595
+ self . normalize_fn_sig_for_diagnostic = Some ( fun) ;
596
+ self
597
+ }
598
+
585
599
/// Given a canonical value `C` as a starting point, create an
586
600
/// inference context that contains each of the bound values
587
601
/// within instantiated as a fresh variable. The `f` closure is
@@ -611,6 +625,7 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
611
625
defining_use_anchor,
612
626
considering_regions,
613
627
ref fresh_typeck_results,
628
+ ref normalize_fn_sig_for_diagnostic,
614
629
} = * self ;
615
630
let in_progress_typeck_results = fresh_typeck_results. as_ref ( ) ;
616
631
f ( InferCtxt {
@@ -629,6 +644,9 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
629
644
in_snapshot : Cell :: new ( false ) ,
630
645
skip_leak_check : Cell :: new ( false ) ,
631
646
universe : Cell :: new ( ty:: UniverseIndex :: ROOT ) ,
647
+ normalize_fn_sig_for_diagnostic : normalize_fn_sig_for_diagnostic
648
+ . as_ref ( )
649
+ . map ( |f| f. clone ( ) ) ,
632
650
} )
633
651
}
634
652
}
0 commit comments