Add supplementary information for get_unchecked(mut)#158810
Merged
Merged
Conversation
Collaborator
|
r? @Darksonn rustbot has assigned @Darksonn. Use Why was this reviewer chosen?The reviewer was selected based on:
|
Darksonn
approved these changes
Jul 6, 2026
Member
There was a problem hiding this comment.
Looks good to me.
I don't think we should add any links to the slice methods. Defining in-bounds for raw pointers is slightly tricky and non-obvious, so it makes sense to link those, but for slices the definition is obvious and I think no link is needed.
@bors r+ rollup
Contributor
Contributor
Author
|
I understand. Thank you for your review! |
rust-bors Bot
pushed a commit
that referenced
this pull request
Jul 6, 2026
Rollup of 24 pull requests Successful merges: - #158377 (add `-Zforce-intrinsic-fallback` flag) - #158642 (Clarify some interning details) - #158694 (Positive test for closures needing expectations) - #158743 (Look for cdb location in the registry first) - #158775 (bootstrap: only encode RUSTFLAGS when a flag contains a space) - #158782 (Add and use cfg(target_has_threads) to enforce no_thread impl usage) - #158785 (hook intrinsic-test into aarch64-gnu) - #158819 (Put `InhabitedPredicate::NotInModule` earlier in disjunction since it can be a lot faster) - #157734 (Stabilize `local_key_cell_update`) - #158183 (std: allocate less memory in `current_exe` for OpenBSD) - #158310 (Remove unexpected usage of Unambig in non-infer variants) - #158671 (Move tests batch 17) - #158730 (Update `FIXME(static_mut_refs)` comments) - #158752 (Reorganize `tests/ui/issues` [18/N]) - #158755 (Use `ThinVec` more in the AST) - #158757 (Fix incorrect tracking issue for `read_le`/`read_be`) - #158765 (Fix ICE on non-ident path in `doc(auto_cfg values)`) - #158771 (library: expand HashSet::extract_if coverage) - #158772 (rustc-dev-guide subtree update) - #158776 (fix: emit diagnostic for AVR target without target-cpu) - #158786 (Add regression test for builtin attr macro values) - #158810 (Add supplementary information for get_unchecked(mut)) - #158825 (Fix typo) - #158838 (tidy: Use `empty_alternate = true` for triagebot mention glob check)
rust-bors Bot
pushed a commit
that referenced
this pull request
Jul 6, 2026
Rollup of 24 pull requests Successful merges: - #158377 (add `-Zforce-intrinsic-fallback` flag) - #158642 (Clarify some interning details) - #158694 (Positive test for closures needing expectations) - #158743 (Look for cdb location in the registry first) - #158775 (bootstrap: only encode RUSTFLAGS when a flag contains a space) - #158782 (Add and use cfg(target_has_threads) to enforce no_thread impl usage) - #158785 (hook intrinsic-test into aarch64-gnu) - #158819 (Put `InhabitedPredicate::NotInModule` earlier in disjunction since it can be a lot faster) - #157734 (Stabilize `local_key_cell_update`) - #158183 (std: allocate less memory in `current_exe` for OpenBSD) - #158310 (Remove unexpected usage of Unambig in non-infer variants) - #158671 (Move tests batch 17) - #158730 (Update `FIXME(static_mut_refs)` comments) - #158752 (Reorganize `tests/ui/issues` [18/N]) - #158755 (Use `ThinVec` more in the AST) - #158757 (Fix incorrect tracking issue for `read_le`/`read_be`) - #158765 (Fix ICE on non-ident path in `doc(auto_cfg values)`) - #158771 (library: expand HashSet::extract_if coverage) - #158772 (rustc-dev-guide subtree update) - #158776 (fix: emit diagnostic for AVR target without target-cpu) - #158786 (Add regression test for builtin attr macro values) - #158810 (Add supplementary information for get_unchecked(mut)) - #158825 (Fix typo) - #158838 (tidy: Use `empty_alternate = true` for triagebot mention glob check)
rust-bors Bot
pushed a commit
that referenced
this pull request
Jul 6, 2026
Rollup of 24 pull requests Successful merges: - #158377 (add `-Zforce-intrinsic-fallback` flag) - #158642 (Clarify some interning details) - #158694 (Positive test for closures needing expectations) - #158743 (Look for cdb location in the registry first) - #158775 (bootstrap: only encode RUSTFLAGS when a flag contains a space) - #158782 (Add and use cfg(target_has_threads) to enforce no_thread impl usage) - #158785 (hook intrinsic-test into aarch64-gnu) - #158819 (Put `InhabitedPredicate::NotInModule` earlier in disjunction since it can be a lot faster) - #157734 (Stabilize `local_key_cell_update`) - #158183 (std: allocate less memory in `current_exe` for OpenBSD) - #158310 (Remove unexpected usage of Unambig in non-infer variants) - #158671 (Move tests batch 17) - #158730 (Update `FIXME(static_mut_refs)` comments) - #158752 (Reorganize `tests/ui/issues` [18/N]) - #158755 (Use `ThinVec` more in the AST) - #158757 (Fix incorrect tracking issue for `read_le`/`read_be`) - #158765 (Fix ICE on non-ident path in `doc(auto_cfg values)`) - #158771 (library: expand HashSet::extract_if coverage) - #158772 (rustc-dev-guide subtree update) - #158776 (fix: emit diagnostic for AVR target without target-cpu) - #158786 (Add regression test for builtin attr macro values) - #158810 (Add supplementary information for get_unchecked(mut)) - #158825 (Fix typo) - #158838 (tidy: Use `empty_alternate = true` for triagebot mention glob check)
rust-timer
added a commit
that referenced
this pull request
Jul 6, 2026
Rollup merge of #158810 - yilin0518:fix_get_unchecked, r=Darksonn Add supplementary information for get_unchecked(mut) Tracking issue: #74265 This PR makes the safety documentation for raw pointer and NonNull `get_unchecked(_mut)` APIs more consistent. Currently, `*mut [T]::get_unchecked_mut` links `out-of-bounds index` to the `add` method, but the corresponding docs for `*const[T]::get_unchecked` and `NonNull<[T]>::get_unchecked_mut` use plain text for the same safety condition. This PR updates those two docs to link `out-of-bounds index` to `#method.add`, matching the existing wording and link style used by `*mut [T]::get_unchecked_mut`. This is a documentation-only change. I also noticed that similar wording in the following APIs currently does not link `out-of-bounds index`: - [slice::get_unchecked](https://doc.rust-lang.org/core/primitive.slice.html#method.get_unchecked) - [slice::get_unchecked_mut](https://doc.rust-lang.org/core/primitive.slice.html#method.get_unchecked_mut) - [core::slice::SliceIndex::get_unchecked](https://doc.rust-lang.org/core/slice/trait.SliceIndex.html#tymethod.get_unchecked) - [core::slice::SliceIndex::get_unchecked_mut](https://doc.rust-lang.org/core/slice/trait.SliceIndex.html#tymethod.get_unchecked_mut) I did not update those in this PR because I am not sure which target would be the most appropriate link for those APIs. If there is a preferred link target for these slice and `SliceIndex` docs, I would be happy to update them and merge the updates in this PR.
pull Bot
pushed a commit
to xtqqczze/rust-lang-miri
that referenced
this pull request
Jul 7, 2026
Rollup of 24 pull requests Successful merges: - rust-lang/rust#158377 (add `-Zforce-intrinsic-fallback` flag) - rust-lang/rust#158642 (Clarify some interning details) - rust-lang/rust#158694 (Positive test for closures needing expectations) - rust-lang/rust#158743 (Look for cdb location in the registry first) - rust-lang/rust#158775 (bootstrap: only encode RUSTFLAGS when a flag contains a space) - rust-lang/rust#158782 (Add and use cfg(target_has_threads) to enforce no_thread impl usage) - rust-lang/rust#158785 (hook intrinsic-test into aarch64-gnu) - rust-lang/rust#158819 (Put `InhabitedPredicate::NotInModule` earlier in disjunction since it can be a lot faster) - rust-lang/rust#157734 (Stabilize `local_key_cell_update`) - rust-lang/rust#158183 (std: allocate less memory in `current_exe` for OpenBSD) - rust-lang/rust#158310 (Remove unexpected usage of Unambig in non-infer variants) - rust-lang/rust#158671 (Move tests batch 17) - rust-lang/rust#158730 (Update `FIXME(static_mut_refs)` comments) - rust-lang/rust#158752 (Reorganize `tests/ui/issues` [18/N]) - rust-lang/rust#158755 (Use `ThinVec` more in the AST) - rust-lang/rust#158757 (Fix incorrect tracking issue for `read_le`/`read_be`) - rust-lang/rust#158765 (Fix ICE on non-ident path in `doc(auto_cfg values)`) - rust-lang/rust#158771 (library: expand HashSet::extract_if coverage) - rust-lang/rust#158772 (rustc-dev-guide subtree update) - rust-lang/rust#158776 (fix: emit diagnostic for AVR target without target-cpu) - rust-lang/rust#158786 (Add regression test for builtin attr macro values) - rust-lang/rust#158810 (Add supplementary information for get_unchecked(mut)) - rust-lang/rust#158825 (Fix typo) - rust-lang/rust#158838 (tidy: Use `empty_alternate = true` for triagebot mention glob check)
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.
Tracking issue: #74265
This PR makes the safety documentation for raw pointer and NonNull
get_unchecked(_mut)APIs more consistent.Currently,
*mut [T]::get_unchecked_mutlinksout-of-bounds indexto theaddmethod, but the corresponding docs for*const[T]::get_uncheckedandNonNull<[T]>::get_unchecked_mutuse plain text for the same safety condition.This PR updates those two docs to link
out-of-bounds indexto#method.add, matching the existing wording and link style used by*mut [T]::get_unchecked_mut.This is a documentation-only change.
I also noticed that similar wording in the following APIs currently does not link
out-of-bounds index:I did not update those in this PR because I am not sure which target would be the most appropriate link for those APIs. If there is a preferred link target for these slice and
SliceIndexdocs, I would be happy to update them and merge the updates in this PR.