1919
2020use std:: mem;
2121
22- use rustc_infer:: infer:: canonical:: OriginalQueryValues ;
23- use rustc_infer:: infer:: { InferCtxt , TyCtxtInferExt } ;
22+ use rustc_infer:: infer:: canonical:: { OriginalQueryValues , QueryRegionConstraints , QueryResponse } ;
23+ use rustc_infer:: infer:: { InferCtxt , InferOk , TyCtxtInferExt } ;
2424use rustc_infer:: traits:: query:: NoSolution ;
2525use rustc_infer:: traits:: Obligation ;
26+ use rustc_middle:: infer:: canonical:: Certainty as OldCertainty ;
2627use rustc_middle:: infer:: canonical:: { Canonical , CanonicalVarValues } ;
2728use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
2829use rustc_middle:: ty:: { RegionOutlivesPredicate , ToPredicate , TypeOutlivesPredicate } ;
2930use rustc_span:: DUMMY_SP ;
3031
32+ use crate :: traits:: ObligationCause ;
33+
34+ use self :: cache:: response_no_constraints;
3135use self :: infcx_ext:: InferCtxtExt ;
3236
3337mod assembly;
@@ -119,7 +123,7 @@ pub enum MaybeCause {
119123}
120124
121125/// Additional constraints returned on success.
122- #[ derive( Debug , PartialEq , Eq , Clone , Hash , TypeFoldable , TypeVisitable ) ]
126+ #[ derive( Debug , PartialEq , Eq , Clone , Hash , TypeFoldable , TypeVisitable , Default ) ]
123127pub struct ExternalConstraints < ' tcx > {
124128 // FIXME: implement this.
125129 regions : ( ) ,
@@ -175,7 +179,7 @@ impl<'tcx> EvalCtxt<'tcx> {
175179 let canonical_response = self . evaluate_canonical_goal ( canonical_goal) ?;
176180 Ok ( (
177181 true , // FIXME: check whether `var_values` are an identity substitution.
178- fixme_instantiate_canonical_query_response ( infcx, & orig_values, canonical_response) ,
182+ instantiate_canonical_query_response ( infcx, & orig_values, canonical_response) ,
179183 ) )
180184 }
181185
@@ -208,7 +212,8 @@ impl<'tcx> EvalCtxt<'tcx> {
208212 // of `PredicateKind` this is the case and it is and faster than instantiating and
209213 // recanonicalizing.
210214 let Goal { param_env, predicate } = canonical_goal. value ;
211- if let Some ( kind) = predicate. kind ( ) . no_bound_vars ( ) {
215+
216+ if let Some ( kind) = predicate. kind ( ) . no_bound_vars_ignoring_escaping ( self . tcx ) {
212217 match kind {
213218 ty:: PredicateKind :: Clause ( ty:: Clause :: Trait ( predicate) ) => self . compute_trait_goal (
214219 canonical_goal. unchecked_rebind ( Goal { param_env, predicate } ) ,
@@ -234,7 +239,10 @@ impl<'tcx> EvalCtxt<'tcx> {
234239 | ty:: PredicateKind :: ConstEvaluatable ( _)
235240 | ty:: PredicateKind :: ConstEquate ( _, _)
236241 | ty:: PredicateKind :: TypeWellFormedFromEnv ( _)
237- | ty:: PredicateKind :: Ambiguous => unimplemented ! ( ) ,
242+ | ty:: PredicateKind :: Ambiguous => {
243+ // FIXME
244+ response_no_constraints ( self . tcx , canonical_goal, Certainty :: Yes )
245+ }
238246 }
239247 } else {
240248 let ( infcx, goal, var_values) =
@@ -248,16 +256,18 @@ impl<'tcx> EvalCtxt<'tcx> {
248256
249257 fn compute_type_outlives_goal (
250258 & mut self ,
251- _goal : CanonicalGoal < ' tcx , TypeOutlivesPredicate < ' tcx > > ,
259+ goal : CanonicalGoal < ' tcx , TypeOutlivesPredicate < ' tcx > > ,
252260 ) -> QueryResult < ' tcx > {
253- todo ! ( )
261+ // FIXME
262+ response_no_constraints ( self . tcx , goal, Certainty :: Yes )
254263 }
255264
256265 fn compute_region_outlives_goal (
257266 & mut self ,
258- _goal : CanonicalGoal < ' tcx , RegionOutlivesPredicate < ' tcx > > ,
267+ goal : CanonicalGoal < ' tcx , RegionOutlivesPredicate < ' tcx > > ,
259268 ) -> QueryResult < ' tcx > {
260- todo ! ( )
269+ // FIXME
270+ response_no_constraints ( self . tcx , goal, Certainty :: Yes )
261271 }
262272}
263273
@@ -300,10 +310,27 @@ impl<'tcx> EvalCtxt<'tcx> {
300310 }
301311}
302312
303- fn fixme_instantiate_canonical_query_response < ' tcx > (
304- _ : & InferCtxt < ' tcx > ,
305- _ : & OriginalQueryValues < ' tcx > ,
306- _ : CanonicalResponse < ' tcx > ,
313+ fn instantiate_canonical_query_response < ' tcx > (
314+ infcx : & InferCtxt < ' tcx > ,
315+ original_values : & OriginalQueryValues < ' tcx > ,
316+ response : CanonicalResponse < ' tcx > ,
307317) -> Certainty {
308- unimplemented ! ( )
318+ let Ok ( InferOk { value, obligations } ) = infcx
319+ . instantiate_query_response_and_region_obligations (
320+ & ObligationCause :: dummy ( ) ,
321+ ty:: ParamEnv :: empty ( ) ,
322+ original_values,
323+ & response. unchecked_map ( |resp| QueryResponse {
324+ var_values : resp. var_values ,
325+ region_constraints : QueryRegionConstraints :: default ( ) ,
326+ certainty : match resp. certainty {
327+ Certainty :: Yes => OldCertainty :: Proven ,
328+ Certainty :: Maybe ( _) => OldCertainty :: Ambiguous ,
329+ } ,
330+ opaque_types : resp. external_constraints . opaque_types ,
331+ value : resp. certainty ,
332+ } ) ,
333+ ) else { bug ! ( ) ; } ;
334+ assert ! ( obligations. is_empty( ) ) ;
335+ value
309336}
0 commit comments