-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Vec::recycle (experimental API implementation) #66069
Conversation
r? @shepmaster (rust_highfive has picked a reviewer for you, use r? to override) |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
It seems that a formatting check failed. I'm gonna reformat this later. |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
src/liballoc/vec.rs
Outdated
#[unstable(feature = "recycle_vec", reason = "new API", issue = "0")] | ||
pub fn recycle<U>(mut self) -> Vec<U> { | ||
self.truncate(0); | ||
// TODO make these const asserts once it becomes possible |
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 there an actual plan for making this possible? Even with compile time assertions, you wouldn't actually be able to reference T
and U
inside e.g. a const
item defined in this body.
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.
That is a question that needs to be resolved. It is mentioned as an unresolved question in the RFC. The problem is that changing to compile-time error is a breaking change, so whatever gets decided, we must commit to before stabilizing.
I assumed that once the const functions support conditionals, creating compile time assertion for this case would be possible, but I had a hidden assumption that if there is a generic const function, I could pass it generic types that are in scope. Is the latter not the case? I wonder if there are explicit plans about supporting or not supporting that, or is it just more about how it currently is?
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.
That's not the case and there are no current plans to change that so don't expect it to change within the next 1.5 years at least.
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.
All right, I removed the FIXME
. I guess it seems good enough just to panic, although I'd love to have a compile-time guarantee, and I think I'm not alone. I wonder if there is any other avenue of attack that would accomplish this.
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
I'm getting a CI error like this: I wonder if 3000 is the threshold value and this PR just happened to break it? Even if |
You can add the ignore directive but it would be good if you could follow up with the splitting. |
I'll starting working on one. That's actually a nice, manageable thing to do for us rustc noobs :) Adding the ignore directive for now. |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Ping from triage: Thanks! |
I am going to update the unresolved questions of this RFC. I’ll have time to do that on Monday or Tuesday next week. Edit: oops, responded without checking which thread this was. Never mind. |
Is this worth reviewing while the RFC is still being discussed? |
Marking this as blocked because it is blocked on RFC |
/// # } | ||
/// ``` | ||
/// | ||
/// # Note about stabilization |
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.
Should be removed now?
☔ The latest upstream changes (presumably #67917) made this pull request unmergeable. Please resolve the merge conflicts. |
☔ The latest upstream changes (presumably #68142) made this pull request unmergeable. Please resolve the merge conflicts. |
Closing this as this is blocked on the RFC and the RFC will take a while |
Implements the API described here rust-lang/rfcs#2802 behind a feature flag
recycle_vec
.