99// except according to those terms.
1010
1111use rustc:: infer:: canonical:: { Canonical , QueryResult } ;
12- use rustc:: infer:: { InferCtxt , InferOk } ;
12+ use rustc:: infer:: InferCtxt ;
1313use rustc:: traits:: query:: type_op:: eq:: Eq ;
1414use rustc:: traits:: query:: type_op:: normalize:: Normalize ;
1515use rustc:: traits:: query:: type_op:: prove_predicate:: ProvePredicate ;
1616use rustc:: traits:: query:: type_op:: subtype:: Subtype ;
1717use rustc:: traits:: query:: { Fallible , NoSolution } ;
18- use rustc:: traits:: { Obligation , Normalized , ObligationCause } ;
18+ use rustc:: traits:: { FulfillmentContext , Normalized , Obligation , ObligationCause , TraitEngine , TraitEngineExt } ;
1919use 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 } ;
2121use rustc_data_structures:: sync:: Lrc ;
2222use std:: fmt;
2323
@@ -39,24 +39,29 @@ fn type_op_eq<'tcx>(
3939 canonicalized : Canonical < ' tcx , ParamEnvAnd < ' tcx , Eq < ' tcx > > > ,
4040) -> Result < Lrc < Canonical < ' tcx , QueryResult < ' tcx , ( ) > > > , NoSolution > {
4141 tcx. infer_ctxt ( )
42- . enter_canonical_trait_query ( & canonicalized, |infcx, key| {
42+ . enter_canonical_trait_query ( & canonicalized, |infcx, fulfill_cx , key| {
4343 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) )
4548 } )
4649}
4750
4851fn type_op_normalize < T > (
4952 infcx : & InferCtxt < ' _ , ' gcx , ' tcx > ,
53+ fulfill_cx : & mut FulfillmentContext < ' tcx > ,
5054 key : ParamEnvAnd < ' tcx , Normalize < T > > ,
51- ) -> Fallible < InferOk < ' tcx , T > >
55+ ) -> Fallible < T >
5256where
5357 T : fmt:: Debug + TypeFoldable < ' tcx > + Lift < ' gcx > ,
5458{
5559 let ( param_env, Normalize { value } ) = key. into_parts ( ) ;
5660 let Normalized { value, obligations } = infcx
5761 . at ( & ObligationCause :: dummy ( ) , param_env)
5862 . 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)
6065}
6166
6267fn type_op_normalize_ty (
@@ -95,30 +100,27 @@ fn type_op_subtype<'tcx>(
95100 tcx : TyCtxt < ' _ , ' tcx , ' tcx > ,
96101 canonicalized : Canonical < ' tcx , ParamEnvAnd < ' tcx , Subtype < ' tcx > > > ,
97102) -> 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| {
100105 let ( param_env, Subtype { sub, sup } ) = key. into_parts ( ) ;
101106 Ok ( infcx
102107 . at ( & ObligationCause :: dummy ( ) , param_env)
103- . sup ( sup, sub) ?)
104- } ,
105- )
108+ . sup ( sup, sub) ?
109+ . into_value_registering_obligations ( infcx , fulfill_cx ) )
110+ } )
106111}
107112
108113fn type_op_prove_predicate < ' tcx > (
109114 tcx : TyCtxt < ' _ , ' tcx , ' tcx > ,
110115 canonicalized : Canonical < ' tcx , ParamEnvAnd < ' tcx , ProvePredicate < ' tcx > > > ,
111116) -> Result < Lrc < Canonical < ' tcx , QueryResult < ' tcx , ( ) > > > , NoSolution > {
112117 tcx. infer_ctxt ( )
113- . enter_canonical_trait_query ( & canonicalized, |_infcx , key| {
118+ . enter_canonical_trait_query ( & canonicalized, |infcx , fulfill_cx , key| {
114119 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 ( ( ) )
123125 } )
124126}
0 commit comments