Document BinaryHeap unsafe functions#81706
Merged
bors merged 2 commits intorust-lang:masterfrom Feb 21, 2021
Merged
Conversation
Contributor
|
(rust-highfive has picked a reviewer for you, use r? to override) |
pickfire
reviewed
Feb 3, 2021
Member
Mark-Simulacrum
left a comment
There was a problem hiding this comment.
Thanks, this looks excellent. I think you are possibly right on the note about zero sized types; I think a PR adding the ZST bailout makes sense, but would need to do some more review on that. It would be good to add a FIXME comment into both methods that are likely affected to note down the problem.
Contributor
Author
|
Oops, I guess I had to use rustbot. Anyway, let me try @rustbot label -S-waiting-on-author +S-waiting-on-review |
03f7a34 to
3ec1a28
Compare
Member
|
Squashed out the rebase fix commit (feel free to do so in the future). @bors r+ rollup |
Collaborator
|
📌 Commit 3ec1a28 has been approved by |
JohnTitor
added a commit
to JohnTitor/rust
that referenced
this pull request
Feb 21, 2021
…e, r=Mark-Simulacrum Document BinaryHeap unsafe functions `BinaryHeap` contains some private safe functions but that are actually unsafe to call. This PR marks them `unsafe` and documents all the `unsafe` function calls inside them. While doing this I might also have found a bug: some "SAFETY" comments in `sift_down_range` and `sift_down_to_bottom` are valid only if you assume that `child` doesn't overflow. However it may overflow if `end > isize::MAX` which can be true for ZSTs (but I think only for them). I guess the easiest fix would be to skip any sifting if `mem::size_of::<T> == 0`. Probably conflicts with rust-lang#81127 but solving the eventual merge conflict should be pretty easy.
JohnTitor
added a commit
to JohnTitor/rust
that referenced
this pull request
Feb 21, 2021
…e, r=Mark-Simulacrum Document BinaryHeap unsafe functions `BinaryHeap` contains some private safe functions but that are actually unsafe to call. This PR marks them `unsafe` and documents all the `unsafe` function calls inside them. While doing this I might also have found a bug: some "SAFETY" comments in `sift_down_range` and `sift_down_to_bottom` are valid only if you assume that `child` doesn't overflow. However it may overflow if `end > isize::MAX` which can be true for ZSTs (but I think only for them). I guess the easiest fix would be to skip any sifting if `mem::size_of::<T> == 0`. Probably conflicts with rust-lang#81127 but solving the eventual merge conflict should be pretty easy.
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Feb 21, 2021
Rollup of 11 pull requests Successful merges: - rust-lang#81300 (BTree: share panicky test code & test panic during clear, clone) - rust-lang#81706 (Document BinaryHeap unsafe functions) - rust-lang#81833 (parallelize x.py test tidy) - rust-lang#81966 (Add new `rustc` target for Arm64 machines that can target the iphonesimulator) - rust-lang#82154 (Update RELEASES.md 1.50 to include methods stabilized in rust-lang#79342) - rust-lang#82177 (Do not delete bootstrap.exe on Windows during clean) - rust-lang#82181 (Add check for ES5 in CI) - rust-lang#82229 (Add [A-diagnostics] bug report template) - rust-lang#82233 (try-back-block-type test: Use TryFromSliceError for From test) - rust-lang#82302 (Remove unsafe impl Send for CompletedTest & TestResult) - rust-lang#82349 (test: Print test name only once on timeout) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BinaryHeapcontains some private safe functions but that are actually unsafe to call. This PR marks themunsafeand documents all theunsafefunction calls inside them.While doing this I might also have found a bug: some "SAFETY" comments in
sift_down_rangeandsift_down_to_bottomare valid only if you assume thatchilddoesn't overflow. However it may overflow ifend > isize::MAXwhich can be true for ZSTs (but I think only for them). I guess the easiest fix would be to skip any sifting ifmem::size_of::<T> == 0.Probably conflicts with #81127 but solving the eventual merge conflict should be pretty easy.