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

stabilize const_cell_into_inner #130972

Merged
merged 2 commits into from
Sep 29, 2024
Merged

Conversation

RalfJung
Copy link
Member

This const-stabilizes

  • UnsafeCell::into_inner
  • Cell::into_inner
  • RefCell::into_inner
  • OnceCell::into_inner

@rust-lang/wg-const-eval this uses rustc_allow_const_fn_unstable(const_precise_live_drops), so we'd be comitting to always finding some way to accept this code. IMO that's fine -- what these functions do is to move out the only field of a struct, and that struct has no destructor itself. The field's destructor does not get run as it gets returned to the caller.

@rust-lang/libs-api this was FCP'd already years ago, except that OnceCell::into_inner was added to the same feature gate since then (Cc @tgross35). Does that mean we have to re-run the FCP? If yes, I'd honestly prefer to move OnceCell into its own feature gate to not risk missing the next release. (That's why it's not great to add new functions to an already FCP'd feature gate.) OTOH if this needs an FCP either way since the previous FCP was so long ago, then we might as well do it all at once.

@rustbot
Copy link
Collaborator

rustbot commented Sep 28, 2024

r? @ibraheemdev

rustbot has assigned @ibraheemdev.
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

@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 28, 2024
@RalfJung RalfJung added the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Sep 28, 2024
@rust-log-analyzer

This comment has been minimized.

@RalfJung
Copy link
Member Author

Seems to be something with cranelift?

  [PATCH] "stdlib" <- "0027-stdlib-128bit-atomic-operations.patch"
  error: patch failed: library/core/src/cell.rs:2246
  error: library/core/src/cell.rs: patch does not apply
  hint: Use 'git am --show-current-patch=diff' to see the failed patch
  Patch failed at 0001 Disable 128bit atomic operations

Cc @bjorn3

@tgross35
Copy link
Contributor

@rust-lang/libs-api this was FCP'd already years ago, except that OnceCell::into_inner was added to the same feature gate since then (Cc @tgross35). Does that mean we have to re-run the FCP? If yes, I'd honestly prefer to move OnceCell into its own feature gate to not risk missing the next release. (That's why it's not great to add new functions to an already FCP'd feature gate.) OTOH if this needs an FCP either way since the previous FCP was so long ago, then we might as well do it all at once.

The OnceCell function signature is already stable, constness only makes use of UnsafeCell::into_inner which is under the same gate - it seemed entirely reasonable to keep the features together since libs-api needs to revisit the FCP in any case (and aiui, small adjustments to complete FCPs can happen with only consensus). But yes, if it is problematic then it can be split off.

@dtolnay dtolnay assigned dtolnay and unassigned ibraheemdev Sep 28, 2024
@dtolnay
Copy link
Member

dtolnay commented Sep 28, 2024

I would be happy to approve this including OnceCell::into_inner. I don't think another separate FCP is warranted.

Seems to be something with cranelift?

Please try deleting these lines:

diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs
index 58b9ba4..91bbd0a 100644
--- a/library/core/src/cell.rs
+++ b/library/core/src/cell.rs
@@ -2246,8 +2246,6 @@ unsafe_cell_primitive_into_inner! {
u32 "32"
i64 "64"
u64 "64"
- i128 "128"
- u128 "128"
isize "ptr"
usize "ptr"
}

@dtolnay dtolnay added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 28, 2024
@rustbot
Copy link
Collaborator

rustbot commented Sep 29, 2024

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

@dtolnay
Copy link
Member

dtolnay commented Sep 29, 2024

@bors r+

@bors
Copy link
Contributor

bors commented Sep 29, 2024

📌 Commit e1c09ec has been approved by dtolnay

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 29, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 29, 2024
…iaskrgr

Rollup of 4 pull requests

Successful merges:

 - rust-lang#123932 (restate GlobalAlloc method safety preconditions in terms of what the caller has to do for greater clarity)
 - rust-lang#129003 (Improve Ord docs)
 - rust-lang#130972 (stabilize const_cell_into_inner)
 - rust-lang#130990 (try to get rid of mir::Const::normalize)

r? `@ghost`
`@rustbot` modify labels: rollup
@RalfJung RalfJung added the relnotes Marks issues that should be documented in the release notes of the next release. label Sep 29, 2024
@bors bors merged commit a061e56 into rust-lang:master Sep 29, 2024
6 checks passed
@rustbot rustbot added this to the 1.83.0 milestone Sep 29, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Sep 29, 2024
Rollup merge of rust-lang#130972 - RalfJung:const_cell_into_inner, r=dtolnay

stabilize const_cell_into_inner

This const-stabilizes
- `UnsafeCell::into_inner`
- `Cell::into_inner`
- `RefCell::into_inner`
- `OnceCell::into_inner`

`@rust-lang/wg-const-eval` this uses `rustc_allow_const_fn_unstable(const_precise_live_drops)`, so we'd be comitting to always finding *some* way to accept this code. IMO that's fine -- what these functions do is to move out the only field of a struct, and that struct has no destructor itself. The field's destructor does not get run as it gets returned to the caller.

`@rust-lang/libs-api` this was FCP'd already [years ago](rust-lang#78729 (comment)), except that  `OnceCell::into_inner` was added to the same feature gate since then (Cc `@tgross35).` Does that mean we have to re-run the FCP? If yes, I'd honestly prefer to move `OnceCell` into its own feature gate to not risk missing the next release. (That's why it's not great to add new functions to an already FCP'd feature gate.) OTOH if this needs an FCP either way since the previous FCP was so long ago, then we might as well do it all at once.
@RalfJung RalfJung deleted the const_cell_into_inner branch September 30, 2024 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-libs-api-nominated Nominated for discussion during a libs-api team meeting. relnotes Marks issues that should be documented in the release notes of the next release. 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.

7 participants