@@ -24,7 +24,8 @@ use rustc_infer::infer::{InferCtxt, InferOk, TyCtxtInferExt};
24
24
use rustc_infer:: traits:: query:: NoSolution ;
25
25
use rustc_infer:: traits:: Obligation ;
26
26
use rustc_middle:: infer:: canonical:: Certainty as OldCertainty ;
27
- use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
27
+ use rustc_middle:: traits:: solve:: { ExternalConstraints , ExternalConstraintsData } ;
28
+ use rustc_middle:: ty:: { self , TyCtxt } ;
28
29
use rustc_middle:: ty:: {
29
30
CoercePredicate , RegionOutlivesPredicate , SubtypePredicate , ToPredicate , TypeOutlivesPredicate ,
30
31
} ;
@@ -72,8 +73,7 @@ impl<'tcx, P> From<Obligation<'tcx, P>> for Goal<'tcx, P> {
72
73
Goal { param_env : obligation. param_env , predicate : obligation. predicate }
73
74
}
74
75
}
75
-
76
- #[ derive( Debug , PartialEq , Eq , Clone , Hash , TypeFoldable , TypeVisitable ) ]
76
+ #[ derive( Debug , PartialEq , Eq , Clone , Copy , Hash , TypeFoldable , TypeVisitable ) ]
77
77
pub struct Response < ' tcx > {
78
78
pub var_values : CanonicalVarValues < ' tcx > ,
79
79
/// Additional constraints returned by this query.
@@ -121,14 +121,6 @@ pub enum MaybeCause {
121
121
Overflow ,
122
122
}
123
123
124
- /// Additional constraints returned on success.
125
- #[ derive( Debug , PartialEq , Eq , Clone , Hash , TypeFoldable , TypeVisitable , Default ) ]
126
- pub struct ExternalConstraints < ' tcx > {
127
- // FIXME: implement this.
128
- regions : ( ) ,
129
- opaque_types : Vec < ( Ty < ' tcx > , Ty < ' tcx > ) > ,
130
- }
131
-
132
124
type CanonicalGoal < ' tcx , T = ty:: Predicate < ' tcx > > = Canonical < ' tcx , Goal < ' tcx , T > > ;
133
125
type CanonicalResponse < ' tcx > = Canonical < ' tcx , Response < ' tcx > > ;
134
126
/// The result of evaluating a canonical query.
@@ -218,15 +210,14 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
218
210
EvalCtxt { infcx, var_values, search_graph, in_projection_eq_hack : false } ;
219
211
let result = ecx. compute_goal ( goal) ;
220
212
221
- // FIXME: `Response` should be `Copy`
222
- if search_graph. try_finalize_goal ( tcx, canonical_goal, result. clone ( ) ) {
213
+ if search_graph. try_finalize_goal ( tcx, canonical_goal, result) {
223
214
return result;
224
215
}
225
216
}
226
217
}
227
218
228
219
fn make_canonical_response ( & self , certainty : Certainty ) -> QueryResult < ' tcx > {
229
- let external_constraints = take_external_constraints ( self . infcx ) ?;
220
+ let external_constraints = compute_external_query_constraints ( self . infcx ) ?;
230
221
231
222
Ok ( self . infcx . canonicalize_response ( Response {
232
223
var_values : self . var_values ,
@@ -461,18 +452,18 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
461
452
}
462
453
463
454
#[ instrument( level = "debug" , skip( infcx) , ret) ]
464
- fn take_external_constraints < ' tcx > (
455
+ fn compute_external_query_constraints < ' tcx > (
465
456
infcx : & InferCtxt < ' tcx > ,
466
457
) -> Result < ExternalConstraints < ' tcx > , NoSolution > {
467
458
let region_obligations = infcx. take_registered_region_obligations ( ) ;
468
459
let opaque_types = infcx. take_opaque_types_for_query_response ( ) ;
469
- Ok ( ExternalConstraints {
460
+ Ok ( infcx . tcx . intern_external_constraints ( ExternalConstraintsData {
470
461
// FIXME: Now that's definitely wrong :)
471
462
//
472
463
// Should also do the leak check here I think
473
464
regions : drop ( region_obligations) ,
474
465
opaque_types,
475
- } )
466
+ } ) )
476
467
}
477
468
478
469
fn instantiate_canonical_query_response < ' tcx > (
@@ -492,7 +483,10 @@ fn instantiate_canonical_query_response<'tcx>(
492
483
Certainty :: Yes => OldCertainty :: Proven ,
493
484
Certainty :: Maybe ( _) => OldCertainty :: Ambiguous ,
494
485
} ,
495
- opaque_types : resp. external_constraints . opaque_types ,
486
+ // FIXME: This to_owned makes me sad, but we should eventually impl
487
+ // `instantiate_query_response_and_region_obligations` separately
488
+ // instead of piggybacking off of the old implementation.
489
+ opaque_types : resp. external_constraints . opaque_types . to_owned ( ) ,
496
490
value : resp. certainty ,
497
491
} ) ,
498
492
) else { bug ! ( ) ; } ;
@@ -510,7 +504,10 @@ pub(super) fn response_no_constraints<'tcx>(
510
504
variables : goal. variables ,
511
505
value : Response {
512
506
var_values : CanonicalVarValues :: make_identity ( tcx, goal. variables ) ,
513
- external_constraints : Default :: default ( ) ,
507
+ // FIXME: maybe we should store the "no response" version in tcx, like
508
+ // we do for tcx.types and stuff.
509
+ external_constraints : tcx
510
+ . intern_external_constraints ( ExternalConstraintsData :: default ( ) ) ,
514
511
certainty,
515
512
} ,
516
513
} )
0 commit comments