Skip to content

Commit 6d00234

Browse files
committed
fix: Ensure that const extern fn is always enabled
In [1] this conditional was dropped in favor of a Cargo feature, which was turned on by default in [2]. Fixes: #4149 [1]: #4105 [2]: #4134
1 parent f553033 commit 6d00234

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

Cargo.toml

+1-5
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,10 @@ cargo-args = ["-Zbuild-std=core"]
135135
rustc-std-workspace-core = { version = "1.0.0", optional = true }
136136

137137
[features]
138-
default = ["const-extern-fn", "std"]
138+
default = ["std"]
139139
std = []
140140
rustc-dep-of-std = ["rustc-std-workspace-core"]
141141
extra_traits = []
142142

143-
# `const-extern-function` is deprecated and no longer does anything
144-
# FIXME(1.0): remove this completely
145-
const-extern-fn = []
146-
147143
[workspace]
148144
members = ["libc-test"]

build.rs

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const ALLOWED_CFGS: &'static [&'static str] = &[
1313
"freebsd13",
1414
"freebsd14",
1515
"freebsd15",
16+
// FIXME(ctest): this config shouldn't be needed but ctest can't parse `const extern fn`
17+
"libc_const_extern_fn",
1618
"libc_deny_warnings",
1719
"libc_ctest",
1820
];
@@ -74,6 +76,8 @@ fn main() {
7476
set_cfg("libc_deny_warnings");
7577
}
7678

79+
set_cfg("libc_const_extern_fn");
80+
7781
// check-cfg is a nightly cargo/rustc feature to warn when unknown cfgs are used across the
7882
// codebase. libc can configure it if the appropriate environment variable is passed. Since
7983
// rust-lang/rust enforces it, this is useful when using a custom libc fork there.

src/macros.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ macro_rules! e {
199199
// cfg completely.
200200
// FIXME(ctest): ctest can't handle `$(,)?` so we use `$(,)*` which isn't quite correct.
201201
cfg_if! {
202-
if #[cfg(feature = "const-extern-fn")] {
202+
if #[cfg(libc_const_extern_fn)] {
203+
// if #[cfg(feature = "const-extern-fn")] {
203204
/// Define an `unsafe` function that is const as long as `const-extern-fn` is enabled.
204205
macro_rules! f {
205206
($(

0 commit comments

Comments
 (0)