Skip to content

alloc crate: shrink undocumented unsafe blocks - #162102

Open
DanielEScherzer wants to merge 1 commit into
rust-lang:mainfrom
DanielEScherzer:less-unsafe-in-alloc
Open

alloc crate: shrink undocumented unsafe blocks#162102
DanielEScherzer wants to merge 1 commit into
rust-lang:mainfrom
DanielEScherzer:less-unsafe-in-alloc

Conversation

@DanielEScherzer

Copy link
Copy Markdown
Contributor

Reduce the scope of unsafe blocks that are not yet documented by moving safe operations out of the blocks, making it easier to add the missing documentation in the future.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 1, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Reduce the scope of `unsafe` blocks that are not yet documented by moving safe
operations out of the blocks, making it easier to add the missing documentation
in the future.
@DanielEScherzer
DanielEScherzer marked this pull request as ready for review September 1, 2026 16:57
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 1, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Sep 1, 2026
@rustbot

rustbot commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

r? @JohnTitor

rustbot has assigned @JohnTitor.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

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 JohnTitor, Mark-Simulacrum, clarfonthey, joboet

@DanielEScherzer

DanielEScherzer commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Cross link #160941

r? @clarfonthey

@rustbot rustbot assigned clarfonthey and unassigned JohnTitor Sep 1, 2026
@clarfonthey

Copy link
Copy Markdown
Contributor

@bors r+ rollup

Thank you!

@rust-bors

rust-bors Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

📌 Commit b5e8344 has been approved by clarfonthey

It is now in the queue for this repository.

@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 Sep 1, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 1, 2026
…oc, r=clarfonthey

`alloc` crate: shrink undocumented `unsafe` blocks

Reduce the scope of `unsafe` blocks that are not yet documented by moving safe operations out of the blocks, making it easier to add the missing documentation in the future.
@DanielEScherzer

DanielEScherzer commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

@bors r+ rollup

Thank you!

Is it worth sending PRs to shrink unsafe blocks that are already documented? See rust-lang/git2-rs#1271 and rust-lang/git2-rs#1306 for what that looks like

@clarfonthey

Copy link
Copy Markdown
Contributor

I think in general we're fine with it if it's adding useful docs; discretion is always preferred here.

@DanielEScherzer

DanielEScherzer commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

I think in general we're fine with it if it's adding useful docs; discretion is always preferred here.

My question isn't about adding docs, but rather just moving what statements are included in unsafe blocks

I'll send a PR with some examples

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 1, 2026
…oc, r=clarfonthey

`alloc` crate: shrink undocumented `unsafe` blocks

Reduce the scope of `unsafe` blocks that are not yet documented by moving safe operations out of the blocks, making it easier to add the missing documentation in the future.
@clarfonthey

Copy link
Copy Markdown
Contributor

Oh, sorry, for some reason my thought process was that you might be splitting up a few unsafe blocks into multiple safety comments, which would require stricter review/need those comments to be written.

Absolutely, I think just moving more unsafe code out of them to really hone in on what's documented is helpful.

rust-bors Bot pushed a commit that referenced this pull request Sep 1, 2026
…uwer

Rollup of 11 pull requests

Successful merges:

 - #151618 (rustdoc: add `--print` option)
 - #161287 (Update `icu_list` dependency to 2.3)
 - #161767 (change DEFAULT_STACK_SIZE to be 32MB on s390x)
 - #161968 (Diverse offload fixes)
 - #161971 (Remove -Zsaturating-float-casts flag)
 - #162071 (Fix ICE of getting item name from RPITIT)
 - #161209 (Rework `next_power_of_two` to always be `1 << …`)
 - #162073 (Change some `Infallible` to `!` in std)
 - #162086 (Remove `gate_check` from `AttributeStability::Unstable`)
 - #162102 (`alloc` crate: shrink undocumented `unsafe` blocks)
 - #162110 (make it clear that Range cannot represent arbitrary ranges)
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.

5 participants