@@ -157,7 +157,7 @@ impl<'tcx> InferCtxtEvalExt<'tcx> for InferCtxt<'tcx> {
157
157
Option < inspect:: GoalEvaluation < ' tcx > > ,
158
158
) {
159
159
EvalCtxt :: enter_root ( self , generate_proof_tree, |ecx| {
160
- ecx. evaluate_goal ( GoalEvaluationKind :: Root , goal)
160
+ ecx. evaluate_goal ( GoalEvaluationKind :: Root , GoalSource :: Misc , goal)
161
161
} )
162
162
}
163
163
}
@@ -335,6 +335,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
335
335
fn evaluate_goal (
336
336
& mut self ,
337
337
goal_evaluation_kind : GoalEvaluationKind ,
338
+ source : GoalSource ,
338
339
goal : Goal < ' tcx , ty:: Predicate < ' tcx > > ,
339
340
) -> Result < ( bool , Certainty , Vec < Goal < ' tcx , ty:: Predicate < ' tcx > > > ) , NoSolution > {
340
341
let ( orig_values, canonical_goal) = self . canonicalize_goal ( goal) ;
@@ -354,13 +355,13 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
354
355
Ok ( response) => response,
355
356
} ;
356
357
357
- let has_changed = !canonical_response . value . var_values . is_identity_modulo_regions ( )
358
- || !canonical_response . value . external_constraints . opaque_types . is_empty ( ) ;
359
- let ( certainty , nested_goals ) = match self . instantiate_and_apply_query_response (
360
- goal . param_env ,
361
- orig_values,
362
- canonical_response,
363
- ) {
358
+ let ( certainty , has_changed, nested_goals ) = match self
359
+ . instantiate_response_discarding_overflow (
360
+ goal . param_env ,
361
+ source ,
362
+ orig_values,
363
+ canonical_response,
364
+ ) {
364
365
Err ( e) => {
365
366
self . inspect . goal_evaluation ( goal_evaluation) ;
366
367
return Err ( e) ;
@@ -387,6 +388,30 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
387
388
Ok ( ( has_changed, certainty, nested_goals) )
388
389
}
389
390
391
+ fn instantiate_response_discarding_overflow (
392
+ & mut self ,
393
+ param_env : ty:: ParamEnv < ' tcx > ,
394
+ source : GoalSource ,
395
+ original_values : Vec < ty:: GenericArg < ' tcx > > ,
396
+ response : CanonicalResponse < ' tcx > ,
397
+ ) -> Result < ( Certainty , bool , Vec < Goal < ' tcx , ty:: Predicate < ' tcx > > > ) , NoSolution > {
398
+ let keep_overflow_constraints = || {
399
+ self . search_graph . current_goal_is_normalizes_to ( )
400
+ && source != GoalSource :: ImplWhereBound
401
+ } ;
402
+
403
+ if response. value . certainty == Certainty :: OVERFLOW && !keep_overflow_constraints ( ) {
404
+ Ok ( ( Certainty :: OVERFLOW , false , Vec :: new ( ) ) )
405
+ } else {
406
+ let has_changed = !response. value . var_values . is_identity_modulo_regions ( )
407
+ || !response. value . external_constraints . opaque_types . is_empty ( ) ;
408
+
409
+ let ( certainty, nested_goals) =
410
+ self . instantiate_and_apply_query_response ( param_env, original_values, response) ?;
411
+ Ok ( ( certainty, has_changed, nested_goals) )
412
+ }
413
+ }
414
+
390
415
fn compute_goal ( & mut self , goal : Goal < ' tcx , ty:: Predicate < ' tcx > > ) -> QueryResult < ' tcx > {
391
416
let Goal { param_env, predicate } = goal;
392
417
let kind = predicate. kind ( ) ;
@@ -509,6 +534,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
509
534
510
535
let ( _, certainty, instantiate_goals) = self . evaluate_goal (
511
536
GoalEvaluationKind :: Nested { is_normalizes_to_hack : IsNormalizesToHack :: Yes } ,
537
+ GoalSource :: Misc ,
512
538
unconstrained_goal,
513
539
) ?;
514
540
self . nested_goals . goals . extend ( with_misc_source ( instantiate_goals) ) ;
@@ -544,6 +570,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
544
570
for ( source, goal) in goals. goals . drain ( ..) {
545
571
let ( has_changed, certainty, instantiate_goals) = self . evaluate_goal (
546
572
GoalEvaluationKind :: Nested { is_normalizes_to_hack : IsNormalizesToHack :: No } ,
573
+ source,
547
574
goal,
548
575
) ?;
549
576
self . nested_goals . goals . extend ( with_misc_source ( instantiate_goals) ) ;
0 commit comments