-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unsoundness due to variance of trait objects WRT associated types #71550
Comments
With rustc 1.0.0 ..= 1.16.0, the following error was emitted:
|
@nikomatsakis -- this looks plausibly similar to #44454, but I don't know enough to be certain. |
Oh wow how are these not invariant? Cc @eddyb |
Assigning |
Just in case, in my last action I've removed |
Wait, these are supposed to be invariant. This is definitely a bug. It would be great to figure out just which nightly regressed this, maybe somebody can run cargo bisect? @rustbot cleanup |
Er, I guess I meant this? @rustbot ping cleanup |
Hey Cleanup Crew ICE-breakers! This bug has been identified as a good cc @AminArria @chrissimpkins @contrun @DutchGhost @elshize @ethanboxx @h-michael @HallerPatrick @hdhoang @hellow554 @imtsuki @jakevossen5 @kanru @KarlK90 @LeSeulArtichaut @MAdrianMattocks @matheus-consoli @mental32 @nmccarty @Noah-Kennedy @pard68 @PeytonT @pierreN @Redblueflame @RobbieClarken @RobertoSnap @robjtede @SarthakSingh31 @senden9 @shekohex @sinato @spastorino @turboladen @woshilapin @yerke |
searched toolchains nightly-2016-06-01 through nightly-2020-01-01 Previous error message:
I used a slightly modified variant (just removed the Code used
|
Thanks! Super useful. |
After discussing a bit with @nikomatsakis this sounds more like |
@rustbot modify labels:-E-needs-bisection |
Crater run from the fix suggested 16 non-spurious regressions (thanks to @bjorn3 for the analysis). I was thinking about that and I realize that it's plausible that we could do variance inference on associated types and use that to inform the variance for I'm a bit nervous about this though. For one thing, the core operations exposed by a |
This was exposed by a recent fix on nightly to rust-lang/rust#71550.
This was exposed by a recent fix on nightly to rust-lang/rust#71550.
IIUC currently a trait object is always covariant in its associated types, regardless of their positions.
This makes it possible to pass a non-static reference to a function expecting a static reference:
The text was updated successfully, but these errors were encountered: