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_maybe_uninit_assume_init #86722

Closed
2 tasks done
usbalbin opened this issue Jun 29, 2021 · 23 comments · Fixed by #131274
Closed
2 tasks done

Tracking Issue for const_maybe_uninit_assume_init #86722

usbalbin opened this issue Jun 29, 2021 · 23 comments · Fixed by #131274
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. 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 29, 2021

Feature gate: #![feature(const_maybe_uninit_assume_init)]

This is a tracking issue for turning the methods assume_init, assume_init_ref, assume_init_mut, slice_assume_init_ref, slice_assume_init_mut of MaybeUninit into const fns. Note that the implementation of the latter two slice related methods are currently behind maybe_uninit_slice #63569, while the constness is behind const_maybe_uninit_assume_init.

Public API

impl<T> MaybeUninit<T> {
    pub const unsafe fn assume_init(self) -> T;
    pub const unsafe fn assume_init_ref(&self) -> &T;
    pub const unsafe fn assume_init_mut(&mut self) -> &mut T;
}

// These function impls are behind `maybe_uninit_slice` while the constnes is `const_maybe_uninit_assume_init` (this issue)
impl<T> MaybeUninit<T> {
    pub const unsafe fn slice_assume_init_ref(slice: &[Self]) -> &[T];
    pub const unsafe fn slice_assume_init_mut(slice: &mut [Self]) -> &mut [T];
}

Steps / History

Unresolved Questions

  • None yet.
@usbalbin usbalbin added C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Jun 29, 2021
@jhpratt
Copy link
Member

jhpratt commented Sep 28, 2021

@RalfJung @oli-obk there should be no issues stabilizing this, correct? I'm going through some things that can be stabilized as const and this seems like it would fall logically from the const union PR that has already been merged.

I was planning to stabilize assume_init and assume_init_ref, as assume_init_mut would be blocked on const mut refs with the two slice methods being unstable in general (the immutable one could have its rustc_const_unstable annotation removed, though).

@oli-obk
Copy link
Contributor

oli-obk commented Sep 28, 2021

we haven't stabilized transmute yet, all that is blocked on me finishing rust-lang/nomicon#221, then we can start the stabilization wave for unsafe const stuff

@jhpratt
Copy link
Member

jhpratt commented Sep 28, 2021

Was that not #85769?

@oli-obk
Copy link
Contributor

oli-obk commented Sep 28, 2021

🤦 I am completely lost at the moment on what is stabilized and what is not... I really need to update the skill tree...

Yea, those are trivial to replicate in bad ways on stable then... so we should stabilize them

@jhpratt
Copy link
Member

jhpratt commented Sep 29, 2021

It looks like a number of methods rely on dereferencing a raw pointer or reading one, all of which we don't want at compile-time for the time being due to some uncertainty, correct? If this is permissible, just say so and I can include them.

The one method that can clearly be stabilized without issue is assume_init (with array_assume_init being able to be stabilized with the method itself).

@oli-obk
Copy link
Contributor

oli-obk commented Sep 29, 2021

We should stabilize raw pointer deref, otherwise ppl will start transmuting raw pointers to references and dereferencing those

@jhpratt
Copy link
Member

jhpratt commented Sep 29, 2021

Just sent Ralf a PM on Zulip asking him to check this out. I recall him having an objection to something of the sort when stabilizing const transmutes — I believe we initially wanted a lint.

@RalfJung
Copy link
Member

Yeah there was the idea of having a lint against ptr-to-int transmutes.

My only concern with raw pointers is how and where to document that type-punning loads (i.e., raw-ptr-based transmutes) of pointers to integers are considered UB during CTFE.

@jhpratt
Copy link
Member

jhpratt commented Sep 30, 2021

So raw pointer deref could be stabilized, correct? Dereferencing raw pointers is unsafe to begin with, so documenting that shouldn't be an issue.

@RalfJung
Copy link
Member

so documenting that shouldn't be an issue.

Where would you put that documentation though? And would anyone actually read it?^^

But, yeah, just from an implementation perspective I can't think of any reason how raw ptr deref could screw us now that we have stabilized transmutes and union field accesses.

@jhpratt
Copy link
Member

jhpratt commented Sep 30, 2021

I removed bit of my comment that because I realized it was orthogonal to this issue. Sounds good though 👍

@KamilaBorowska
Copy link
Contributor

Is there anything blocking stabilization of const MaybeUninit::assume_init and const MaybeUninit::assume_init_ref at this point?

