-
Notifications
You must be signed in to change notification settings - Fork 14k
vec_recycle: implementation
#148416
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
base: main
Are you sure you want to change the base?
vec_recycle: implementation
#148416
Conversation
|
rustbot has assigned @Mark-Simulacrum. Use |
This comment has been minimized.
This comment has been minimized.
9eb5e67 to
d118c1c
Compare
library/alloc/src/vec/mod.rs
Outdated
| /// | ||
| /// ``` | ||
| /// #![feature(vec_recycle)] | ||
| /// #![feature(transmutability)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the explicit transmutability feature flag needed for this example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the feature flag seems to propagate from the bound on the impl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I wonder how Try avoids that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The initial TransmuteFrom trait is marked with unstable_feature_bound, while Try is not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, interesting! I didn't add that, and I'm curious why it was added (it's usually used to create unstable impls of stable traits). Hey @tiif, can you chime in as to why you added #[unstable_feature_bound(transmutability)] to TransmuteFrom here?
For context: We're using TransmuteFrom as a private implementation detail of Vec::recycle, but requiring users of recycle to have #![feature(transmutability)] even when they don't mention TransmuteFrom leaks that implementation detail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a #[unstable_feature_bound(transmutability)] for impl ConstParamTy_ for Assume {}. Since TransmuteFrom uses const ASSUME: Assume = { Assume::NOTHING } here, it needs to add #[unstable_feature_bound(transmutability)] too.
Unfortunately we haven't made it possible to stop propagating #[unstable_feature_bound] this way for now :(
d118c1c to
697a9e4
Compare
|
☔ The latest upstream changes (presumably #135634) made this pull request unmergeable. Please resolve the merge conflicts. |
697a9e4 to
280c6aa
Compare
This comment has been minimized.
This comment has been minimized.
|
@rustbot ready |
This comment has been minimized.
This comment has been minimized.
280c6aa to
33da728
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Tracking issue: #148227
Going with the
TransmuteFromapproach suggested in rust-lang/libs-team#674 (comment), but a bit simplified.Currently does not work in some places where it should due to the limitations of the current implementation of the transmutability analysis: #148227 (comment)