make RefCell unstably const by Daniel-Aaron-Bloom · Pull Request #137843 · rust-lang/rust (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation45 Commits1 Checks10 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
Now that we can do interior mutability in const, most of the RefCell API can be const fn. The main exceptions are APIs which use FnOnce (RefCell::replace_with and Ref[Mut]::[filter_]map[_split]) and RefCell::take which calls Default::default.
Tracking issue: #137844
r? @Amanieu
rustbot has assigned @Amanieu.
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 added S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
Relevant to the library team, which will review and decide on the PR/issue.
labels
Daniel-Aaron-Bloom changed the title
Draft: make Cell more unstably const make RefCell more unstably const
@rustbot label -T-libs +T-libs-api
r? libs-api
rustbot added T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
and removed T-libs
Relevant to the library team, which will review and decide on the PR/issue.
labels
Daniel-Aaron-Bloom changed the title
make RefCell more unstably const make RefCell unstably const
Cc @rust-lang/wg-const-eval
The main problem is dropping. Please make sure to also add a test actually using a RefCell; that will probably not work since the Ref/RefMut Drop impls are not const.
@compiler-errors what is the state of Drop in const? Can one impl const Drop and it will "just work"? Are const Destruct bounds ready for use in std (for APIs that are stable but const-unstable)?
Since we probably all want to hear the answer to that question...
cc @rust-lang/lang
Are
const Destructbounds ready for use in std (for APIs that are stable but const-unstable)?
No. Until we know what const traits syntax to implement, adding more const trait impls is not something we want. The libstd churn is not worth it
Can one
impl const Dropand it will "just work"?
Yes
@Daniel-Aaron-Bloom okay so please remove the fn const_drop hack and instead try impl const Drop for BorrowRef and BorrowRefMut. If that does not work, then I think it is better to wait until that works; nobody will be able to use RefCell in const otherwise anyway (not even on nightly).
Should I also remove try to remove my added private function RefMut::as_mut and use const_deref instead?
Oh that's what those functions are for?
Sure, seems fine to me as long no incomplete nightly features have to be enabled for this.
This comment has been minimized.
Status: Blocked on something else such as an RFC or other implementation work.
label
📌 Commit 1f1000f has been approved by oli-obk
It is now in the queue for this repository.
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
bors added a commit that referenced this pull request
…rors
Rollup of 18 pull requests
Successful merges:
- #137843 (make RefCell unstably const)
- #140942 (const-eval: allow constants to refer to mutable/external memory, but reject such constants as patterns)
- #142549 (small iter.intersperse.fold() optimization)
- #142637 (Remove some glob imports from the type system)
- #142647 ([perf] Compute hard errors without diagnostics in impl_intersection_has_impossible_obligation)
- #142700 (Remove incorrect comments in
Weak) - #142927 (Add note to
find_const_ty_from_env) - #142967 (Fix RwLock::try_write documentation for WouldBlock condition)
- #142986 (Port
#[export_name]to the new attribute parsing infrastructure) - #143001 (Rename run always )
- #143010 (Update
browser-ui-testversion to0.20.7) - #143015 (Add
sym::macro_pindiagnostic item forcore::pin::pin!()) - #143033 (Expand const-stabilized API links in relnotes)
- #143041 (Remove cache for citool)
- #143056 (Move an ACE test out of the GCI directory)
- #143059 (Fix 1.88 relnotes)
- #143067 (Tracking issue number for
iter_macro) - #143073 (Fix some fixmes that were waiting for let chains)
Failed merges:
- #143020 (codegen_fn_attrs: make comment more precise)
r? @ghost
@rustbot modify labels: rollup
rust-timer added a commit that referenced this pull request
Rollup merge of #137843 - Daniel-Aaron-Bloom:const_cell, r=oli-obk
make RefCell unstably const
Now that we can do interior mutability in const, most of the RefCell API can be const fn. The main exceptions are APIs which use FnOnce (RefCell::replace_with and Ref[Mut]::[filter_]map[_split]) and RefCell::take which calls Default::default.
Tracking issue: #137844
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request
…li-obk
make RefCell unstably const
Now that we can do interior mutability in const, most of the RefCell API can be const fn. The main exceptions are APIs which use FnOnce (RefCell::replace_with and Ref[Mut]::[filter_]map[_split]) and RefCell::take which calls Default::default.
Tracking issue: rust-lang#137844
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request
Labels
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Relevant to the library API team, which will review and decide on the PR/issue.