@jhpratt
Copy link
Member

jhpratt commented Nov 22, 2021

It's in FCP right now!

@KamilaBorowska
Copy link
Contributor

Oh, didn't realize the FCP is going on in #90896.

@workingjubilee workingjubilee added the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Sep 19, 2024
@workingjubilee
Copy link
Member

workingjubilee commented Sep 19, 2024

We have the option of const-stabilizing assume_init_mut: #86722

@dtolnay
Copy link
Member

dtolnay commented Sep 19, 2024

@rfcbot fcp merge

assume_init and assume_init_ref were const-stabilized already by #90896.

This FCP proposes const-stabilizing assume_init_mut, which has been unblocked by #129195.

Further, it proposes moving the const-stability of slice_assume_init_ref and slice_assume_init_mut, which are still unstable, out of this tracking issue over to those functions' main tracking issue, and this one can be closed. When or if these functions get stabilized in the future, they can be const-stabilized at the same time.

@rfcbot
Copy link

rfcbot commented Sep 19, 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 19, 2024
@dtolnay dtolnay removed the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Sep 19, 2024
@rfcbot rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Sep 24, 2024
@rfcbot
Copy link

rfcbot commented Sep 24, 2024

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Oct 4, 2024
@rfcbot
Copy link

rfcbot commented Oct 4, 2024

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

@RalfJung
Copy link
Member

RalfJung commented Oct 4, 2024

@workingjubilee is there a reason this is not part of your big const stabilization PR?
It doesn't seem to have an open PR at all right now.

@workingjubilee
Copy link
Member

@RalfJung No reason, I think! Slipped through the cracks because I am merely mortal.

@workingjubilee
Copy link
Member

workingjubilee commented Oct 5, 2024

Oh, I think I missed this because I looked for features, when stabilizing things, with actual issue numbers in the code... this thing had never gotten its correct issue number assigned in the code.

@RalfJung
Copy link
Member

RalfJung commented Oct 5, 2024

Oh lol this had issue = "none"? I guess someone forgot to note down the tracking issue.^^

Thanks for making a PR!

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 13, 2024
…hat-got-away, r=scottmcm

library: Const-stabilize `MaybeUninit::assume_init_mut`

FCP completed in rust-lang#86722 (comment)

Also moves const-ness of an unstable fn under the `maybe_uninit_slice` gate, Cc rust-lang#63569
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 14, 2024
…hat-got-away, r=scottmcm

library: Const-stabilize `MaybeUninit::assume_init_mut`

FCP completed in rust-lang#86722 (comment)

Also moves const-ness of an unstable fn under the `maybe_uninit_slice` gate, Cc rust-lang#63569
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Oct 14, 2024
Rollup merge of rust-lang#131274 - workingjubilee:stabilize-the-one-that-got-away, r=scottmcm

library: Const-stabilize `MaybeUninit::assume_init_mut`

FCP completed in rust-lang#86722 (comment)

Also moves const-ness of an unstable fn under the `maybe_uninit_slice` gate, Cc rust-lang#63569
RalfJung pushed a commit to RalfJung/miri that referenced this issue Oct 14, 2024
…way, r=scottmcm

library: Const-stabilize `MaybeUninit::assume_init_mut`

FCP completed in rust-lang/rust#86722 (comment)

Also moves const-ness of an unstable fn under the `maybe_uninit_slice` gate, Cc rust-lang/rust#63569
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Oct 17, 2024
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Dec 2, 2024
…nit_write, r=RalfJung,dtolnay

Stabilize `const_maybe_uninit_write`

Mark the following API const stable:

```rust
impl<T> MaybeUninit<T> {
    pub const fn write(&mut self, val: T) -> &mut T;
}
```

This depends on `const_mut_refs` and [`const_maybe_uninit_assume_init`](rust-lang#86722), both of which have recently been stabilized.

Closes: <rust-lang#63567>
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Dec 3, 2024
Rollup merge of rust-lang#131713 - tgross35:stabilize-const_maybe_uninit_write, r=RalfJung,dtolnay

Stabilize `const_maybe_uninit_write`

Mark the following API const stable:

```rust
impl<T> MaybeUninit<T> {
    pub const fn write(&mut self, val: T) -> &mut T;
}
```

This depends on `const_mut_refs` and [`const_maybe_uninit_assume_init`](rust-lang#86722), both of which have recently been stabilized.

Closes: <rust-lang#63567>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants