-
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
Implement TrustedRandomAccess
for vec::Drain
#81617
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
020dfb8
to
1d33db3
Compare
r? @m-ou-se for reassignment |
r? @Amanieu |
@bors r+ |
📌 Commit 1d33db3 has been approved by |
⌛ Testing commit 1d33db3 with merge e5642fd10b149d75caa992b4327123129d14f902... |
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
Marking as S-blocked as per #81617 (comment). |
library/alloc/src/vec/drain.rs
Outdated
// | ||
// T: Copy as approximation for !Drop since get_unchecked does not advance self.iter | ||
// and as a result the `Drop` impl above would otherwise cause items to be dropped twice. | ||
unsafe impl<T, A: Allocator> TrustedRandomAccess for Drain<'_, T, A> |
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.
Now that #85874 has landed this should become TrustedRandomAccessNoCoerce
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.
Switched over to TrustedRandomAccessNoCoerce
. Thanks and sorry for the delay!
Ping from triage, any updates on this? |
@sdroege |
…pping Otherwise this simply causes advancing of the iterator with no other effects, which is unnecessary work.
9c70fcb
to
19480c1
Compare
Ready for a new round of review! :) |
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.
Taking over review of this.
Overall it seems safe, just the safety comment could use some expansion
r? @the8472
// requires each index to be accessed only once, this is safe to do here. | ||
// | ||
// TrustedRandomAccess (without NoCoerce) must not be implemented because | ||
// subtypes/supertypes of `T` might not be `NonDrop` |
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.
Drain
is a bit more complicated than IntoIter
due to its Drop
impl doing actual work even for T: Copy
. This comment should mention why this is still ok. Something along the lines that the tail move does not depend on how much has been drained.
Ping from triage: |
☔ The latest upstream changes (presumably #85157) made this pull request unmergeable. Please resolve the merge conflicts. |
No description provided.