@@ -12,11 +12,8 @@ use crate::solve::{deeply_normalize_for_diagnostics, inspect, FulfillmentCtxt};
12
12
use crate :: traits:: engine:: TraitEngineExt as _;
13
13
use crate :: traits:: select:: IntercrateAmbiguityCause ;
14
14
use crate :: traits:: structural_normalize:: StructurallyNormalizeExt ;
15
- use crate :: traits:: NormalizeExt ;
16
- use crate :: traits:: SkipLeakCheck ;
17
- use crate :: traits:: {
18
- Obligation , ObligationCause , PredicateObligation , PredicateObligations , SelectionContext ,
19
- } ;
15
+ use crate :: traits:: { NormalizeExt , SelectionContext , SkipLeakCheck } ;
16
+ use crate :: traits:: { Obligation , ObligationCause , PredicateObligation , PredicateObligations } ;
20
17
use rustc_data_structures:: fx:: FxIndexSet ;
21
18
use rustc_errors:: { Diag , EmissionGuarantee } ;
22
19
use rustc_hir:: def:: DefKind ;
@@ -346,9 +343,15 @@ fn impl_intersection_has_impossible_obligation<'a, 'cx, 'tcx>(
346
343
) -> IntersectionHasImpossibleObligations < ' tcx > {
347
344
let infcx = selcx. infcx ;
348
345
346
+ // Elaborate obligations in case the current obligation is unknowable,
347
+ // but its super trait bound is not. See #124532 for more details.
348
+ //
349
+ // FIXME(-Znext-solver=coinductive): Once we always prove super trait
350
+ // bounds when using impls this `elaborate` call can be ignored.
351
+ let obligations = util:: elaborate ( infcx. tcx , obligations. iter ( ) . cloned ( ) ) ;
349
352
if infcx. next_trait_solver ( ) {
350
353
let mut fulfill_cx = FulfillmentCtxt :: new ( infcx) ;
351
- fulfill_cx. register_predicate_obligations ( infcx, obligations. iter ( ) . cloned ( ) ) ;
354
+ fulfill_cx. register_predicate_obligations ( infcx, obligations) ;
352
355
353
356
// We only care about the obligations that are *definitely* true errors.
354
357
// Ambiguities do not prove the disjointness of two impls.
@@ -371,7 +374,7 @@ fn impl_intersection_has_impossible_obligation<'a, 'cx, 'tcx>(
371
374
for obligation in obligations {
372
375
// We use `evaluate_root_obligation` to correctly track intercrate
373
376
// ambiguity clauses.
374
- let evaluation_result = selcx. evaluate_root_obligation ( obligation) ;
377
+ let evaluation_result = selcx. evaluate_root_obligation ( & obligation) ;
375
378
376
379
match evaluation_result {
377
380
Ok ( result) => {
0 commit comments