There have been quite a few instances in std recently of variance not being right or changing unexpectedly after some patch. See e.g. https://github.com/rust-lang/rust/issues/35727 and https://github.com/rust-lang/rust/issues/35721.
Variance is kinda invisible and hard to think about and this is a drag, and if it’s hard for us with std it’s got to be super-hard for others to obey semver in the presence of variance. Better tools would help. Here’s what I think would be swell, at least for std:
First, a ‘variance-lock’. We have the compiler dump the variance of everything in std to a file, and commit it. Every test run we re-run the variance dump and compare. Similar to other tools we’ve got.
Second, a variance-policy. When we add new features, what is the variance? Even if it was as simple as everything must be invariant, then you have to take some manual step to loosen the variance. Tool-enforced.
I’d be very curious to see the variance of all our types side-by-side, what kind of inconsistencies we have and don’t know about.