A surprising new SemVer breakage case was discovered earlier this week, affecting sealed traits' associated items (consts, types, functions with or without receivers — everything) being accessible to subtraits. This is non-obvious and usually isn't intended by the authors of such code, which can lead to accidental breakage.
The standard library has an at-risk pattern here, where the sealing trait's associated item is accessible downstream: playground
#![feature(phantom_variance_markers)]
use core::marker::{PhantomCovariant, Variance};
fn leaked_value<T: Variance>() -> T {
// This is actually `private_items::PrivateItems::VALUE`,
// which we can't actually name directly.
T::VALUE
}
fn main() {
let _: PhantomCovariant<u8> = leaked_value();
}
If Variance were stabilized, PrivateItems::VALUE might also become stabilized. This seems possibly unintentional. Linking the tracking issue to get a backlink here: #135806.
portable-simd has the same issue, filed separately here.
Hat tip to @jhpratt for looping me in to look at the SemVer breakage and suggesting that we scan the standard library for this pattern. I used AI tools for the scan, and to generate the code snippet above. I wrote this issue fully by hand otherwise.
A surprising new SemVer breakage case was discovered earlier this week, affecting sealed traits' associated items (consts, types, functions with or without receivers — everything) being accessible to subtraits. This is non-obvious and usually isn't intended by the authors of such code, which can lead to accidental breakage.
The standard library has an at-risk pattern here, where the sealing trait's associated item is accessible downstream: playground
If
Variancewere stabilized,PrivateItems::VALUEmight also become stabilized. This seems possibly unintentional. Linking the tracking issue to get a backlink here: #135806.portable-simdhas the same issue, filed separately here.Hat tip to @jhpratt for looping me in to look at the SemVer breakage and suggesting that we scan the standard library for this pattern. I used AI tools for the scan, and to generate the code snippet above. I wrote this issue fully by hand otherwise.