Skip to content

Commit f02b6b0

Browse files
committed
platform: replace cfg-if with cfg_select
1 parent 75e373a commit f02b6b0

File tree

13 files changed

+48
-35
lines changed

13 files changed

+48
-35
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ libffi = "5.0.0"
108108

109109
byteorder = "1.5.0"
110110
byte-slice-cast = "1.2.2"
111-
cfg-if = "1.0.0"
112111
const_format = "0.2.33"
113112
fxhash = "0.2.1"
114113
tracing = "0.1.41"

native/nio/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ crate-type = ["rlib", "dylib"]
1414
jni.workspace = true
1515
native-macros.workspace = true
1616

17-
cfg-if.workspace = true
18-
1917
[target.'cfg(unix)'.dependencies]
2018
libc.workspace = true
2119

native/nio/src/channel/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ use jni::objects::JClass;
77
use jni::sys::jint;
88
use native_macros::jni_call;
99

10-
cfg_if::cfg_if! {
11-
if #[cfg(unix)] {
10+
cfg_select! {
11+
unix => {
1212
mod unix;
1313
pub use unix::*;
14-
} else if #[cfg(windows)] {
14+
}
15+
windows => {
1516
mod windows;
1617
pub use windows::*;
17-
} else {
18+
}
19+
_ => {
1820
compile_error!("Unsupported platform for libnio");
1921
}
2022
}

native/nio/src/channel/unix/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ use jni::objects::JClass;
55
use jni::sys::jint;
66
use native_macros::jni_call;
77

8-
cfg_if::cfg_if! {
9-
if #[cfg(target_os = "linux")] {
8+
cfg_select! {
9+
target_os = "linux" => {
1010
mod linux;
1111
pub use linux::*;
12-
} else if #[cfg(target_os = "macos")] {
12+
}
13+
target_os = "macos" => {
1314
mod macos;
1415
pub use macos::*;
1516
}

native/nio/src/fs/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
cfg_if::cfg_if! {
2-
if #[cfg(unix)] {
1+
cfg_select! {
2+
unix => {
33
mod unix;
44
pub use unix::*;
5-
} else if #[cfg(windows)] {
5+
}
6+
windows => {
67
mod windows;
78
pub use windows::*;
8-
} else {
9+
}
10+
_ => {
911
compile_error!("Unsupported platform for libnio");
1012
}
1113
}

native/nio/src/fs/unix/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#![allow(non_snake_case)]
22

3-
cfg_if::cfg_if! {
4-
if #[cfg(target_os = "linux")] {
3+
cfg_select! {
4+
target_os = "linux" => {
55
mod linux;
66
pub use linux::*;
7-
} else if #[cfg(target_os = "macos")] {
7+
}
8+
target_os = "macos" => {
89
mod macos;
910
pub use macos::*;
1011
}

native/nio/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![feature(custom_inner_attributes)]
22
#![feature(proc_macro_hygiene)]
3+
#![feature(cfg_select)]
34

45
pub mod channel;
56
pub mod fs;

platform/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ repository.workspace = true
99
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1010

1111
[dependencies]
12-
cfg-if.workspace = true
1312
libc.workspace = true
1413

1514
[target.'cfg(target_family = "windows")'.dependencies]

platform/src/arch/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
cfg_if::cfg_if! {
2-
if #[cfg(target_arch = "x86")] {
1+
cfg_select! {
2+
target_arch = "x86" => {
33
mod x86;
44
pub use x86::*;
5-
} else if #[cfg(target_arch = "x86_64")] {
5+
}
6+
target_arch = "x86_64" => {
67
mod x86;
78
pub use x86::*;
8-
} else {
9+
}
10+
_ => {
911
compile_error!("target architecture is not supported!");
1012
}
1113
}

platform/src/family/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@ pub mod properties;
77

88
// `target_family` specific exports
99

10-
cfg_if::cfg_if! {
11-
if #[cfg(unix)] {
10+
cfg_select! {
11+
unix => {
1212
mod unix;
1313
use unix as imp;
1414
pub use unix::*;
1515
pub use unix::signals::*;
16-
} else if #[cfg(windows)] {
16+
}
17+
windows => {
1718
mod windows;
1819
use windows as imp;
1920
pub use windows::*;
2021
pub use windows::signals::*;
21-
} else {
22+
}
23+
_ => {
2224
compile_error!("target family is not supported!");
2325
}
2426
}

0 commit comments

Comments
 (0)