1
Fork 0

Rollup merge of #104411 - lcnr:bivariance-nll, r=compiler-errors

nll: correctly deal with bivariance

fixes #104409

when in a bivariant context, relating stuff should always trivially succeed. Also changes the mir validator to correctly deal with higher ranked regions.

r? types cc ``@RalfJung``
This commit is contained in:
Dylan DPC 2022-11-19 11:54:44 +05:30 committed by GitHub
commit 00876c68c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 130 additions and 85 deletions

View file

@ -556,8 +556,9 @@ where
self.ambient_variance_info = self.ambient_variance_info.xform(info);
debug!(?self.ambient_variance);
let r = self.relate(a, b)?;
// In a bivariant context this always succeeds.
let r =
if self.ambient_variance == ty::Variance::Bivariant { a } else { self.relate(a, b)? };
self.ambient_variance = old_ambient_variance;