Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Tracking Issue for const_ptr_write #86302

Open
5 of 8 tasks
usbalbin opened this issue Jun 14, 2021 · 10 comments
Open
5 of 8 tasks

Tracking Issue for const_ptr_write #86302

usbalbin opened this issue Jun 14, 2021 · 10 comments
Labels
C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@usbalbin
Copy link
Contributor

usbalbin commented Jun 14, 2021

Feature gate: #![feature(const_ptr_write)]

This is a tracking issue for making the functions ptr::write and ptr::write_unaligned, and the same methods on *mut T, const fn.

Public API

mod ptr {
    pub const unsafe fn write<T>(dst: *mut T, src: T);
    pub const unsafe fn write_unaligned<T>(dst: *mut T, src: T);
    pub const unsafe fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
}

impl<T> *mut T {
    pub const unsafe fn write(self, val: T);
    pub const unsafe fn write_unaligned(self, val: T);
    pub const unsafe fn write_bytes(self, val: u8, count: usize);
}

Steps / History

Related

Unresolved Questions

  • None yet.
@usbalbin usbalbin added C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Jun 14, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 23, 2021
Make `intrinsics::write_bytes` const

This is required to constify `MaybeUninit::zeroed` and `(*mut T)::write_bytes`.

Tracking issue: rust-lang#86302
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 11, 2021
Make `intrinsics::write_bytes` const

This is required to constify `MaybeUninit::zeroed` and `(*mut T)::write_bytes`.

Tracking issue: rust-lang#86302
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 11, 2021
Make `intrinsics::write_bytes` const

This is required to constify `MaybeUninit::zeroed` and `(*mut T)::write_bytes`.

Tracking issue: rust-lang#86302
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 12, 2021
…i-obk

Make `(*mut T)::write_bytes` `const`

Tracking issue: rust-lang#86302
@lilasta
Copy link
Contributor

lilasta commented Dec 13, 2021

core::intrinsics::write_bytes and (*mut T)::write_bytes have been constified: #90081 #91824

@SUPERCILEX
Copy link
Contributor

How does one initiate the FCP? Or are there any blockers?

@c410-f3r
Copy link
Contributor

AFAICT, there are no blockers so this feature can probably be stabilized.

@RalfJung
Copy link
Member

RalfJung commented Nov 10, 2023

How does stabilizing this help? You can't create mutable pointers in const on stable anyway...

@RalfJung
Copy link
Member

IOW, this is blocked on #57349 getting stabilized first.

@wyfo
Copy link

wyfo commented Aug 17, 2024

How does stabilizing this help? You can't create mutable pointers in const on stable anyway...

It seems you can with UnsafeCell::raw_get.

@RalfJung
Copy link
Member

Oh fun, another accidental stabilization...

Well, #57349 should be stable soon, so it's not worth de-stabilizing like we did with #80697.

@RalfJung
Copy link
Member

RalfJung commented Sep 4, 2024

@rust-lang/libs-api with #129195 in FCP, I'd like to get the ball rolling for stabilizing this feature as well, so that it can be released together with const_mut_refs. After all, what good is a mutable raw pointer if you cannot .write() it? Okay, you can use *ptr = ...;, and in const context we don't allow Drop types, so this can't cause destructor problems... but still, these functions seem like basic functionality to go with "you can have mutable pointers and references now", so would be nice to ship them all in one package.

So, can we get a t-libs-api FCP started for this? :)

@RalfJung RalfJung added the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Sep 4, 2024
@rfcbot
Copy link

rfcbot commented Sep 4, 2024

Team member @dtolnay has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Sep 4, 2024
@dtolnay dtolnay removed the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

8 participants