Description
Currently, core::slice::from_raw_parts
is not const
, since it uses debug_assert!
with a non-const
check:
rust/library/core/src/slice/raw.rs
Line 89 in 5dab47d
is_aligned_and_not_null
can't be made const
, 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_select
intrinsic 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_select
requires approval of all of the above teams)
@rustbot label +T-lang +T-libs +A-const-eval +A-const-fn