Skip to content

Commit e09e887

Browse files
committed
Add test and fix parsing/gating
1 parent 8b3e945 commit e09e887

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

src/cargo/core/compiler/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,6 +1234,9 @@ fn build_base_args(
12341234
if *panic != PanicStrategy::Unwind {
12351235
cmd.arg("-C").arg(format!("panic={}", panic));
12361236
}
1237+
if *panic == PanicStrategy::ImmediateAbort {
1238+
cmd.arg("-Z").arg("unstable-options");
1239+
}
12371240

12381241
cmd.args(&lto_args(build_runner, unit));
12391242

src/cargo/core/features.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,7 @@ unstable_cli_options!(
890890
skip_rustdoc_fingerprint: bool,
891891
target_applies_to_host: bool = ("Enable the `target-applies-to-host` key in the .cargo/config.toml file"),
892892
trim_paths: bool = ("Enable the `trim-paths` option in profiles"),
893+
panic_immediate_abort: bool = ("Enable setting `panic = \"immediate-abort\"` in profiles"),
893894
unstable_options: bool = ("Allow the usage of unstable options"),
894895
warnings: bool = ("Allow use of the build.warnings config key"),
895896
);
@@ -1420,6 +1421,7 @@ impl CliUnstable {
14201421
"skip-rustdoc-fingerprint" => self.skip_rustdoc_fingerprint = parse_empty(k, v)?,
14211422
"script" => self.script = parse_empty(k, v)?,
14221423
"target-applies-to-host" => self.target_applies_to_host = parse_empty(k, v)?,
1424+
"panic-immediate-abort" => self.panic_immediate_abort = parse_empty(k, v)?,
14231425
"unstable-options" => self.unstable_options = parse_empty(k, v)?,
14241426
"warnings" => self.warnings = parse_empty(k, v)?,
14251427
_ => bail!(

src/cargo/util/toml/mod.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2550,10 +2550,10 @@ pub fn validate_profile(
25502550
}
25512551

25522552
if let Some(panic) = &root.panic {
2553-
if panic != "unwind" && panic != "abort" {
2553+
if panic != "unwind" && panic != "abort" && panic != "immediate-abort" {
25542554
bail!(
25552555
"`panic` setting of `{}` is not a valid setting, \
2556-
must be `unwind` or `abort`",
2556+
must be `unwind`, `abort`, or `immediate-abort`.",
25572557
panic
25582558
);
25592559
}
@@ -2607,6 +2607,15 @@ fn validate_profile_layer(
26072607
_ => {}
26082608
}
26092609
}
2610+
if profile.panic.as_deref() == Some("immediate-abort") {
2611+
match (
2612+
features.require(Feature::panic_immediate_abort()),
2613+
cli_unstable.panic_immediate_abort,
2614+
) {
2615+
(Err(e), false) => return Err(e),
2616+
_ => {}
2617+
}
2618+
}
26102619
Ok(())
26112620
}
26122621

tests/testsuite/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ mod proc_macro;
150150
mod profile_config;
151151
mod profile_custom;
152152
mod profile_overrides;
153+
mod profile_panic_immediate_abort;
153154
mod profile_targets;
154155
mod profile_trim_paths;
155156
mod profiles;

0 commit comments

Comments
 (0)