Skip to content

Commit 4aca0b8

Browse files
authored
Unrolled build for #145689
Rollup merge of #145689 - cuviper:panic_unwind-cfg, r=joshtriplett Migrate `panic_unwind` to use `cfg_select!` This follows #145489 with an additional place we can drop the `cfg-if` dependency.
2 parents 6ba0ce4 + d41cd48 commit 4aca0b8

File tree

4 files changed

+20
-14
lines changed

4 files changed

+20
-14
lines changed

library/Cargo.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ name = "panic_unwind"
192192
version = "0.0.0"
193193
dependencies = [
194194
"alloc",
195-
"cfg-if",
196195
"libc",
197196
"rustc-std-workspace-core",
198197
"unwind",

library/panic_unwind/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ doc = false
1313

1414
[dependencies]
1515
alloc = { path = "../alloc" }
16-
cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
1716
core = { path = "../rustc-std-workspace-core", package = "rustc-std-workspace-core" }
1817
unwind = { path = "../unwind" }
1918

library/panic_unwind/src/lib.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#![unstable(feature = "panic_unwind", issue = "32837")]
1616
#![doc(issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")]
1717
#![feature(cfg_emscripten_wasm_eh)]
18+
#![feature(cfg_select)]
1819
#![feature(core_intrinsics)]
1920
#![feature(lang_items)]
2021
#![feature(panic_unwind)]
@@ -33,38 +34,44 @@ use alloc::boxed::Box;
3334
use core::any::Any;
3435
use core::panic::PanicPayload;
3536

36-
cfg_if::cfg_if! {
37-
if #[cfg(all(target_os = "emscripten", not(emscripten_wasm_eh)))] {
37+
cfg_select! {
38+
all(target_os = "emscripten", not(emscripten_wasm_eh)) => {
3839
#[path = "emcc.rs"]
3940
mod imp;
40-
} else if #[cfg(target_os = "hermit")] {
41+
}
42+
target_os = "hermit" => {
4143
#[path = "hermit.rs"]
4244
mod imp;
43-
} else if #[cfg(target_os = "l4re")] {
45+
}
46+
target_os = "l4re" => {
4447
// L4Re is unix family but does not yet support unwinding.
4548
#[path = "dummy.rs"]
4649
mod imp;
47-
} else if #[cfg(any(
50+
}
51+
any(
4852
all(target_family = "windows", target_env = "gnu"),
4953
target_os = "psp",
5054
target_os = "xous",
5155
target_os = "solid_asp3",
5256
all(target_family = "unix", not(any(target_os = "espidf", target_os = "nuttx"))),
5357
all(target_vendor = "fortanix", target_env = "sgx"),
5458
target_family = "wasm",
55-
))] {
59+
) => {
5660
#[path = "gcc.rs"]
5761
mod imp;
58-
} else if #[cfg(miri)] {
62+
}
63+
miri => {
5964
// Use the Miri runtime on Windows as miri doesn't support funclet based unwinding,
6065
// only landingpad based unwinding. Also use the Miri runtime on unsupported platforms.
6166
#[path = "miri.rs"]
6267
mod imp;
63-
} else if #[cfg(all(target_env = "msvc", not(target_arch = "arm")))] {
68+
}
69+
all(target_env = "msvc", not(target_arch = "arm")) => {
6470
// LLVM does not support unwinding on 32 bit ARM msvc (thumbv7a-pc-windows-msvc)
6571
#[path = "seh.rs"]
6672
mod imp;
67-
} else {
73+
}
74+
_ => {
6875
// Targets that don't support unwinding.
6976
// - os=none ("bare metal" targets)
7077
// - os=uefi

library/panic_unwind/src/seh.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,11 @@ macro_rules! define_cleanup {
289289
}
290290
}
291291
}
292-
cfg_if::cfg_if! {
293-
if #[cfg(target_arch = "x86")] {
292+
cfg_select! {
293+
target_arch = "x86" => {
294294
define_cleanup!("thiscall" "thiscall-unwind");
295-
} else {
295+
}
296+
_ => {
296297
define_cleanup!("C" "C-unwind");
297298
}
298299
}

0 commit comments

Comments
 (0)