@@ -12,8 +12,8 @@ use rustc_middle::infer::canonical::CanonicalVarInfos;
12
12
use rustc_middle:: infer:: unify_key:: { ConstVariableOrigin , ConstVariableOriginKind } ;
13
13
use rustc_middle:: traits:: solve:: inspect;
14
14
use rustc_middle:: traits:: solve:: {
15
- CanonicalInput , CanonicalResponse , Certainty , IsNormalizesToHack , PredefinedOpaques ,
16
- PredefinedOpaquesData , QueryResult ,
15
+ CanonicalInput , CanonicalResponse , Certainty , PredefinedOpaques , PredefinedOpaquesData ,
16
+ QueryResult ,
17
17
} ;
18
18
use rustc_middle:: traits:: { specialization_graph, DefiningAnchor } ;
19
19
use rustc_middle:: ty:: {
@@ -28,8 +28,8 @@ use std::ops::ControlFlow;
28
28
use crate :: traits:: vtable:: { count_own_vtable_entries, prepare_vtable_segments, VtblSegment } ;
29
29
30
30
use super :: inspect:: ProofTreeBuilder ;
31
- use super :: search_graph;
32
31
use super :: SolverMode ;
32
+ use super :: { search_graph, GoalEvaluationKind } ;
33
33
use super :: { search_graph:: SearchGraph , Goal } ;
34
34
pub use select:: InferCtxtSelectExt ;
35
35
@@ -85,7 +85,7 @@ pub struct EvalCtxt<'a, 'tcx> {
85
85
// evaluation code.
86
86
tainted : Result < ( ) , NoSolution > ,
87
87
88
- inspect : ProofTreeBuilder < ' tcx > ,
88
+ pub ( super ) inspect : ProofTreeBuilder < ' tcx > ,
89
89
}
90
90
91
91
#[ derive( Debug , Clone ) ]
@@ -149,7 +149,7 @@ pub trait InferCtxtEvalExt<'tcx> {
149
149
generate_proof_tree : GenerateProofTree ,
150
150
) -> (
151
151
Result < ( bool , Certainty , Vec < Goal < ' tcx , ty:: Predicate < ' tcx > > > ) , NoSolution > ,
152
- Option < inspect:: GoalEvaluation < ' tcx > > ,
152
+ Option < inspect:: RootGoalEvaluation < ' tcx > > ,
153
153
) ;
154
154
}
155
155
@@ -161,10 +161,10 @@ impl<'tcx> InferCtxtEvalExt<'tcx> for InferCtxt<'tcx> {
161
161
generate_proof_tree : GenerateProofTree ,
162
162
) -> (
163
163
Result < ( bool , Certainty , Vec < Goal < ' tcx , ty:: Predicate < ' tcx > > > ) , NoSolution > ,
164
- Option < inspect:: GoalEvaluation < ' tcx > > ,
164
+ Option < inspect:: RootGoalEvaluation < ' tcx > > ,
165
165
) {
166
166
EvalCtxt :: enter_root ( self , generate_proof_tree, |ecx| {
167
- ecx. evaluate_goal ( IsNormalizesToHack :: No , goal)
167
+ ecx. evaluate_goal ( GoalEvaluationKind :: Root , goal)
168
168
} )
169
169
}
170
170
}
@@ -185,7 +185,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
185
185
infcx : & InferCtxt < ' tcx > ,
186
186
generate_proof_tree : GenerateProofTree ,
187
187
f : impl FnOnce ( & mut EvalCtxt < ' _ , ' tcx > ) -> R ,
188
- ) -> ( R , Option < inspect:: GoalEvaluation < ' tcx > > ) {
188
+ ) -> ( R , Option < inspect:: RootGoalEvaluation < ' tcx > > ) {
189
189
let mode = if infcx. intercrate { SolverMode :: Coherence } else { SolverMode :: Normal } ;
190
190
let mut search_graph = search_graph:: SearchGraph :: new ( infcx. tcx , mode) ;
191
191
@@ -260,7 +260,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
260
260
search_graph,
261
261
nested_goals : NestedGoals :: new ( ) ,
262
262
tainted : Ok ( ( ) ) ,
263
- inspect : canonical_goal_evaluation. new_goal_evaluation_step ( input ) ,
263
+ inspect : canonical_goal_evaluation. new_goal_evaluation_step ( ) ,
264
264
} ;
265
265
266
266
for & ( key, ty) in & input. predefined_opaques_in_body . opaque_types {
@@ -340,11 +340,13 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
340
340
/// been constrained and the certainty of the result.
341
341
fn evaluate_goal (
342
342
& mut self ,
343
- is_normalizes_to_hack : IsNormalizesToHack ,
343
+ goal_evaluation_kind : GoalEvaluationKind ,
344
344
goal : Goal < ' tcx , ty:: Predicate < ' tcx > > ,
345
345
) -> Result < ( bool , Certainty , Vec < Goal < ' tcx , ty:: Predicate < ' tcx > > > ) , NoSolution > {
346
346
let ( orig_values, canonical_goal) = self . canonicalize_goal ( goal) ;
347
- let mut goal_evaluation = self . inspect . new_goal_evaluation ( goal, is_normalizes_to_hack) ;
347
+
348
+ let mut goal_evaluation =
349
+ ProofTreeBuilder :: new_goal_evaluation ( self , goal, & orig_values, goal_evaluation_kind) ;
348
350
let encountered_overflow = self . search_graph . encountered_overflow ( ) ;
349
351
let canonical_response = EvalCtxt :: evaluate_canonical_goal (
350
352
self . tcx ( ) ,
@@ -354,7 +356,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
354
356
) ;
355
357
let canonical_response = match canonical_response {
356
358
Err ( e) => {
357
- self . inspect . goal_evaluation ( goal_evaluation) ;
359
+ ProofTreeBuilder :: goal_evaluation ( self , goal_evaluation, & [ ] ) ;
358
360
return Err ( e) ;
359
361
}
360
362
Ok ( response) => response,
@@ -368,13 +370,12 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
368
370
canonical_response,
369
371
) {
370
372
Err ( e) => {
371
- self . inspect . goal_evaluation ( goal_evaluation) ;
373
+ ProofTreeBuilder :: goal_evaluation ( self , goal_evaluation, & [ ] ) ;
372
374
return Err ( e) ;
373
375
}
374
376
Ok ( response) => response,
375
377
} ;
376
- goal_evaluation. returned_goals ( & nested_goals) ;
377
- self . inspect . goal_evaluation ( goal_evaluation) ;
378
+ ProofTreeBuilder :: goal_evaluation ( self , goal_evaluation, & nested_goals) ;
378
379
379
380
if !has_changed && !nested_goals. is_empty ( ) {
380
381
bug ! ( "an unchanged goal shouldn't have any side-effects on instantiation" ) ;
@@ -389,7 +390,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
389
390
// solver cycle.
390
391
if cfg ! ( debug_assertions)
391
392
&& has_changed
392
- && is_normalizes_to_hack == IsNormalizesToHack :: No
393
+ && goal_evaluation_kind != GoalEvaluationKind :: NormalizesToHack
393
394
&& !self . search_graph . in_cycle ( )
394
395
{
395
396
// The nested evaluation has to happen with the original state
@@ -562,7 +563,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
562
563
) ;
563
564
564
565
let ( _, certainty, instantiate_goals) =
565
- self . evaluate_goal ( IsNormalizesToHack :: Yes , unconstrained_goal) ?;
566
+ self . evaluate_goal ( GoalEvaluationKind :: NormalizesToHack , unconstrained_goal) ?;
566
567
self . add_goals ( instantiate_goals) ;
567
568
568
569
// Finally, equate the goal's RHS with the unconstrained var.
@@ -597,7 +598,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
597
598
598
599
for goal in goals. goals . drain ( ..) {
599
600
let ( has_changed, certainty, instantiate_goals) =
600
- self . evaluate_goal ( IsNormalizesToHack :: No , goal) ?;
601
+ self . evaluate_goal ( GoalEvaluationKind :: Nested , goal) ?;
601
602
self . add_goals ( instantiate_goals) ;
602
603
if has_changed {
603
604
unchanged_certainty = None ;
0 commit comments