-
Notifications
You must be signed in to change notification settings - Fork 13.4k
vec::IntoIter is now invariant #35721
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
See my comment here: #35447 (comment) |
I'll be honest, I don't entirely know what covariant means, but I'm sorry for whatever pain it caused and wouldn't be offended if it got reverted. Does anyone know of a resource explaining the terms 'covariant' and 'invariant' in this context? |
@frewsxcv the docs on variance are at https://doc.rust-lang.org/nomicon/subtyping.html |
@frewsxcv: Basically, we just need to change |
@apasel422 is it safe to do that without also removing |
We probably need something like this for |
@asajeffrey It seems to me that |
@apasel422 okay, good point. The thing that's worrying me is that the *const T is being treated as a constant pointer by LLVM, which may trigger unsafe LLVM optimizations it it's then exposed as a &mut[T]. |
@apasel422 I think the difference is that |
@asajeffrey It's already safe to cast a In terms of duplicating |
@apasel422 okay, sounds like I'm being overly conservative! |
Thanks for the report @asajeffrey! As pointed out by @nikomatsakis we may just want to use @apasel422 or @frewsxcv, would either of you be interested in making a PR for this? |
Er |
I can't do anything at this very moment, but if no one gets around to it after a few hours when I get home from work, I can look into it. |
@apasel422 just opened a PR to resolve this: #35733 Sorry again for the accidental invariance! |
Make `vec::IntoIter` covariant again Closes #35721 r? @alexcrichton
The regression in rust-lang/rust#35721 will most likely not be backported to beta until next week - see rust-lang/rust#35733 - so it probably makes sense to disable it for now.
#35447 replaced a
*const T
by a*mut T
inIntoIter<T>
, which changedIntoIter
from being covariant to being invariant. This breaks crates likevec_map
which relied onIntoIter
being invariant, e.g. https://travis-ci.org/asajeffrey/presort/jobs/152720189#L208 has error:cc @alexcrichton @frewsxcv @apasel422
The text was updated successfully, but these errors were encountered: