Skip to content

Add safety section for SliceIndex::get_unchecked(mut)#158382

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
yilin0518:fix_slice_index
Jun 27, 2026
Merged

Add safety section for SliceIndex::get_unchecked(mut)#158382
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
yilin0518:fix_slice_index

Conversation

@yilin0518

Copy link
Copy Markdown
Contributor

This PR adds # Safety sections to the documentation for the unsafe SliceIndex::get_unchecked and SliceIndex::get_unchecked_mut trait methods.

The existing documentation already described the undefined behavior conditions for out-of-bounds indices and dangling slice pointers. This change keeps that content unchanged, but moves it under the standard rustdoc # Safety heading expected for unsafe functions.

No behavior changes.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 25, 2026
@rustbot

rustbot commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @clarfonthey (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue
Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 12 candidates
  • Random selection from 6 candidates

@clarfonthey

Copy link
Copy Markdown
Contributor

Discussed this with a few people; even though this is unstable documentation, this is strictly an improvement, and this documentation is still public even though it's for an unstable method.

@bors r+ rollup=always

@rust-bors

rust-bors Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 0d2070c has been approved by clarfonthey

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 1. This pull request will be tested once the tree is reopened.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 26, 2026
rust-bors Bot pushed a commit that referenced this pull request Jun 26, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #153697 (Add arg splat experiment initial tuple impl)
 - #158360 (Various borrowck cleanups and param_env/opaque_types_defined_by query simplifications for typeck children)
 - #158438 (Use rigidness marker in fast_reject)
 - #157127 (cg_LLVM: Stop needing an alloca for volatile loads)
 - #158376 (Suggest `>=` for `=>` typo in closure and call argument positions)
 - #158185 (perf: Make stable_crate_ids reads lock-free after crate loading)
 - #158244 (Attribute docs `deprecated` , `warn`, `allow`, `cfg`, `deny`, and `forbid` )
 - #158355 (Fixup the refactoring errors in #156246)
 - #158361 (Move `check_ffi_pure` into the attribute parser)
 - #158382 (Add safety section for SliceIndex::get_unchecked(mut))
 - #158399 (std: truncate thread names on NetBSD)
 - #158418 (Eliminate double length check in `Vec::into_array`)
 - #158430 (Guard clone suggestion against empty obligation errors)
 - #158446 (Update Enzyme submodule)
 - #158448 (Cleanup `NumBuffer` comment and replace `ilog(10)` with `ilog10()`)
rust-bors Bot pushed a commit that referenced this pull request Jun 26, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #153697 (Add arg splat experiment initial tuple impl)
 - #158360 (Various borrowck cleanups and param_env/opaque_types_defined_by query simplifications for typeck children)
 - #158438 (Use rigidness marker in fast_reject)
 - #157127 (cg_LLVM: Stop needing an alloca for volatile loads)
 - #158376 (Suggest `>=` for `=>` typo in closure and call argument positions)
 - #158185 (perf: Make stable_crate_ids reads lock-free after crate loading)
 - #158244 (Attribute docs `deprecated` , `warn`, `allow`, `cfg`, `deny`, and `forbid` )
 - #158355 (Fixup the refactoring errors in #156246)
 - #158361 (Move `check_ffi_pure` into the attribute parser)
 - #158382 (Add safety section for SliceIndex::get_unchecked(mut))
 - #158399 (std: truncate thread names on NetBSD)
 - #158418 (Eliminate double length check in `Vec::into_array`)
 - #158430 (Guard clone suggestion against empty obligation errors)
 - #158446 (Update Enzyme submodule)
 - #158448 (Cleanup `NumBuffer` comment and replace `ilog(10)` with `ilog10()`)
rust-bors Bot pushed a commit that referenced this pull request Jun 27, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #153697 (Add arg splat experiment initial tuple impl)
 - #158360 (Various borrowck cleanups and param_env/opaque_types_defined_by query simplifications for typeck children)
 - #158438 (Use rigidness marker in fast_reject)
 - #157127 (cg_LLVM: Stop needing an alloca for volatile loads)
 - #158376 (Suggest `>=` for `=>` typo in closure and call argument positions)
 - #158185 (perf: Make stable_crate_ids reads lock-free after crate loading)
 - #158244 (Attribute docs `deprecated` , `warn`, `allow`, `cfg`, `deny`, and `forbid` )
 - #158355 (Fixup the refactoring errors in #156246)
 - #158361 (Move `check_ffi_pure` into the attribute parser)
 - #158382 (Add safety section for SliceIndex::get_unchecked(mut))
 - #158399 (std: truncate thread names on NetBSD)
 - #158418 (Eliminate double length check in `Vec::into_array`)
 - #158430 (Guard clone suggestion against empty obligation errors)
 - #158446 (Update Enzyme submodule)
 - #158448 (Cleanup `NumBuffer` comment and replace `ilog(10)` with `ilog10()`)
@rust-bors rust-bors Bot merged commit d940e7e into rust-lang:main Jun 27, 2026
13 checks passed
@rustbot rustbot added this to the 1.98.0 milestone Jun 27, 2026
rust-timer added a commit that referenced this pull request Jun 27, 2026
Rollup merge of #158382 - yilin0518:fix_slice_index, r=clarfonthey

Add safety section for SliceIndex::get_unchecked(mut)

This PR adds `# Safety` sections to the documentation for the unsafe `SliceIndex::get_unchecked` and `SliceIndex::get_unchecked_mut` trait methods.

The existing documentation already described the undefined behavior conditions for out-of-bounds indices and dangling slice pointers. This change keeps that content unchanged, but moves it under the standard rustdoc `# Safety` heading expected for unsafe functions.

No behavior changes.
pull Bot pushed a commit to LeeeeeeM/miri that referenced this pull request Jun 27, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - rust-lang/rust#153697 (Add arg splat experiment initial tuple impl)
 - rust-lang/rust#158360 (Various borrowck cleanups and param_env/opaque_types_defined_by query simplifications for typeck children)
 - rust-lang/rust#158438 (Use rigidness marker in fast_reject)
 - rust-lang/rust#157127 (cg_LLVM: Stop needing an alloca for volatile loads)
 - rust-lang/rust#158376 (Suggest `>=` for `=>` typo in closure and call argument positions)
 - rust-lang/rust#158185 (perf: Make stable_crate_ids reads lock-free after crate loading)
 - rust-lang/rust#158244 (Attribute docs `deprecated` , `warn`, `allow`, `cfg`, `deny`, and `forbid` )
 - rust-lang/rust#158355 (Fixup the refactoring errors in rust-lang/rust#156246)
 - rust-lang/rust#158361 (Move `check_ffi_pure` into the attribute parser)
 - rust-lang/rust#158382 (Add safety section for SliceIndex::get_unchecked(mut))
 - rust-lang/rust#158399 (std: truncate thread names on NetBSD)
 - rust-lang/rust#158418 (Eliminate double length check in `Vec::into_array`)
 - rust-lang/rust#158430 (Guard clone suggestion against empty obligation errors)
 - rust-lang/rust#158446 (Update Enzyme submodule)
 - rust-lang/rust#158448 (Cleanup `NumBuffer` comment and replace `ilog(10)` with `ilog10()`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants