19
19
20
20
use std:: mem;
21
21
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 } ;
24
24
use rustc_infer:: traits:: query:: NoSolution ;
25
25
use rustc_infer:: traits:: Obligation ;
26
+ use rustc_middle:: infer:: canonical:: Certainty as OldCertainty ;
26
27
use rustc_middle:: infer:: canonical:: { Canonical , CanonicalVarValues } ;
27
28
use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
28
29
use rustc_middle:: ty:: { RegionOutlivesPredicate , ToPredicate , TypeOutlivesPredicate } ;
29
30
use rustc_span:: DUMMY_SP ;
30
31
32
+ use crate :: traits:: ObligationCause ;
33
+
34
+ use self :: cache:: response_no_constraints;
31
35
use self :: infcx_ext:: InferCtxtExt ;
32
36
33
37
mod assembly;
@@ -119,7 +123,7 @@ pub enum MaybeCause {
119
123
}
120
124
121
125
/// Additional constraints returned on success.
122
- #[ derive( Debug , PartialEq , Eq , Clone , Hash , TypeFoldable , TypeVisitable ) ]
126
+ #[ derive( Debug , PartialEq , Eq , Clone , Hash , TypeFoldable , TypeVisitable , Default ) ]
123
127
pub struct ExternalConstraints < ' tcx > {
124
128
// FIXME: implement this.
125
129
regions : ( ) ,
@@ -175,7 +179,7 @@ impl<'tcx> EvalCtxt<'tcx> {
175
179
let canonical_response = self . evaluate_canonical_goal ( canonical_goal) ?;
176
180
Ok ( (
177
181
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) ,
179
183
) )
180
184
}
181
185
@@ -208,7 +212,8 @@ impl<'tcx> EvalCtxt<'tcx> {
208
212
// of `PredicateKind` this is the case and it is and faster than instantiating and
209
213
// recanonicalizing.
210
214
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 ) {
212
217
match kind {
213
218
ty:: PredicateKind :: Clause ( ty:: Clause :: Trait ( predicate) ) => self . compute_trait_goal (
214
219
canonical_goal. unchecked_rebind ( Goal { param_env, predicate } ) ,
@@ -234,7 +239,10 @@ impl<'tcx> EvalCtxt<'tcx> {
234
239
| ty:: PredicateKind :: ConstEvaluatable ( _)
235
240
| ty:: PredicateKind :: ConstEquate ( _, _)
236
241
| 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
+ }
238
246
}
239
247
} else {
240
248
let ( infcx, goal, var_values) =
@@ -248,16 +256,18 @@ impl<'tcx> EvalCtxt<'tcx> {
248
256
249
257
fn compute_type_outlives_goal (
250
258
& mut self ,
251
- _goal : CanonicalGoal < ' tcx , TypeOutlivesPredicate < ' tcx > > ,
259
+ goal : CanonicalGoal < ' tcx , TypeOutlivesPredicate < ' tcx > > ,
252
260
) -> QueryResult < ' tcx > {
253
- todo ! ( )
261
+ // FIXME
262
+ response_no_constraints ( self . tcx , goal, Certainty :: Yes )
254
263
}
255
264
256
265
fn compute_region_outlives_goal (
257
266
& mut self ,
258
- _goal : CanonicalGoal < ' tcx , RegionOutlivesPredicate < ' tcx > > ,
267
+ goal : CanonicalGoal < ' tcx , RegionOutlivesPredicate < ' tcx > > ,
259
268
) -> QueryResult < ' tcx > {
260
- todo ! ( )
269
+ // FIXME
270
+ response_no_constraints ( self . tcx , goal, Certainty :: Yes )
261
271
}
262
272
}
263
273
@@ -300,10 +310,27 @@ impl<'tcx> EvalCtxt<'tcx> {
300
310
}
301
311
}
302
312
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 > ,
307
317
) -> 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
309
336
}
0 commit comments