@@ -4,9 +4,7 @@ use crate::infer::canonical::{
44use crate :: infer:: { InferCtxt , InferOk } ;
55use crate :: traits:: query:: Fallible ;
66use crate :: traits:: ObligationCause ;
7- use rustc_infer:: infer:: canonical:: { Canonical , Certainty } ;
8- use rustc_infer:: traits:: query:: NoSolution ;
9- use rustc_infer:: traits:: PredicateObligations ;
7+ use rustc_infer:: infer:: canonical:: Canonical ;
108use rustc_middle:: ty:: fold:: TypeFoldable ;
119use rustc_middle:: ty:: { ParamEnvAnd , TyCtxt } ;
1210use std:: fmt;
@@ -19,6 +17,7 @@ pub mod implied_outlives_bounds;
1917pub mod normalize;
2018pub mod outlives;
2119pub mod prove_predicate;
20+ use self :: prove_predicate:: ProvePredicate ;
2221pub mod subtype;
2322
2423pub use rustc_middle:: traits:: query:: type_op:: * ;
@@ -81,14 +80,9 @@ pub trait QueryTypeOp<'tcx>: fmt::Debug + Copy + TypeFoldable<'tcx> + 'tcx {
8180 query_key : ParamEnvAnd < ' tcx , Self > ,
8281 infcx : & InferCtxt < ' _ , ' tcx > ,
8382 output_query_region_constraints : & mut QueryRegionConstraints < ' tcx > ,
84- ) -> Fallible < (
85- Self :: QueryResponse ,
86- Option < Canonical < ' tcx , ParamEnvAnd < ' tcx , Self > > > ,
87- PredicateObligations < ' tcx > ,
88- Certainty ,
89- ) > {
83+ ) -> Fallible < ( Self :: QueryResponse , Option < Canonical < ' tcx , ParamEnvAnd < ' tcx , Self > > > ) > {
9084 if let Some ( result) = QueryTypeOp :: try_fast_path ( infcx. tcx , & query_key) {
91- return Ok ( ( result, None , vec ! [ ] , Certainty :: Proven ) ) ;
85+ return Ok ( ( result, None ) ) ;
9286 }
9387
9488 // FIXME(#33684) -- We need to use
@@ -110,7 +104,20 @@ pub trait QueryTypeOp<'tcx>: fmt::Debug + Copy + TypeFoldable<'tcx> + 'tcx {
110104 output_query_region_constraints,
111105 ) ?;
112106
113- Ok ( ( value, Some ( canonical_self) , obligations, canonical_result. value . certainty ) )
107+ // Typically, instantiating NLL query results does not
108+ // create obligations. However, in some cases there
109+ // are unresolved type variables, and unify them *can*
110+ // create obligations. In that case, we have to go
111+ // fulfill them. We do this via a (recursive) query.
112+ for obligation in obligations {
113+ let ( ( ) , _) = ProvePredicate :: fully_perform_into (
114+ obligation. param_env . and ( ProvePredicate :: new ( obligation. predicate ) ) ,
115+ infcx,
116+ output_query_region_constraints,
117+ ) ?;
118+ }
119+
120+ Ok ( ( value, Some ( canonical_self) ) )
114121 }
115122}
116123
@@ -122,39 +129,9 @@ where
122129
123130 fn fully_perform ( self , infcx : & InferCtxt < ' _ , ' tcx > ) -> Fallible < TypeOpOutput < ' tcx , Self > > {
124131 let mut region_constraints = QueryRegionConstraints :: default ( ) ;
125- let ( output, canonicalized_query, mut obligations , _ ) =
132+ let ( output, canonicalized_query) =
126133 Q :: fully_perform_into ( self , infcx, & mut region_constraints) ?;
127134
128- // Typically, instantiating NLL query results does not
129- // create obligations. However, in some cases there
130- // are unresolved type variables, and unify them *can*
131- // create obligations. In that case, we have to go
132- // fulfill them. We do this via a (recursive) query.
133- while !obligations. is_empty ( ) {
134- trace ! ( "{:#?}" , obligations) ;
135- let mut progress = false ;
136- for obligation in std:: mem:: take ( & mut obligations) {
137- let obligation = infcx. resolve_vars_if_possible ( obligation) ;
138- match ProvePredicate :: fully_perform_into (
139- obligation. param_env . and ( ProvePredicate :: new ( obligation. predicate ) ) ,
140- infcx,
141- & mut region_constraints,
142- ) {
143- Ok ( ( ( ) , _, new, certainty) ) => {
144- obligations. extend ( new) ;
145- progress = true ;
146- if let Certainty :: Ambiguous = certainty {
147- obligations. push ( obligation) ;
148- }
149- }
150- Err ( _) => obligations. push ( obligation) ,
151- }
152- }
153- if !progress {
154- return Err ( NoSolution ) ;
155- }
156- }
157-
158135 // Promote the final query-region-constraints into a
159136 // (optional) ref-counted vector:
160137 let region_constraints =
0 commit comments