Skip to content

Clarify language around ptrs in slice::raw #129892

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Sep 3, 2024

Conversation

oskgo
Copy link
Contributor

@oskgo oskgo commented Sep 2, 2024

More specifically we explicitly mention that the pointer should be non-null as a top level requirement. Nullptrs are always valid for zero sized operations, so just validity (and alignment) does not guarantee non-nullness as implied in the existing docs.

We also explicitly call out ZSTs as an additional example where perhaps unintuitively alignment and non-nullness still have to hold.

Finally we change data in the range functions to start, which seems like a typo to me.

Touches docs for #89792

r? RalfJung

@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 Sep 2, 2024
@oskgo oskgo added A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools A-slice Area: `[T]` A-zst Area: Zero-sized types (ZSTs). labels Sep 2, 2024
@RalfJung
Copy link
Member

RalfJung commented Sep 2, 2024

Makes sense, thanks!

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Sep 2, 2024

📌 Commit 7494224 has been approved by RalfJung

It is now in the queue for this repository.

@bors bors 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 2, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Sep 2, 2024
…lfJung

Clarify language around ptrs in slice::raw

More specifically we explicitly mention that the pointer should be non-null as a top level requirement. Nullptrs are always valid for zero sized operations, so just validity (and alignment) does not guarantee non-nullness as implied in the existing docs.

We also explicitly call out ZSTs as an additional example where perhaps unintuitively alignment and non-nullness still have to hold.

Finally we change `data` in the range functions to `start`, which seems like a typo to me.

Touches docs for rust-lang#89792

r? RalfJung
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 2, 2024
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#129152 (custom/external clippy support for bootstrapping)
 - rust-lang#129529 (Add test to build crates used by r-a on stable)
 - rust-lang#129829 (Make decoding non-optional `LazyArray` panic if not set)
 - rust-lang#129860 (update `object` dependency to remove duplicate `wasmparser`)
 - rust-lang#129875 (chore: Fix typos in 'compiler' (batch 1))
 - rust-lang#129877 (chore: Fix typos in 'compiler' (batch 2))
 - rust-lang#129878 (chore: Fix typos in 'compiler' (batch 3))
 - rust-lang#129891 (Do not request sanitizers for naked functions)
 - rust-lang#129892 (Clarify language around ptrs in slice::raw)

Failed merges:

 - rust-lang#129777 (Add `unreachable_pub`, round 4)
 - rust-lang#129868 (Remove kobzol vacation status)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 2, 2024
…iaskrgr

Rollup of 12 pull requests

Successful merges:

 - rust-lang#129748 (Box validity: update for new zero-sized rules)
 - rust-lang#129829 (Make decoding non-optional `LazyArray` panic if not set)
 - rust-lang#129856 (compiler_fence documentation: emphasize synchronization, not reordering)
 - rust-lang#129868 (Remove kobzol vacation status)
 - rust-lang#129875 (chore: Fix typos in 'compiler' (batch 1))
 - rust-lang#129877 (chore: Fix typos in 'compiler' (batch 2))
 - rust-lang#129878 (chore: Fix typos in 'compiler' (batch 3))
 - rust-lang#129890 (Remove stray word in a comment)
 - rust-lang#129892 (Clarify language around ptrs in slice::raw)
 - rust-lang#129905 (mailmap: add new email for davidtwco)
 - rust-lang#129906 (mailmapper?)
 - rust-lang#129907 (Fix compile error in solid's remove_dir_all)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 9dad90a into rust-lang:master Sep 3, 2024
6 checks passed
@rustbot rustbot added this to the 1.83.0 milestone Sep 3, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Sep 3, 2024
Rollup merge of rust-lang#129892 - oskgo:clarify-slice-from-raw, r=RalfJung

Clarify language around ptrs in slice::raw

More specifically we explicitly mention that the pointer should be non-null as a top level requirement. Nullptrs are always valid for zero sized operations, so just validity (and alignment) does not guarantee non-nullness as implied in the existing docs.

We also explicitly call out ZSTs as an additional example where perhaps unintuitively alignment and non-nullness still have to hold.

Finally we change `data` in the range functions to `start`, which seems like a typo to me.

Touches docs for rust-lang#89792

r? RalfJung
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools A-slice Area: `[T]` A-zst Area: Zero-sized types (ZSTs). 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.

4 participants