Skip to content

Commit cb2d69e

Browse files
committed
also fully resolve predicates from the next solver
1 parent a315a05 commit cb2d69e

File tree

1 file changed

+41
-14
lines changed
  • compiler/rustc_trait_selection/src/traits

1 file changed

+41
-14
lines changed

compiler/rustc_trait_selection/src/traits/mod.rs

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -328,25 +328,52 @@ fn do_normalize_predicates<'tcx>(
328328
.with_next_trait_solver(true)
329329
.ignoring_regions()
330330
.build(TypingMode::non_body_analysis());
331-
for (orig_pred, pred_by_old) in original_predicates.into_iter().zip(&predicates) {
332-
let inconsistent_pred_by_next =
333-
match crate::solve::deeply_normalize::<_, ScrubbedTraitError<'tcx>>(
331+
let predicates_by_next: Vec<Option<_>> = original_predicates
332+
.iter()
333+
.cloned()
334+
.map(|p| {
335+
crate::solve::deeply_normalize::<_, ScrubbedTraitError<'tcx>>(
334336
infcx.at(&cause, elaborated_env),
335-
orig_pred,
336-
) {
337-
Ok(pred_by_next) => {
338-
if pred_by_next == *pred_by_old {
339-
continue;
340-
}
341-
Some(pred_by_next)
342-
}
343-
Err(_) => None,
344-
};
337+
p,
338+
)
339+
.ok()
340+
})
341+
.collect();
342+
343+
let errors = infcx.resolve_regions(cause.body_id, elaborated_env, []);
344+
if !errors.is_empty() {
345+
tcx.dcx().span_delayed_bug(
346+
span,
347+
format!(
348+
"failed region resolution while normalizing {elaborated_env:?}: {errors:?}"
349+
),
350+
);
351+
}
352+
353+
let predicates_by_next = match infcx.fully_resolve(predicates_by_next) {
354+
Ok(predicates) => predicates,
355+
Err(fixup_err) => {
356+
span_bug!(
357+
span,
358+
"inference variables in normalized parameter environment: {}",
359+
fixup_err
360+
);
361+
}
362+
};
363+
364+
for ((orig_pred, old_pred), next_pred) in
365+
original_predicates.iter().zip(&predicates).zip(&predicates_by_next)
366+
{
367+
if let Some(next_pred) = next_pred
368+
&& next_pred == old_pred
369+
{
370+
continue;
371+
}
345372
tcx.dcx().span_err(
346373
span,
347374
format!(
348375
"inconsistency during normalizing env `{:#?}`, old={:#?}, next={:#?}",
349-
orig_pred, pred_by_old, inconsistent_pred_by_next
376+
orig_pred, old_pred, next_pred
350377
),
351378
);
352379
}

0 commit comments

Comments
 (0)