@@ -4,10 +4,11 @@ use crate::traits::{needs_normalization, BoundVarReplacer, PlaceholderReplacer};
4
4
use rustc_data_structures:: stack:: ensure_sufficient_stack;
5
5
use rustc_infer:: infer:: at:: At ;
6
6
use rustc_infer:: infer:: type_variable:: { TypeVariableOrigin , TypeVariableOriginKind } ;
7
+ use rustc_infer:: infer:: InferCtxt ;
7
8
use rustc_infer:: traits:: TraitEngineExt ;
8
9
use rustc_infer:: traits:: { FulfillmentError , Obligation , TraitEngine } ;
9
10
use rustc_middle:: infer:: unify_key:: { ConstVariableOrigin , ConstVariableOriginKind } ;
10
- use rustc_middle:: traits:: Reveal ;
11
+ use rustc_middle:: traits:: { ObligationCause , Reveal } ;
11
12
use rustc_middle:: ty:: { self , AliasTy , Ty , TyCtxt , UniverseIndex } ;
12
13
use rustc_middle:: ty:: { FallibleTypeFolder , TypeSuperFoldable } ;
13
14
use rustc_middle:: ty:: { TypeFoldable , TypeVisitableExt } ;
@@ -41,6 +42,19 @@ pub(crate) fn deeply_normalize_with_skipped_universes<'tcx, T: TypeFoldable<TyCt
41
42
value. try_fold_with ( & mut folder)
42
43
}
43
44
45
+ // Deeply normalize a value and return it
46
+ pub ( crate ) fn deeply_normalize_for_diagnostics < ' tcx , T : TypeFoldable < TyCtxt < ' tcx > > > (
47
+ infcx : & InferCtxt < ' tcx > ,
48
+ param_env : ty:: ParamEnv < ' tcx > ,
49
+ t : T ,
50
+ ) -> T {
51
+ infcx
52
+ . commit_if_ok ( |_| {
53
+ deeply_normalize ( infcx. at ( & ObligationCause :: dummy ( ) , param_env) , t. clone ( ) )
54
+ } )
55
+ . unwrap_or ( t)
56
+ }
57
+
44
58
struct NormalizationFolder < ' me , ' tcx > {
45
59
at : At < ' me , ' tcx > ,
46
60
fulfill_cx : FulfillmentCtxt < ' tcx > ,
0 commit comments