9
9
// except according to those terms.
10
10
11
11
use rustc:: infer:: canonical:: { Canonical , QueryResult } ;
12
- use rustc:: infer:: { InferCtxt , InferOk } ;
12
+ use rustc:: infer:: InferCtxt ;
13
13
use rustc:: traits:: query:: type_op:: eq:: Eq ;
14
14
use rustc:: traits:: query:: type_op:: normalize:: Normalize ;
15
15
use rustc:: traits:: query:: type_op:: prove_predicate:: ProvePredicate ;
16
16
use rustc:: traits:: query:: type_op:: subtype:: Subtype ;
17
17
use rustc:: traits:: query:: { Fallible , NoSolution } ;
18
- use rustc:: traits:: { Obligation , Normalized , ObligationCause } ;
18
+ use rustc:: traits:: { FulfillmentContext , Normalized , Obligation , ObligationCause , TraitEngine , TraitEngineExt } ;
19
19
use rustc:: ty:: query:: Providers ;
20
- use rustc:: ty:: { ParamEnvAnd , FnSig , Lift , PolyFnSig , Predicate , Ty , TyCtxt , TypeFoldable } ;
20
+ use rustc:: ty:: { FnSig , Lift , ParamEnvAnd , PolyFnSig , Predicate , Ty , TyCtxt , TypeFoldable } ;
21
21
use rustc_data_structures:: sync:: Lrc ;
22
22
use std:: fmt;
23
23
@@ -39,24 +39,29 @@ fn type_op_eq<'tcx>(
39
39
canonicalized : Canonical < ' tcx , ParamEnvAnd < ' tcx , Eq < ' tcx > > > ,
40
40
) -> Result < Lrc < Canonical < ' tcx , QueryResult < ' tcx , ( ) > > > , NoSolution > {
41
41
tcx. infer_ctxt ( )
42
- . enter_canonical_trait_query ( & canonicalized, |infcx, key| {
42
+ . enter_canonical_trait_query ( & canonicalized, |infcx, fulfill_cx , key| {
43
43
let ( param_env, Eq { a, b } ) = key. into_parts ( ) ;
44
- Ok ( infcx. at ( & ObligationCause :: dummy ( ) , param_env) . eq ( a, b) ?)
44
+ Ok ( infcx
45
+ . at ( & ObligationCause :: dummy ( ) , param_env)
46
+ . eq ( a, b) ?
47
+ . into_value_registering_obligations ( infcx, fulfill_cx) )
45
48
} )
46
49
}
47
50
48
51
fn type_op_normalize < T > (
49
52
infcx : & InferCtxt < ' _ , ' gcx , ' tcx > ,
53
+ fulfill_cx : & mut FulfillmentContext < ' tcx > ,
50
54
key : ParamEnvAnd < ' tcx , Normalize < T > > ,
51
- ) -> Fallible < InferOk < ' tcx , T > >
55
+ ) -> Fallible < T >
52
56
where
53
57
T : fmt:: Debug + TypeFoldable < ' tcx > + Lift < ' gcx > ,
54
58
{
55
59
let ( param_env, Normalize { value } ) = key. into_parts ( ) ;
56
60
let Normalized { value, obligations } = infcx
57
61
. at ( & ObligationCause :: dummy ( ) , param_env)
58
62
. normalize ( & value) ?;
59
- Ok ( InferOk { value, obligations } ) // ugh we should merge these two structs
63
+ fulfill_cx. register_predicate_obligations ( infcx, obligations) ;
64
+ Ok ( value)
60
65
}
61
66
62
67
fn type_op_normalize_ty (
@@ -95,30 +100,27 @@ fn type_op_subtype<'tcx>(
95
100
tcx : TyCtxt < ' _ , ' tcx , ' tcx > ,
96
101
canonicalized : Canonical < ' tcx , ParamEnvAnd < ' tcx , Subtype < ' tcx > > > ,
97
102
) -> Result < Lrc < Canonical < ' tcx , QueryResult < ' tcx , ( ) > > > , NoSolution > {
98
- tcx. infer_ctxt ( ) . enter_canonical_trait_query (
99
- & canonicalized, |infcx, key| {
103
+ tcx. infer_ctxt ( )
104
+ . enter_canonical_trait_query ( & canonicalized, |infcx, fulfill_cx , key| {
100
105
let ( param_env, Subtype { sub, sup } ) = key. into_parts ( ) ;
101
106
Ok ( infcx
102
107
. at ( & ObligationCause :: dummy ( ) , param_env)
103
- . sup ( sup, sub) ?)
104
- } ,
105
- )
108
+ . sup ( sup, sub) ?
109
+ . into_value_registering_obligations ( infcx , fulfill_cx ) )
110
+ } )
106
111
}
107
112
108
113
fn type_op_prove_predicate < ' tcx > (
109
114
tcx : TyCtxt < ' _ , ' tcx , ' tcx > ,
110
115
canonicalized : Canonical < ' tcx , ParamEnvAnd < ' tcx , ProvePredicate < ' tcx > > > ,
111
116
) -> Result < Lrc < Canonical < ' tcx , QueryResult < ' tcx , ( ) > > > , NoSolution > {
112
117
tcx. infer_ctxt ( )
113
- . enter_canonical_trait_query ( & canonicalized, |_infcx , key| {
118
+ . enter_canonical_trait_query ( & canonicalized, |infcx , fulfill_cx , key| {
114
119
let ( param_env, ProvePredicate { predicate } ) = key. into_parts ( ) ;
115
- Ok ( InferOk {
116
- value : ( ) ,
117
- obligations : vec ! [ Obligation :: new(
118
- ObligationCause :: dummy( ) ,
119
- param_env,
120
- predicate,
121
- ) ] ,
122
- } )
120
+ fulfill_cx. register_predicate_obligation (
121
+ infcx,
122
+ Obligation :: new ( ObligationCause :: dummy ( ) , param_env, predicate) ,
123
+ ) ;
124
+ Ok ( ( ) )
123
125
} )
124
126
}
0 commit comments