Rollup merge of #116219 - compiler-errors:relate-alias-ty-with-variance, r=lcnr
Relate alias ty with variance
In the new solver, turns out that the subst-relate branch of the alias-relate predicate was relating args invariantly even for opaques, which have variance 💀.
This change is a bit more invasive, but I'd rather not special-case it [here](aeaa5c30e5/compiler/rustc_trait_selection/src/solve/alias_relate.rs (L171-L190)
) and then have it break elsewhere. I'm doing a perf run to see if the extra call to `def_kind` is that expensive, if it is, I'll reconsider.
r? ``@lcnr``
This commit is contained in:
commit
8ddc0df1f1
4 changed files with 40 additions and 43 deletions
|
@ -56,7 +56,7 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> {
|
|||
// performing trait matching (which then performs equality
|
||||
// unification).
|
||||
|
||||
relate::relate_args(self, a_arg, b_arg)
|
||||
relate::relate_args_invariantly(self, a_arg, b_arg)
|
||||
}
|
||||
|
||||
fn relate_with_variance<T: Relate<'tcx>>(
|
||||
|
|
|
@ -183,7 +183,7 @@ where
|
|||
// Avoid fetching the variance if we are in an invariant
|
||||
// context; no need, and it can induce dependency cycles
|
||||
// (e.g., #41849).
|
||||
relate::relate_args(self, a_subst, b_subst)
|
||||
relate::relate_args_invariantly(self, a_subst, b_subst)
|
||||
} else {
|
||||
let tcx = self.tcx();
|
||||
let opt_variances = tcx.variances_of(item_def_id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue