Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 1d61912

Browse files
committed
Move the existing "unstable" feature to "unstable-intrinsics"
Currently there is a single feature called "unstable" that is used to control whether intrinsics may be called. In anticipation of adding other unstable features that we will want to control separately, create a new feature called "unstable-intrinsics" that is enabled by "unstable". Then move everything gated by "unstable" to "unstable-intrinsics".
1 parent 2063e36 commit 1d61912

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ default = []
1818

1919
# This tells the compiler to assume that a Nightly toolchain is being used and
2020
# that it should activate any useful Nightly things accordingly.
21-
unstable = []
21+
unstable = ["unstable-intrinsics"]
22+
23+
# Enable calls to functions in `core::intrinsics`
24+
unstable-intrinsics = []
2225

2326
# Used to prevent using any intrinsics or arch-specific code.
2427
force-soft-floats = []

ci/run.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ fi
4949
if [ "${BUILD_ONLY:-}" = "1" ]; then
5050
cmd="cargo build --target $target --package libm"
5151
$cmd
52-
$cmd --features 'unstable'
52+
$cmd --features "unstable-intrinsics"
5353

5454
echo "can't run tests on $target"
5555
else
@@ -60,6 +60,6 @@ else
6060
$cmd --release
6161

6262
# unstable with a feature
63-
$cmd --features 'unstable'
64-
$cmd --release --features 'unstable'
63+
$cmd --features "unstable-intrinsics"
64+
$cmd --release --features "unstable-intrinsics"
6565
fi

crates/compiler-builtins-smoke-test/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ test = false
1010
bench = false
1111

1212
[features]
13+
# Duplicated from libm's Cargo.toml
1314
unstable = []
15+
unstable-intrinsics = []
1416
checked = []
1517
force-soft-floats = []

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! libm in pure Rust
22
#![no_std]
3-
#![cfg_attr(feature = "unstable", allow(internal_features))]
4-
#![cfg_attr(feature = "unstable", feature(core_intrinsics))]
3+
#![cfg_attr(feature = "unstable-intrinsics", allow(internal_features))]
4+
#![cfg_attr(feature = "unstable-intrinsics", feature(core_intrinsics))]
55
#![allow(clippy::assign_op_pattern)]
66
#![allow(clippy::deprecated_cfg_attr)]
77
#![allow(clippy::eq_op)]

src/math/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ macro_rules! i {
6060
// the time of this writing this is only used in a few places, and once
6161
// rust-lang/rust#72751 is fixed then this macro will no longer be necessary and
6262
// the native `/` operator can be used and panics won't be codegen'd.
63-
#[cfg(any(debug_assertions, not(feature = "unstable")))]
63+
#[cfg(any(debug_assertions, not(feature = "unstable-intrinsics")))]
6464
macro_rules! div {
6565
($a:expr, $b:expr) => {
6666
$a / $b
6767
};
6868
}
6969

70-
#[cfg(all(not(debug_assertions), feature = "unstable"))]
70+
#[cfg(all(not(debug_assertions), feature = "unstable-intrinsics"))]
7171
macro_rules! div {
7272
($a:expr, $b:expr) => {
7373
unsafe { core::intrinsics::unchecked_div($a, $b) }
@@ -76,7 +76,9 @@ macro_rules! div {
7676

7777
macro_rules! llvm_intrinsically_optimized {
7878
(#[cfg($($clause:tt)*)] $e:expr) => {
79-
#[cfg(all(feature = "unstable", not(feature = "force-soft-floats"), $($clause)*))]
79+
#[cfg(all(
80+
feature = "unstable-intrinsics", not(feature = "force-soft-floats"), $($clause)*
81+
))]
8082
{
8183
if true { // thwart the dead code lint
8284
$e

0 commit comments

Comments
 (0)