1
1
use rustc_infer:: infer:: at:: ToTrace ;
2
2
use rustc_infer:: infer:: type_variable:: { TypeVariableOrigin , TypeVariableOriginKind } ;
3
- use rustc_infer:: infer:: { InferCtxt , InferOk } ;
3
+ use rustc_infer:: infer:: { InferCtxt , InferOk , LateBoundRegionConversionTime } ;
4
4
use rustc_infer:: traits:: query:: NoSolution ;
5
5
use rustc_infer:: traits:: ObligationCause ;
6
6
use rustc_middle:: infer:: unify_key:: { ConstVariableOrigin , ConstVariableOriginKind } ;
7
- use rustc_middle:: ty:: { self , Ty } ;
7
+ use rustc_middle:: ty:: { self , Ty , TypeFoldable } ;
8
8
use rustc_span:: DUMMY_SP ;
9
9
10
10
use super :: Goal ;
@@ -26,12 +26,10 @@ pub(super) trait InferCtxtExt<'tcx> {
26
26
rhs : T ,
27
27
) -> Result < Vec < Goal < ' tcx , ty:: Predicate < ' tcx > > > , NoSolution > ;
28
28
29
- fn sup < T : ToTrace < ' tcx > > (
29
+ fn instantiate_bound_vars_with_infer < T : TypeFoldable < ' tcx > + Copy > (
30
30
& 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 ;
35
33
}
36
34
37
35
impl < ' tcx > InferCtxtExt < ' tcx > for InferCtxt < ' tcx > {
@@ -67,22 +65,14 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
67
65
} )
68
66
}
69
67
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 > (
72
69
& 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
+ )
87
77
}
88
78
}
0 commit comments