Closed
Description
The functions below in the standard library are const fn
with individual feature gates for calling them in constant expressions. This issue is tracking the stabilization of such calls.
CC #24111, the super-set feature which also includes defining new const fn
items.
std::sync::Once::new
core::cell::Cell::new
core::cell::RefCell::new
core::cell::UnsafeCell::new
core::sync::AtomicBool::new
core::sync::AtomicPtr::new
core::sync::Atomic$IntegerType::new
core::mem::size_of
core::mem::align_of
core::ptr::null
core::ptr::null_mut
<$IntegerType>::max_value
<$IntegerType>::min_value
Items in core::
are also re-exported in std::
.
Metadata
Metadata
Assignees
Labels
Blocker: Implemented in the nightly compiler and unstable.Category: An issue tracking the progress of sth. like the implementation of an RFCRelevant to the library API team, which will review and decide on the PR/issue.In the final comment period and will be merged soon unless new substantive objections are raised.
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
SimonSapin commentedon Nov 16, 2017
Feature gates are:
const_once_new
const_cell_new
const_refcell_new
const_unsafe_cell_new
const_size_of
const_align_of
const_ptr_null
const_ptr_null_mut
const_min_value
const_max_value
const_atomic_bool_new
const_atomic_ptr_new
const_atomic_i8_new
const_atomic_u8_new
const_atomic_i16_new
const_atomic_u16_new
const_atomic_i32_new
const_atomic_u32_new
const_atomic_i64_new
const_atomic_u64_new
const_atomic_isize_new
const_atomic_usize_new
aturon commentedon Nov 16, 2017
Kicking off stabilization discussion for the const-ness of these functions in
std
.@rfcbot fcp merge
rfcbot commentedon Nov 16, 2017
Team member @aturon has proposed to merge this. The next step is review by the rest of the tagged teams:
No concerns currently listed.
Once these reviewers reach consensus, 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 commentedon Nov 16, 2017
🔔 This is now entering its final comment period, as per the review above. 🔔
chabapok commentedon Nov 16, 2017
How to about mark std::time::Duration::{from_millis, new, from_secs, from_micros} as const_fn?
sfackler commentedon Nov 16, 2017
new can panic so it can't be const.
durka commentedon Nov 17, 2017
@sfackler sure it can, the same way an indexing expression can be const (panic turns into
const evaluation error
).sfackler commentedon Nov 18, 2017
@durka How?
eddyb commentedon Nov 18, 2017
I think this is "what is allowed right now" vs "what we could allow" (i.e. miri evaluates panics just fine).
durka commentedon Nov 18, 2017
SimonSapin commentedon Nov 18, 2017
There are many more
fn
s that could be madeconst
once miri lands, and we should definitely consider them then. This issue is specifically about those that are alreadyconst
, and stabilizing calls to them Very Soon®.rfcbot commentedon Nov 26, 2017
The final comment period is now complete.
Stabilize const-calling existing const-fns in std
SimonSapin commentedon Nov 26, 2017
I’ve submitted #46287
Rollup merge of rust-lang#46287 - SimonSapin:stable-constness, r=aturon
solutiontracking commentedon Mar 30, 2024