@@ -23,8 +23,7 @@ use crate::solve::inspect::{self, ProofTreeBuilder};
23
23
use crate :: solve:: search_graph:: SearchGraph ;
24
24
use crate :: solve:: {
25
25
CanonicalInput , Certainty , FIXPOINT_STEP_LIMIT , Goal , GoalEvaluationKind , GoalSource ,
26
- HasChanged , NestedNormalizationGoals , NoSolution , PredefinedOpaquesData , QueryInput ,
27
- QueryResult ,
26
+ HasChanged , NestedNormalizationGoals , NoSolution , QueryInput , QueryResult ,
28
27
} ;
29
28
30
29
pub ( super ) mod canonical;
99
98
current_goal_kind : CurrentGoalKind ,
100
99
pub ( super ) var_values : CanonicalVarValues < I > ,
101
100
102
- predefined_opaques_in_body : I :: PredefinedOpaques ,
103
-
104
101
/// The highest universe index nameable by the caller.
105
102
///
106
103
/// When we enter a new binder inside of the query we create new universes
@@ -111,6 +108,10 @@ where
111
108
/// if we have a coinductive cycle and because that's the only way we can return
112
109
/// new placeholders to the caller.
113
110
pub ( super ) max_input_universe : ty:: UniverseIndex ,
111
+ /// The opaque types from the canonical input. We only need to return opaque types
112
+ /// which have been added to the storage while evaluating this goal.
113
+ pub ( super ) initial_opaque_types_storage_num_entries :
114
+ <D :: Infcx as InferCtxtLike >:: OpaqueTypeStorageEntries ,
114
115
115
116
pub ( super ) search_graph : & ' a mut SearchGraph < D > ,
116
117
@@ -305,10 +306,8 @@ where
305
306
306
307
// Only relevant when canonicalizing the response,
307
308
// which we don't do within this evaluation context.
308
- predefined_opaques_in_body : delegate
309
- . cx ( )
310
- . mk_predefined_opaques_in_body ( PredefinedOpaquesData :: default ( ) ) ,
311
309
max_input_universe : ty:: UniverseIndex :: ROOT ,
310
+ initial_opaque_types_storage_num_entries : Default :: default ( ) ,
312
311
variables : Default :: default ( ) ,
313
312
var_values : CanonicalVarValues :: dummy ( ) ,
314
313
current_goal_kind : CurrentGoalKind :: Misc ,
@@ -342,25 +341,10 @@ where
342
341
canonical_goal_evaluation : & mut ProofTreeBuilder < D > ,
343
342
f : impl FnOnce ( & mut EvalCtxt < ' _ , D > , Goal < I , I :: Predicate > ) -> R ,
344
343
) -> R {
345
- let ( ref delegate, input, var_values) =
346
- SolverDelegate :: build_with_canonical ( cx, & canonical_input) ;
347
-
348
- let mut ecx = EvalCtxt {
349
- delegate,
350
- variables : canonical_input. canonical . variables ,
351
- var_values,
352
- current_goal_kind : CurrentGoalKind :: from_query_input ( cx, input) ,
353
- predefined_opaques_in_body : input. predefined_opaques_in_body ,
354
- max_input_universe : canonical_input. canonical . max_universe ,
355
- search_graph,
356
- nested_goals : Default :: default ( ) ,
357
- origin_span : I :: Span :: dummy ( ) ,
358
- tainted : Ok ( ( ) ) ,
359
- inspect : canonical_goal_evaluation. new_goal_evaluation_step ( var_values) ,
360
- } ;
344
+ let ( ref delegate, input, var_values) = D :: build_with_canonical ( cx, & canonical_input) ;
361
345
362
346
for & ( key, ty) in & input. predefined_opaques_in_body . opaque_types {
363
- let prev = ecx . delegate . register_hidden_type_in_storage ( key, ty, ecx . origin_span ) ;
347
+ let prev = delegate. register_hidden_type_in_storage ( key, ty, I :: Span :: dummy ( ) ) ;
364
348
// It may be possible that two entries in the opaque type storage end up
365
349
// with the same key after resolving contained inference variables.
366
350
//
@@ -373,13 +357,24 @@ where
373
357
// the canonical input. This is more annoying to implement and may cause a
374
358
// perf regression, so we do it inside of the query for now.
375
359
if let Some ( prev) = prev {
376
- debug ! ( ?key, ?ty, ?prev, "ignore duplicate in `opaque_type_storage `" ) ;
360
+ debug ! ( ?key, ?ty, ?prev, "ignore duplicate in `opaque_types_storage `" ) ;
377
361
}
378
362
}
379
363
380
- if !ecx. nested_goals . is_empty ( ) {
381
- panic ! ( "prepopulating opaque types shouldn't add goals: {:?}" , ecx. nested_goals) ;
382
- }
364
+ let initial_opaque_types_storage_num_entries = delegate. opaque_types_storage_num_entries ( ) ;
365
+ let mut ecx = EvalCtxt {
366
+ delegate,
367
+ variables : canonical_input. canonical . variables ,
368
+ var_values,
369
+ current_goal_kind : CurrentGoalKind :: from_query_input ( cx, input) ,
370
+ max_input_universe : canonical_input. canonical . max_universe ,
371
+ initial_opaque_types_storage_num_entries,
372
+ search_graph,
373
+ nested_goals : Default :: default ( ) ,
374
+ origin_span : I :: Span :: dummy ( ) ,
375
+ tainted : Ok ( ( ) ) ,
376
+ inspect : canonical_goal_evaluation. new_goal_evaluation_step ( var_values) ,
377
+ } ;
383
378
384
379
let result = f ( & mut ecx, input. goal ) ;
385
380
ecx. inspect . probe_final_state ( ecx. delegate , ecx. max_input_universe ) ;
0 commit comments