@@ -337,6 +337,9 @@ pub struct InferCtxt<'a, 'tcx> {
337337 /// when we enter into a higher-ranked (`for<..>`) type or trait
338338 /// bound.
339339 universe : Cell < ty:: UniverseIndex > ,
340+
341+ normalize_fn_sig_for_diagnostic :
342+ Option < Lrc < dyn Fn ( & InferCtxt < ' _ , ' tcx > , ty:: PolyFnSig < ' tcx > ) -> ty:: PolyFnSig < ' tcx > > > ,
340343}
341344
342345/// See the `error_reporting` module for more details.
@@ -540,6 +543,8 @@ pub struct InferCtxtBuilder<'tcx> {
540543 defining_use_anchor : DefiningAnchor ,
541544 considering_regions : bool ,
542545 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 > > > ,
543548}
544549
545550pub trait TyCtxtInferExt < ' tcx > {
@@ -553,6 +558,7 @@ impl<'tcx> TyCtxtInferExt<'tcx> for TyCtxt<'tcx> {
553558 defining_use_anchor : DefiningAnchor :: Error ,
554559 considering_regions : true ,
555560 fresh_typeck_results : None ,
561+ normalize_fn_sig_for_diagnostic : None ,
556562 }
557563 }
558564}
@@ -582,6 +588,14 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
582588 self
583589 }
584590
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+
585599 /// Given a canonical value `C` as a starting point, create an
586600 /// inference context that contains each of the bound values
587601 /// within instantiated as a fresh variable. The `f` closure is
@@ -611,6 +625,7 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
611625 defining_use_anchor,
612626 considering_regions,
613627 ref fresh_typeck_results,
628+ ref normalize_fn_sig_for_diagnostic,
614629 } = * self ;
615630 let in_progress_typeck_results = fresh_typeck_results. as_ref ( ) ;
616631 f ( InferCtxt {
@@ -629,6 +644,9 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
629644 in_snapshot : Cell :: new ( false ) ,
630645 skip_leak_check : Cell :: new ( false ) ,
631646 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 ( ) ) ,
632650 } )
633651 }
634652}
0 commit comments