11use rustc_infer:: infer:: at:: ToTrace ;
22use rustc_infer:: infer:: type_variable:: { TypeVariableOrigin , TypeVariableOriginKind } ;
3- use rustc_infer:: infer:: { InferCtxt , InferOk } ;
3+ use rustc_infer:: infer:: { InferCtxt , InferOk , LateBoundRegionConversionTime } ;
44use rustc_infer:: traits:: query:: NoSolution ;
55use rustc_infer:: traits:: ObligationCause ;
66use rustc_middle:: infer:: unify_key:: { ConstVariableOrigin , ConstVariableOriginKind } ;
7- use rustc_middle:: ty:: { self , Ty } ;
7+ use rustc_middle:: ty:: { self , Ty , TypeFoldable } ;
88use rustc_span:: DUMMY_SP ;
99
1010use super :: Goal ;
@@ -26,12 +26,10 @@ pub(super) trait InferCtxtExt<'tcx> {
2626 rhs : T ,
2727 ) -> Result < Vec < Goal < ' tcx , ty:: Predicate < ' tcx > > > , NoSolution > ;
2828
29- fn sup < T : ToTrace < ' tcx > > (
29+ fn instantiate_bound_vars_with_infer < T : TypeFoldable < ' tcx > + Copy > (
3030 & self ,
31- param_env : ty:: ParamEnv < ' tcx > ,
32- lhs : T ,
33- rhs : T ,
34- ) -> Result < Vec < Goal < ' tcx , ty:: Predicate < ' tcx > > > , NoSolution > ;
31+ value : ty:: Binder < ' tcx , T > ,
32+ ) -> T ;
3533}
3634
3735impl < ' tcx > InferCtxtExt < ' tcx > for InferCtxt < ' tcx > {
@@ -67,22 +65,14 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
6765 } )
6866 }
6967
70- #[ instrument( level = "debug" , skip( self , param_env) , ret) ]
71- fn sup < T : ToTrace < ' tcx > > (
68+ fn instantiate_bound_vars_with_infer < T : TypeFoldable < ' tcx > + Copy > (
7269 & self ,
73- param_env : ty:: ParamEnv < ' tcx > ,
74- lhs : T ,
75- rhs : T ,
76- ) -> Result < Vec < Goal < ' tcx , ty:: Predicate < ' tcx > > > , NoSolution > {
77- self . at ( & ObligationCause :: dummy ( ) , param_env)
78- . define_opaque_types ( false )
79- . sup ( lhs, rhs)
80- . map ( |InferOk { value : ( ) , obligations } | {
81- obligations. into_iter ( ) . map ( |o| o. into ( ) ) . collect ( )
82- } )
83- . map_err ( |e| {
84- debug ! ( ?e, "failed to sup" ) ;
85- NoSolution
86- } )
70+ value : ty:: Binder < ' tcx , T > ,
71+ ) -> T {
72+ self . replace_bound_vars_with_fresh_vars (
73+ DUMMY_SP ,
74+ LateBoundRegionConversionTime :: HigherRankedType ,
75+ value,
76+ )
8777 }
8878}
0 commit comments