-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Make slice::from_raw_parts[_mut] const #90011
Copy link
Copy link
Closed
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)T-langRelevant to the language teamRelevant to the language teamT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)T-langRelevant to the language teamRelevant to the language teamT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Currently,
core::slice::from_raw_partsis notconst, since it usesdebug_assert!with a non-constcheck:rust/library/core/src/slice/raw.rs
Line 89 in 5dab47d
is_aligned_and_not_nullcan't be madeconst, since it involves ptr->int cast to check the alignment:rust/library/core/src/intrinsics.rs
Lines 1950 to 1952 in 5dab47d
Recently
const_eval_selectintrinsic was implemented, it allows to run different code in CTFE and runtime. This, in turn, allows us to only make the alignment check in runtime and ignore it in the CTFE where it doesn't make much sense.See also: #67456
cc @rust-lang/lang, @rust-lang/libs and @rust-lang/wg-const-eval (it seems like use of
const_eval_selectrequires approval of all of the above teams)@rustbot label +T-lang +T-libs +A-const-eval +A-const-fn