1
Fork 0

Remove some noise from opaque type errors around associated types

This commit is contained in:
Oli Scherer 2021-12-16 15:17:16 +00:00
parent f8402169aa
commit 689a868a1f
3 changed files with 17 additions and 57 deletions

View file

@ -551,6 +551,20 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
let predicate = predicate.subst(tcx, substs);
debug!(?predicate);
// Replace all other mentions of the same opaque type with the hidden type,
// as the bounds must hold on the hidden type after all.
let predicate = predicate.fold_with(&mut BottomUpFolder {
tcx,
ty_op: |ty| match *ty.kind() {
ty::Opaque(def_id2, substs2) if def_id == def_id2 && substs == substs2 => {
ty_var
}
_ => ty,
},
lt_op: |lt| lt,
ct_op: |ct| ct,
});
// We can't normalize associated types from `rustc_infer`, but we can eagerly register inference variables for them.
let predicate = predicate.fold_with(&mut BottomUpFolder {
tcx,