You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TL;DR: For many types, a held T<'a> can be converted into T<'b> if 'a: 'b: we're agreeing to use the type "for shorter." If at a later time, the implementation of such a T gains (for example) an UnsafeCell field, it will lose the aforementioned property. We say that instead of covariant, it will have become invariant.
This is an extremely subtle way to break semver, and one for which downstream users have no recourse.
To craft an effective lint, we want to explain not just that the variance change happened but also which type(s) caused it. Ideally, we'd show the entire chain of types all the way down to the UnsafeCell or other field that causes invariance.
To be effective, this requires cross-crate analysis, which requires us to be able to effectively link and query rustdocs of multiple crates and the stdlib together.
The text was updated successfully, but these errors were encountered:
Relevant reading: https://doc.rust-lang.org/nomicon/subtyping.html
Especially this section: https://doc.rust-lang.org/nomicon/subtyping.html#variance
TL;DR: For many types, a held
T<'a>
can be converted intoT<'b>
if'a: 'b
: we're agreeing to use the type "for shorter." If at a later time, the implementation of such aT
gains (for example) anUnsafeCell
field, it will lose the aforementioned property. We say that instead of covariant, it will have become invariant.This is an extremely subtle way to break semver, and one for which downstream users have no recourse.
To craft an effective lint, we want to explain not just that the variance change happened but also which type(s) caused it. Ideally, we'd show the entire chain of types all the way down to the
UnsafeCell
or other field that causes invariance.To be effective, this requires cross-crate analysis, which requires us to be able to effectively link and query rustdocs of multiple crates and the stdlib together.
The text was updated successfully, but these errors were encountered: