Skip to content

Commit 6ae1bec

Browse files
authored
Rollup merge of rust-lang#77170 - ecstatic-morse:const-fn-ptr, r=oli-obk
Remove `#[rustc_allow_const_fn_ptr]` and add `#![feature(const_fn_fn_ptr_basics)]` `rustc_allow_const_fn_ptr` was a hack to work around the lack of an escape hatch for the "min `const fn`" checks in const-stable functions. Now that we have co-opted `allow_internal_unstable` for this purpose, we no longer need a bespoke attribute. Now this functionality is gated under `const_fn_fn_ptr_basics` (how concise!), and `#[allow_internal_unstable(const_fn_fn_ptr_basics)]` replaces `#[rustc_allow_const_fn_ptr]`. `const_fn_fn_ptr_basics` allows function pointer types to appear in the arguments and locals of a `const fn` as well as function pointer casts to be performed inside a `const fn`. Both of these were allowed in constants and statics already. Notably, this does **not** allow users to invoke function pointers in a const context. Presumably, we will use a nicer name for that (`const_fn_ptr`?). r? @oli-obk
2 parents 079acd0 + 296f938 commit 6ae1bec

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

core/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
#![feature(const_fn_union)]
8484
#![feature(const_fn)]
8585
#![cfg_attr(not(bootstrap), feature(const_fn_floating_point_arithmetic))]
86+
#![cfg_attr(not(bootstrap), feature(const_fn_fn_ptr_basics))]
8687
#![feature(const_generics)]
8788
#![feature(const_option)]
8889
#![feature(const_precise_live_drops)]

core/src/task/wake.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,9 @@ impl RawWakerVTable {
129129
/// associated task.
130130
#[rustc_promotable]
131131
#[stable(feature = "futures_api", since = "1.36.0")]
132-
// `rustc_allow_const_fn_ptr` is a hack that should not be used anywhere else
133-
// without first consulting with T-Lang.
134-
//
135-
// FIXME: remove whenever we have a stable way to accept fn pointers from const fn
136-
// (see https://github.com/rust-rfcs/const-eval/issues/19#issuecomment-472799062)
137-
#[rustc_allow_const_fn_ptr]
138132
#[rustc_const_stable(feature = "futures_api", since = "1.36.0")]
133+
#[cfg_attr(not(bootstrap), allow_internal_unstable(const_fn_fn_ptr_basics))]
134+
#[cfg_attr(bootstrap, rustc_allow_const_fn_ptr)]
139135
pub const fn new(
140136
clone: unsafe fn(*const ()) -> RawWaker,
141137
wake: unsafe fn(*const ()),

proc_macro/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#![feature(nll)]
2222
#![feature(staged_api)]
2323
#![feature(const_fn)]
24+
#![cfg_attr(not(bootstrap), feature(const_fn_fn_ptr_basics))]
2425
#![feature(allow_internal_unstable)]
2526
#![feature(decl_macro)]
2627
#![feature(extern_types)]

std/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@
239239
#![cfg_attr(not(bootstrap), feature(const_fn_floating_point_arithmetic))]
240240
#![feature(const_fn_transmute)]
241241
#![feature(const_fn)]
242+
#![cfg_attr(not(bootstrap), feature(const_fn_fn_ptr_basics))]
242243
#![feature(const_ip)]
243244
#![feature(const_ipv6)]
244245
#![feature(const_raw_ptr_deref)]

0 commit comments

Comments
 (0)