Skip to content

Commit c1bcf5c

Browse files
committed
Add -Z panic-in-drop={unwind,abort} command-line option
1 parent 497ee32 commit c1bcf5c

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

compiler/rustc_interface/src/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,7 @@ fn test_debugging_options_tracking_hash() {
743743
tracked!(no_profiler_runtime, true);
744744
tracked!(osx_rpath_install_name, true);
745745
tracked!(panic_abort_tests, true);
746+
tracked!(panic_in_drop, PanicStrategy::Abort);
746747
tracked!(partially_uninit_const_threshold, Some(123));
747748
tracked!(plt, Some(true));
748749
tracked!(polonius, true);

compiler/rustc_session/src/options.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ mod desc {
349349
pub const parse_threads: &str = parse_number;
350350
pub const parse_passes: &str = "a space-separated list of passes, or `all`";
351351
pub const parse_panic_strategy: &str = "either `unwind` or `abort`";
352+
pub const parse_opt_panic_strategy: &str = parse_panic_strategy;
352353
pub const parse_relro_level: &str = "one of: `full`, `partial`, or `off`";
353354
pub const parse_sanitizers: &str =
354355
"comma separated list of sanitizers: `address`, `hwaddress`, `leak`, `memory` or `thread`";
@@ -549,7 +550,7 @@ mod parse {
549550
}
550551
}
551552

552-
crate fn parse_panic_strategy(slot: &mut Option<PanicStrategy>, v: Option<&str>) -> bool {
553+
crate fn parse_opt_panic_strategy(slot: &mut Option<PanicStrategy>, v: Option<&str>) -> bool {
553554
match v {
554555
Some("unwind") => *slot = Some(PanicStrategy::Unwind),
555556
Some("abort") => *slot = Some(PanicStrategy::Abort),
@@ -558,6 +559,15 @@ mod parse {
558559
true
559560
}
560561

562+
crate fn parse_panic_strategy(slot: &mut PanicStrategy, v: Option<&str>) -> bool {
563+
match v {
564+
Some("unwind") => *slot = PanicStrategy::Unwind,
565+
Some("abort") => *slot = PanicStrategy::Abort,
566+
_ => return false,
567+
}
568+
true
569+
}
570+
561571
crate fn parse_relro_level(slot: &mut Option<RelroLevel>, v: Option<&str>) -> bool {
562572
match v {
563573
Some(s) => match s.parse::<RelroLevel>() {
@@ -958,7 +968,7 @@ options! {
958968
"optimization level (0-3, s, or z; default: 0)"),
959969
overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
960970
"use overflow checks for integer arithmetic"),
961-
panic: Option<PanicStrategy> = (None, parse_panic_strategy, [TRACKED],
971+
panic: Option<PanicStrategy> = (None, parse_opt_panic_strategy, [TRACKED],
962972
"panic strategy to compile crate with"),
963973
passes: Vec<String> = (Vec::new(), parse_list, [TRACKED],
964974
"a list of extra LLVM passes to run (space separated)"),
@@ -1184,6 +1194,8 @@ options! {
11841194
"pass `-install_name @rpath/...` to the macOS linker (default: no)"),
11851195
panic_abort_tests: bool = (false, parse_bool, [TRACKED],
11861196
"support compiling tests with panic=abort (default: no)"),
1197+
panic_in_drop: PanicStrategy = (PanicStrategy::Unwind, parse_panic_strategy, [TRACKED],
1198+
"panic strategy for panics in drops"),
11871199
parse_only: bool = (false, parse_bool, [UNTRACKED],
11881200
"parse only; do not compile, assemble, or link (default: no)"),
11891201
partially_uninit_const_threshold: Option<usize> = (None, parse_opt_number, [TRACKED],

0 commit comments

Comments
 (0)