1
Fork 0

Rollup merge of #112780 - compiler-errors:tait-is-ambig, r=lcnr

Treat TAIT equation as always ambiguous in coherence

Not sure why we weren't treating all TAIT equality as ambiguous -- this behavior combined with `DefineOpaqueTypes::No` leads to coherence overlap failures, since we incorrectly consider impls as not overlapping because the obligation `T: From<Foo>` doesn't hold.

Fixes #112765
This commit is contained in:
Matthias Krüger 2023-06-19 19:26:28 +02:00 committed by GitHub
commit 263635b917
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 74 additions and 21 deletions

View file

@ -124,13 +124,10 @@ impl<'tcx> InferCtxt<'tcx> {
}
// During coherence, opaque types should be treated as *possibly*
// equal to each other, even if their generic params differ, as
// they could resolve to the same hidden type, even for different
// generic params.
(
&ty::Alias(ty::Opaque, ty::AliasTy { def_id: a_def_id, .. }),
&ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }),
) if self.intercrate && a_def_id == b_def_id => {
// equal to any other type (except for possibly itself). This is an
// extremely heavy hammer, but can be relaxed in a fowards-compatible
// way later.
(&ty::Alias(ty::Opaque, _), _) | (_, &ty::Alias(ty::Opaque, _)) if self.intercrate => {
relation.register_predicates([ty::Binder::dummy(ty::PredicateKind::Ambiguous)]);
Ok(a)
}