Skip to content

Make NonNull::{read,write}_volatile unstably const. - #164051

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
kpreid:nonnull-volatile
Oct 10, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
kpreid:nonnull-volatile

Conversation

@kpreid

@kpreid kpreid commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

#159092 added const to the functions read_volatile and write_volatile for core::ptr, *const T, and *mut T. This PR expands that to NonNull<T>, under the same feature const_volatile.

Tracking issue: #159094
cc @RalfJung

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

rustbot commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

r? @clarfonthey

rustbot has assigned @clarfonthey.
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, aapoalas, clarfonthey

@RalfJung

RalfJung commented Oct 9, 2026

Copy link
Copy Markdown
Member

Makes sense, thanks!

Can you add it to the tracking issue as well?

@clarfonthey

Copy link
Copy Markdown
Contributor

Huh, so, these were implemented in consteval/miri already and just weren't turned on? Confused why only these methods need the const stability tagged.

@kpreid

kpreid commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Can you add it to the tracking issue as well?

I am not a project member and cannot edit issue descriptions.

Huh, so, these were implemented in consteval/miri already and just weren't turned on? Confused why only these methods need the const stability tagged.

NonNull<T> is a wrapper struct and these methods are delegating to its (approximately) *const T field. All this PR is doing is making each wrapper method the same as the method it calls, which is already const fn. I would presume that Miri and const eval do not know anything about NonNull (but I could be wrong).

@clarfonthey

Copy link
Copy Markdown
Contributor

Oh, right, of course. For some reason I thought these were just the regular pointer methods. 🤦🏻

@clarfonthey clarfonthey mentioned this pull request Oct 9, 2026
2 of 5 tasks
@clarfonthey

Copy link
Copy Markdown
Contributor

Updated the tracking issue for you, and also these look good to me. Thank you!

@bors r+ rollup

@rust-bors

rust-bors Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 012f64d 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 Oct 9, 2026
@rust-bors

rust-bors Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

rust-bors Bot pushed a commit that referenced this pull request Oct 10, 2026
Make `NonNull::{read,write}_volatile` unstably const.

#159092 added `const` to the functions `read_volatile` and `write_volatile` for `core::ptr`, `*const T`, and `*mut T`. This PR expands that to `NonNull<T>`, under the same feature `const_volatile`.

Tracking issue: #159094
cc @RalfJung
@jhpratt

jhpratt commented Oct 10, 2026

Copy link
Copy Markdown
Member

@bors yield to rollup

@rust-bors

rust-bors Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Auto build was cancelled. Cancelled workflows:

The next pull request likely to be tested is #164067.

rust-bors Bot pushed a commit that referenced this pull request Oct 10, 2026
Rollup of 3 pull requests

Successful merges:

 - #164051 (Make `NonNull::{read,write}_volatile` unstably const.)
 - #154170 (Stabilize `ptr::try_cast_aligned`)
 - #163975 (std: remove unnecessary sysctl caching on FreeBSD)
@rust-bors
rust-bors Bot merged commit 6dc9080 into rust-lang:main Oct 10, 2026
14 of 15 checks passed
rust-bors Bot pushed a commit that referenced this pull request Oct 10, 2026
Rollup merge of #164051 - kpreid:nonnull-volatile, r=clarfonthey

Make `NonNull::{read,write}_volatile` unstably const.

#159092 added `const` to the functions `read_volatile` and `write_volatile` for `core::ptr`, `*const T`, and `*mut T`. This PR expands that to `NonNull<T>`, under the same feature `const_volatile`.

Tracking issue: #159094
cc @RalfJung
@rustbot rustbot added this to the 1.101.0 milestone Oct 10, 2026
@kpreid
kpreid deleted the nonnull-volatile branch October 10, 2026 18:13
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