Fix inconsistent safety requirement in VecDeque::nonoverlapping_ranges#158433
Merged
rust-bors[bot] merged 1 commit intoJun 28, 2026
Merged
Conversation
Collaborator
|
r? @jhpratt rustbot has assigned @jhpratt. Use Why was this reviewer chosen?The reviewer was selected based on:
|
Member
|
Given that this is an internal API, this shouldn't need team approval. @bors r+ rollup |
Contributor
rust-bors Bot
pushed a commit
that referenced
this pull request
Jun 28, 2026
Rollup of 15 pull requests Successful merges: - #158497 (stdarch subtree update) - #152225 (Add supertrait item shadowing for type-level path resolution) - #158194 (Adds RmetaLinkCache a per-link cache that uses path as the key of dec…) - #158466 (rustdoc: show impl Trait<Box<Local>> for Foreign, etc on Local's docs) - #158501 (miri subtree update) - #153097 (Expand `OptionFlatten`'s iterator methods) - #157614 (Move tests drop) - #157996 (perf: drop the full-crate AST walk in check_unused) - #158163 (Fix too-short variance slice in `variances_of` cycle recovery) - #158233 (Allow the unstable attribute on foreign type) - #158433 (Fix inconsistent safety requirement in VecDeque::nonoverlapping_ranges) - #158464 (Reorganize `tests/ui/issues` [15/N]) - #158470 (Upgrade `jsonsocck` and `jsondoclint` to edition 2024.) - #158485 (Reorganize `tests/ui/issues` [16/N]) - #158488 (Upgrade `rustdoc-json-types` to 2024 edition.)
faukah
pushed a commit
to faukah/miri
that referenced
this pull request
Jun 28, 2026
Rollup of 15 pull requests Successful merges: - rust-lang/rust#158497 (stdarch subtree update) - rust-lang/rust#152225 (Add supertrait item shadowing for type-level path resolution) - rust-lang/rust#158194 (Adds RmetaLinkCache a per-link cache that uses path as the key of dec…) - rust-lang/rust#158466 (rustdoc: show impl Trait<Box<Local>> for Foreign, etc on Local's docs) - rust-lang/rust#158501 (miri subtree update) - rust-lang/rust#153097 (Expand `OptionFlatten`'s iterator methods) - rust-lang/rust#157614 (Move tests drop) - rust-lang/rust#157996 (perf: drop the full-crate AST walk in check_unused) - rust-lang/rust#158163 (Fix too-short variance slice in `variances_of` cycle recovery) - rust-lang/rust#158233 (Allow the unstable attribute on foreign type) - rust-lang/rust#158433 (Fix inconsistent safety requirement in VecDeque::nonoverlapping_ranges) - rust-lang/rust#158464 (Reorganize `tests/ui/issues` [15/N]) - rust-lang/rust#158470 (Upgrade `jsonsocck` and `jsondoclint` to edition 2024.) - rust-lang/rust#158485 (Reorganize `tests/ui/issues` [16/N]) - rust-lang/rust#158488 (Upgrade `rustdoc-json-types` to 2024 edition.)
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.
The safety documentation of
nonoverlapping_rangessays that itsheadargument must be in bounds:However, this is slightly stricter than the
VecDequeinternal invariant forhead. The struct-level invariant allowshead == 0when the buffer capacity is zero:This zero-capacity case is reachable through the public API. I create the corresponding case in Rustplayground. This case can run without UB, also Miri runs successfully.
So it seems that the safety documentation of
VecDeque::nonoverlapping_rangesis incorrect, or this API should add additional processing to approach this condition. This PR provides the minimal fix: updates the safety documentation fornonoverlapping_rangesto match the existing VecDeque invariant.If needed, I can add a debug_assert! to check whether the input satisfies the requirement.
No behavior is changed.