@@ -339,15 +339,15 @@ fn exit(exit_code: i32) -> ! {
339
339
std:: process:: exit ( exit_code) ;
340
340
}
341
341
342
- fn show_error_ ( msg : & impl std:: fmt:: Display ) -> ! {
342
+ fn fatal_error_ ( msg : & impl std:: fmt:: Display ) -> ! {
343
343
eprintln ! ( "fatal error: {msg}" ) ;
344
344
exit ( 1 )
345
345
}
346
346
347
- macro_rules! show_error {
348
- ( $( $tt: tt) * ) => { $crate:: show_error_ ( & format_args!( $( $tt) * ) ) } ;
347
+ macro_rules! fatal_error {
348
+ ( $( $tt: tt) * ) => { $crate:: fatal_error_ ( & format_args!( $( $tt) * ) ) } ;
349
349
}
350
- use show_error ;
350
+ use fatal_error ;
351
351
352
352
/// Execute a compiler with the given CLI arguments and callbacks.
353
353
fn run_compiler_and_exit (
@@ -520,7 +520,7 @@ fn main() {
520
520
params. precise_interior_mut = false ;
521
521
}
522
522
_ =>
523
- show_error ! (
523
+ fatal_error ! (
524
524
"`-Zmiri-tree-borrows` is required before `-Zmiri-tree-borrows-no-precise-interior-mut`"
525
525
) ,
526
526
} ;
@@ -547,7 +547,7 @@ fn main() {
547
547
"warn-nobacktrace" =>
548
548
miri:: IsolatedOp :: Reject ( miri:: RejectOpWith :: WarningWithoutBacktrace ) ,
549
549
_ =>
550
- show_error ! (
550
+ fatal_error ! (
551
551
"-Zmiri-isolation-error must be `abort`, `hide`, `warn`, or `warn-nobacktrace`"
552
552
) ,
553
553
} ;
@@ -578,16 +578,16 @@ fn main() {
578
578
"all" => RetagFields :: Yes ,
579
579
"none" => RetagFields :: No ,
580
580
"scalar" => RetagFields :: OnlyScalar ,
581
- _ => show_error ! ( "`-Zmiri-retag-fields` can only be `all`, `none`, or `scalar`" ) ,
581
+ _ => fatal_error ! ( "`-Zmiri-retag-fields` can only be `all`, `none`, or `scalar`" ) ,
582
582
} ;
583
583
} else if let Some ( param) = arg. strip_prefix ( "-Zmiri-seed=" ) {
584
584
let seed = param. parse :: < u64 > ( ) . unwrap_or_else ( |_| {
585
- show_error ! ( "-Zmiri-seed must be an integer that fits into u64" )
585
+ fatal_error ! ( "-Zmiri-seed must be an integer that fits into u64" )
586
586
} ) ;
587
587
miri_config. seed = Some ( seed) ;
588
588
} else if let Some ( param) = arg. strip_prefix ( "-Zmiri-many-seeds=" ) {
589
589
let range = parse_range ( param) . unwrap_or_else ( |err| {
590
- show_error ! (
590
+ fatal_error ! (
591
591
"-Zmiri-many-seeds requires a range in the form `from..to` or `..to`: {err}"
592
592
)
593
593
} ) ;
@@ -604,51 +604,51 @@ fn main() {
604
604
miri_config. forwarded_env_vars . push ( param. to_owned ( ) ) ;
605
605
} else if let Some ( param) = arg. strip_prefix ( "-Zmiri-env-set=" ) {
606
606
let Some ( ( name, value) ) = param. split_once ( '=' ) else {
607
- show_error ! ( "-Zmiri-env-set requires an argument of the form <name>=<value>" ) ;
607
+ fatal_error ! ( "-Zmiri-env-set requires an argument of the form <name>=<value>" ) ;
608
608
} ;
609
609
miri_config. set_env_vars . insert ( name. to_owned ( ) , value. to_owned ( ) ) ;
610
610
} else if let Some ( param) = arg. strip_prefix ( "-Zmiri-track-pointer-tag=" ) {
611
611
let ids: Vec < u64 > = parse_comma_list ( param) . unwrap_or_else ( |err| {
612
- show_error ! ( "-Zmiri-track-pointer-tag requires a comma separated list of valid `u64` arguments: {err}" )
612
+ fatal_error ! ( "-Zmiri-track-pointer-tag requires a comma separated list of valid `u64` arguments: {err}" )
613
613
} ) ;
614
614
for id in ids. into_iter ( ) . map ( miri:: BorTag :: new) {
615
615
if let Some ( id) = id {
616
616
miri_config. tracked_pointer_tags . insert ( id) ;
617
617
} else {
618
- show_error ! ( "-Zmiri-track-pointer-tag requires nonzero arguments" ) ;
618
+ fatal_error ! ( "-Zmiri-track-pointer-tag requires nonzero arguments" ) ;
619
619
}
620
620
}
621
621
} else if let Some ( param) = arg. strip_prefix ( "-Zmiri-track-alloc-id=" ) {
622
622
let ids = parse_comma_list :: < NonZero < u64 > > ( param) . unwrap_or_else ( |err| {
623
- show_error ! ( "-Zmiri-track-alloc-id requires a comma separated list of valid non-zero `u64` arguments: {err}" )
623
+ fatal_error ! ( "-Zmiri-track-alloc-id requires a comma separated list of valid non-zero `u64` arguments: {err}" )
624
624
} ) ;
625
625
miri_config. tracked_alloc_ids . extend ( ids. into_iter ( ) . map ( miri:: AllocId ) ) ;
626
626
} else if arg == "-Zmiri-track-alloc-accesses" {
627
627
miri_config. track_alloc_accesses = true ;
628
628
} else if let Some ( param) = arg. strip_prefix ( "-Zmiri-address-reuse-rate=" ) {
629
629
miri_config. address_reuse_rate = parse_rate ( param)
630
- . unwrap_or_else ( |err| show_error ! ( "-Zmiri-address-reuse-rate {err}" ) ) ;
630
+ . unwrap_or_else ( |err| fatal_error ! ( "-Zmiri-address-reuse-rate {err}" ) ) ;
631
631
} else if let Some ( param) = arg. strip_prefix ( "-Zmiri-address-reuse-cross-thread-rate=" ) {
632
632
miri_config. address_reuse_cross_thread_rate = parse_rate ( param)
633
- . unwrap_or_else ( |err| show_error ! ( "-Zmiri-address-reuse-cross-thread-rate {err}" ) ) ;
633
+ . unwrap_or_else ( |err| fatal_error ! ( "-Zmiri-address-reuse-cross-thread-rate {err}" ) ) ;
634
634
} else if let Some ( param) = arg. strip_prefix ( "-Zmiri-compare-exchange-weak-failure-rate=" ) {
635
635
miri_config. cmpxchg_weak_failure_rate = parse_rate ( param) . unwrap_or_else ( |err| {
636
- show_error ! ( "-Zmiri-compare-exchange-weak-failure-rate {err}" )
636
+ fatal_error ! ( "-Zmiri-compare-exchange-weak-failure-rate {err}" )
637
637
} ) ;
638
638
} else if let Some ( param) = arg. strip_prefix ( "-Zmiri-preemption-rate=" ) {
639
- miri_config. preemption_rate =
640
- parse_rate ( param ) . unwrap_or_else ( |err| show_error ! ( "-Zmiri-preemption-rate {err}" ) ) ;
639
+ miri_config. preemption_rate = parse_rate ( param )
640
+ . unwrap_or_else ( |err| fatal_error ! ( "-Zmiri-preemption-rate {err}" ) ) ;
641
641
} else if arg == "-Zmiri-report-progress" {
642
642
// This makes it take a few seconds between progress reports on my laptop.
643
643
miri_config. report_progress = Some ( 1_000_000 ) ;
644
644
} else if let Some ( param) = arg. strip_prefix ( "-Zmiri-report-progress=" ) {
645
645
let interval = param. parse :: < u32 > ( ) . unwrap_or_else ( |err| {
646
- show_error ! ( "-Zmiri-report-progress requires a `u32`: {}" , err)
646
+ fatal_error ! ( "-Zmiri-report-progress requires a `u32`: {}" , err)
647
647
} ) ;
648
648
miri_config. report_progress = Some ( interval) ;
649
649
} else if let Some ( param) = arg. strip_prefix ( "-Zmiri-provenance-gc=" ) {
650
650
let interval = param. parse :: < u32 > ( ) . unwrap_or_else ( |err| {
651
- show_error ! ( "-Zmiri-provenance-gc requires a `u32`: {}" , err)
651
+ fatal_error ! ( "-Zmiri-provenance-gc requires a `u32`: {}" , err)
652
652
} ) ;
653
653
miri_config. gc_interval = interval;
654
654
} else if let Some ( param) = arg. strip_prefix ( "-Zmiri-measureme=" ) {
@@ -658,7 +658,7 @@ fn main() {
658
658
"0" => BacktraceStyle :: Off ,
659
659
"1" => BacktraceStyle :: Short ,
660
660
"full" => BacktraceStyle :: Full ,
661
- _ => show_error ! ( "-Zmiri-backtrace may only be 0, 1, or full" ) ,
661
+ _ => fatal_error ! ( "-Zmiri-backtrace may only be 0, 1, or full" ) ,
662
662
} ;
663
663
} else if let Some ( param) = arg. strip_prefix ( "-Zmiri-native-lib=" ) {
664
664
let filename = param. to_string ( ) ;
@@ -675,27 +675,27 @@ fn main() {
675
675
miri_config. native_lib . push ( filename. into ( ) ) ;
676
676
}
677
677
} else {
678
- show_error ! ( "-Zmiri-native-lib `{}` does not exist" , filename) ;
678
+ fatal_error ! ( "-Zmiri-native-lib `{}` does not exist" , filename) ;
679
679
}
680
680
} else if arg == "-Zmiri-force-old-native-lib-mode" {
681
681
miri_config. force_old_native_lib = true ;
682
682
} else if let Some ( param) = arg. strip_prefix ( "-Zmiri-num-cpus=" ) {
683
683
let num_cpus = param
684
684
. parse :: < u32 > ( )
685
- . unwrap_or_else ( |err| show_error ! ( "-Zmiri-num-cpus requires a `u32`: {}" , err) ) ;
685
+ . unwrap_or_else ( |err| fatal_error ! ( "-Zmiri-num-cpus requires a `u32`: {}" , err) ) ;
686
686
if !( 1 ..=miri:: MAX_CPUS ) . contains ( & usize:: try_from ( num_cpus) . unwrap ( ) ) {
687
- show_error ! ( "-Zmiri-num-cpus must be in the range 1..={}" , miri:: MAX_CPUS ) ;
687
+ fatal_error ! ( "-Zmiri-num-cpus must be in the range 1..={}" , miri:: MAX_CPUS ) ;
688
688
}
689
689
miri_config. num_cpus = num_cpus;
690
690
} else if let Some ( param) = arg. strip_prefix ( "-Zmiri-force-page-size=" ) {
691
691
let page_size = param. parse :: < u64 > ( ) . unwrap_or_else ( |err| {
692
- show_error ! ( "-Zmiri-force-page-size requires a `u64`: {}" , err)
692
+ fatal_error ! ( "-Zmiri-force-page-size requires a `u64`: {}" , err)
693
693
} ) ;
694
694
// Convert from kilobytes to bytes.
695
695
let page_size = if page_size. is_power_of_two ( ) {
696
696
page_size * 1024
697
697
} else {
698
- show_error ! ( "-Zmiri-force-page-size requires a power of 2: {page_size}" ) ;
698
+ fatal_error ! ( "-Zmiri-force-page-size requires a power of 2: {page_size}" ) ;
699
699
} ;
700
700
miri_config. page_size = Some ( page_size) ;
701
701
} else {
@@ -706,22 +706,22 @@ fn main() {
706
706
// Tree Borrows implies strict provenance, and is not compatible with native calls.
707
707
if matches ! ( miri_config. borrow_tracker, Some ( BorrowTrackerMethod :: TreeBorrows { .. } ) ) {
708
708
if miri_config. provenance_mode != ProvenanceMode :: Strict {
709
- show_error ! (
709
+ fatal_error ! (
710
710
"Tree Borrows does not support integer-to-pointer casts, and hence requires strict provenance"
711
711
) ;
712
712
}
713
713
if !miri_config. native_lib . is_empty ( ) {
714
- show_error ! ( "Tree Borrows is not compatible with calling native functions" ) ;
714
+ fatal_error ! ( "Tree Borrows is not compatible with calling native functions" ) ;
715
715
}
716
716
}
717
717
718
718
// Native calls and strict provenance are not compatible.
719
719
if !miri_config. native_lib . is_empty ( ) && miri_config. provenance_mode == ProvenanceMode :: Strict {
720
- show_error ! ( "strict provenance is not compatible with calling native functions" ) ;
720
+ fatal_error ! ( "strict provenance is not compatible with calling native functions" ) ;
721
721
}
722
722
// You can set either one seed or many.
723
723
if many_seeds. is_some ( ) && miri_config. seed . is_some ( ) {
724
- show_error ! ( "Only one of `-Zmiri-seed` and `-Zmiri-many-seeds can be set" ) ;
724
+ fatal_error ! ( "Only one of `-Zmiri-seed` and `-Zmiri-many-seeds can be set" ) ;
725
725
}
726
726
727
727
// Ensure we have parallelism for many-seeds mode.
@@ -737,12 +737,12 @@ fn main() {
737
737
assert_eq ! ( genmc_config. is_some( ) , miri_config. genmc_mode) ;
738
738
if genmc_config. is_some ( ) {
739
739
if !miri_config. data_race_detector {
740
- show_error ! ( "Cannot disable data race detection in GenMC mode (currently)" ) ;
740
+ fatal_error ! ( "Cannot disable data race detection in GenMC mode (currently)" ) ;
741
741
} else if !miri_config. weak_memory_emulation {
742
- show_error ! ( "Cannot disable weak memory emulation in GenMC mode" ) ;
742
+ fatal_error ! ( "Cannot disable weak memory emulation in GenMC mode" ) ;
743
743
}
744
744
} else if miri_config. weak_memory_emulation && !miri_config. data_race_detector {
745
- show_error ! (
745
+ fatal_error ! (
746
746
"Weak memory emulation cannot be enabled when the data race detector is disabled"
747
747
) ;
748
748
} ;
0 commit comments