@@ -310,208 +310,154 @@ fn main() {
310
310
} else if after_dashdash {
311
311
// Everything that comes after `--` is forwarded to the interpreted crate.
312
312
miri_config. args . push ( arg) ;
313
- } else {
314
- match arg. as_str ( ) {
315
- "-Zmiri-disable-validation" => {
316
- miri_config. validate = false ;
317
- }
318
- "-Zmiri-disable-stacked-borrows" => {
319
- miri_config. stacked_borrows = false ;
320
- }
321
- "-Zmiri-disable-data-race-detector" => {
322
- miri_config. data_race_detector = false ;
323
- }
324
- "-Zmiri-disable-alignment-check" => {
325
- miri_config. check_alignment = miri:: AlignmentCheck :: None ;
326
- }
327
- "-Zmiri-symbolic-alignment-check" => {
328
- miri_config. check_alignment = miri:: AlignmentCheck :: Symbolic ;
329
- }
330
- "-Zmiri-check-number-validity" => {
331
- eprintln ! (
332
- "WARNING: the flag `-Zmiri-check-number-validity` no longer has any effect \
313
+ } else if arg == "--" {
314
+ after_dashdash = true ;
315
+ } else if arg == "-Zmiri-disable-validation" {
316
+ miri_config. validate = false ;
317
+ } else if arg == "-Zmiri-disable-stacked-borrows" {
318
+ miri_config. stacked_borrows = false ;
319
+ } else if arg == "-Zmiri-disable-data-race-detector" {
320
+ miri_config. data_race_detector = false ;
321
+ } else if arg == "-Zmiri-disable-alignment-check" {
322
+ miri_config. check_alignment = miri:: AlignmentCheck :: None ;
323
+ } else if arg == "-Zmiri-symbolic-alignment-check" {
324
+ miri_config. check_alignment = miri:: AlignmentCheck :: Symbolic ;
325
+ } else if arg == "-Zmiri-check-number-validity" {
326
+ eprintln ! (
327
+ "WARNING: the flag `-Zmiri-check-number-validity` no longer has any effect \
333
328
since it is now enabled by default"
334
- ) ;
335
- }
336
- "-Zmiri-allow-uninit-numbers" => {
337
- miri_config. allow_uninit_numbers = true ;
338
- }
339
- "-Zmiri-allow-ptr-int-transmute" => {
340
- miri_config. allow_ptr_int_transmute = true ;
341
- }
342
- "-Zmiri-disable-abi-check" => {
343
- miri_config. check_abi = false ;
344
- }
345
- "-Zmiri-disable-isolation" => {
346
- if matches ! ( isolation_enabled, Some ( true ) ) {
347
- panic ! (
348
- "-Zmiri-disable-isolation cannot be used along with -Zmiri-isolation-error"
349
- ) ;
350
- } else {
351
- isolation_enabled = Some ( false ) ;
352
- }
353
- miri_config. isolated_op = miri:: IsolatedOp :: Allow ;
354
- }
355
- arg if arg. starts_with ( "-Zmiri-isolation-error=" ) => {
356
- if matches ! ( isolation_enabled, Some ( false ) ) {
357
- panic ! (
358
- "-Zmiri-isolation-error cannot be used along with -Zmiri-disable-isolation"
359
- ) ;
360
- } else {
361
- isolation_enabled = Some ( true ) ;
362
- }
363
-
364
- miri_config. isolated_op = match arg
365
- . strip_prefix ( "-Zmiri-isolation-error=" )
366
- . unwrap ( )
367
- {
368
- "abort" => miri:: IsolatedOp :: Reject ( miri:: RejectOpWith :: Abort ) ,
369
- "hide" => miri:: IsolatedOp :: Reject ( miri:: RejectOpWith :: NoWarning ) ,
370
- "warn" => miri:: IsolatedOp :: Reject ( miri:: RejectOpWith :: Warning ) ,
371
- "warn-nobacktrace" =>
372
- miri:: IsolatedOp :: Reject ( miri:: RejectOpWith :: WarningWithoutBacktrace ) ,
373
- _ =>
374
- panic ! (
375
- "-Zmiri-isolation-error must be `abort`, `hide`, `warn`, or `warn-nobacktrace`"
376
- ) ,
377
- } ;
378
- }
379
- "-Zmiri-ignore-leaks" => {
380
- miri_config. ignore_leaks = true ;
381
- }
382
- "-Zmiri-panic-on-unsupported" => {
383
- miri_config. panic_on_unsupported = true ;
384
- }
385
- "-Zmiri-tag-raw-pointers" => {
386
- miri_config. tag_raw = true ;
387
- }
388
- "-Zmiri-strict-provenance" => {
389
- miri_config. provenance_mode = ProvenanceMode :: Strict ;
390
- miri_config. tag_raw = true ;
391
- }
392
- "-Zmiri-permissive-provenance" => {
393
- miri_config. provenance_mode = ProvenanceMode :: Permissive ;
394
- miri_config. tag_raw = true ;
395
- }
396
- "-Zmiri-mute-stdout-stderr" => {
397
- miri_config. mute_stdout_stderr = true ;
398
- }
399
- "-Zmiri-track-raw-pointers" => {
400
- eprintln ! (
401
- "WARNING: -Zmiri-track-raw-pointers has been renamed to -Zmiri-tag-raw-pointers, the old name is deprecated."
402
- ) ;
403
- miri_config. tag_raw = true ;
404
- }
405
- "--" => {
406
- after_dashdash = true ;
407
- }
408
- arg if arg. starts_with ( "-Zmiri-seed=" ) => {
409
- if miri_config. seed . is_some ( ) {
410
- panic ! ( "Cannot specify -Zmiri-seed multiple times!" ) ;
411
- }
412
- let seed = u64:: from_str_radix ( arg. strip_prefix ( "-Zmiri-seed=" ) . unwrap ( ) , 16 )
329
+ ) ;
330
+ } else if arg == "-Zmiri-allow-uninit-numbers" {
331
+ miri_config. allow_uninit_numbers = true ;
332
+ } else if arg == "-Zmiri-allow-ptr-int-transmute" {
333
+ miri_config. allow_ptr_int_transmute = true ;
334
+ } else if arg == "-Zmiri-disable-abi-check" {
335
+ miri_config. check_abi = false ;
336
+ } else if arg == "-Zmiri-disable-isolation" {
337
+ if matches ! ( isolation_enabled, Some ( true ) ) {
338
+ panic ! ( "-Zmiri-disable-isolation cannot be used along with -Zmiri-isolation-error" ) ;
339
+ } else {
340
+ isolation_enabled = Some ( false ) ;
341
+ }
342
+ miri_config. isolated_op = miri:: IsolatedOp :: Allow ;
343
+ } else if let Some ( param) = arg. strip_prefix ( "-Zmiri-isolation-error=" ) {
344
+ if matches ! ( isolation_enabled, Some ( false ) ) {
345
+ panic ! ( "-Zmiri-isolation-error cannot be used along with -Zmiri-disable-isolation" ) ;
346
+ } else {
347
+ isolation_enabled = Some ( true ) ;
348
+ }
349
+
350
+ miri_config. isolated_op = match param {
351
+ "abort" => miri:: IsolatedOp :: Reject ( miri:: RejectOpWith :: Abort ) ,
352
+ "hide" => miri:: IsolatedOp :: Reject ( miri:: RejectOpWith :: NoWarning ) ,
353
+ "warn" => miri:: IsolatedOp :: Reject ( miri:: RejectOpWith :: Warning ) ,
354
+ "warn-nobacktrace" =>
355
+ miri:: IsolatedOp :: Reject ( miri:: RejectOpWith :: WarningWithoutBacktrace ) ,
356
+ _ =>
357
+ panic ! (
358
+ "-Zmiri-isolation-error must be `abort`, `hide`, `warn`, or `warn-nobacktrace`"
359
+ ) ,
360
+ } ;
361
+ } else if arg == "-Zmiri-ignore-leaks" {
362
+ miri_config. ignore_leaks = true ;
363
+ } else if arg == "-Zmiri-panic-on-unsupported" {
364
+ miri_config. panic_on_unsupported = true ;
365
+ } else if arg == "-Zmiri-tag-raw-pointers" {
366
+ miri_config. tag_raw = true ;
367
+ } else if arg == "-Zmiri-strict-provenance" {
368
+ miri_config. provenance_mode = ProvenanceMode :: Strict ;
369
+ miri_config. tag_raw = true ;
370
+ } else if arg == "-Zmiri-permissive-provenance" {
371
+ miri_config. provenance_mode = ProvenanceMode :: Permissive ;
372
+ miri_config. tag_raw = true ;
373
+ } else if arg == "-Zmiri-mute-stdout-stderr" {
374
+ miri_config. mute_stdout_stderr = true ;
375
+ } else if arg == "-Zmiri-track-raw-pointers" {
376
+ eprintln ! (
377
+ "WARNING: -Zmiri-track-raw-pointers has been renamed to -Zmiri-tag-raw-pointers, the old name is deprecated."
378
+ ) ;
379
+ miri_config. tag_raw = true ;
380
+ } else if let Some ( param) = arg. strip_prefix ( "-Zmiri-seed=" ) {
381
+ if miri_config. seed . is_some ( ) {
382
+ panic ! ( "Cannot specify -Zmiri-seed multiple times!" ) ;
383
+ }
384
+ let seed = u64:: from_str_radix ( param, 16 )
413
385
. unwrap_or_else ( |_| panic ! (
414
386
"-Zmiri-seed should only contain valid hex digits [0-9a-fA-F] and fit into a u64 (max 16 characters)"
415
387
) ) ;
416
- miri_config. seed = Some ( seed) ;
417
- }
418
- arg if arg. starts_with ( "-Zmiri-env-exclude=" ) => {
419
- miri_config
420
- . excluded_env_vars
421
- . push ( arg. strip_prefix ( "-Zmiri-env-exclude=" ) . unwrap ( ) . to_owned ( ) ) ;
422
- }
423
- arg if arg. starts_with ( "-Zmiri-env-forward=" ) => {
424
- miri_config
425
- . forwarded_env_vars
426
- . push ( arg. strip_prefix ( "-Zmiri-env-forward=" ) . unwrap ( ) . to_owned ( ) ) ;
427
- }
428
- arg if arg. starts_with ( "-Zmiri-track-pointer-tag=" ) => {
429
- let ids: Vec < u64 > = match parse_comma_list (
430
- arg. strip_prefix ( "-Zmiri-track-pointer-tag=" ) . unwrap ( ) ,
431
- ) {
432
- Ok ( ids) => ids,
433
- Err ( err) =>
434
- panic ! (
435
- "-Zmiri-track-pointer-tag requires a comma separated list of valid `u64` arguments: {}" ,
436
- err
437
- ) ,
438
- } ;
439
- for id in ids. into_iter ( ) . map ( miri:: PtrId :: new) {
440
- if let Some ( id) = id {
441
- miri_config. tracked_pointer_tags . insert ( id) ;
442
- } else {
443
- panic ! ( "-Zmiri-track-pointer-tag requires nonzero arguments" ) ;
444
- }
445
- }
446
- }
447
- arg if arg. starts_with ( "-Zmiri-track-call-id=" ) => {
448
- let ids: Vec < u64 > = match parse_comma_list (
449
- arg. strip_prefix ( "-Zmiri-track-call-id=" ) . unwrap ( ) ,
450
- ) {
451
- Ok ( ids) => ids,
452
- Err ( err) =>
453
- panic ! (
454
- "-Zmiri-track-call-id requires a comma separated list of valid `u64` arguments: {}" ,
455
- err
456
- ) ,
457
- } ;
458
- for id in ids. into_iter ( ) . map ( miri:: CallId :: new) {
459
- if let Some ( id) = id {
460
- miri_config. tracked_call_ids . insert ( id) ;
461
- } else {
462
- panic ! ( "-Zmiri-track-call-id requires a nonzero argument" ) ;
463
- }
464
- }
465
- }
466
- arg if arg. starts_with ( "-Zmiri-track-alloc-id=" ) => {
467
- let ids: Vec < miri:: AllocId > = match parse_comma_list :: < NonZeroU64 > (
468
- arg. strip_prefix ( "-Zmiri-track-alloc-id=" ) . unwrap ( ) ,
469
- ) {
470
- Ok ( ids) => ids. into_iter ( ) . map ( miri:: AllocId ) . collect ( ) ,
471
- Err ( err) =>
472
- panic ! (
473
- "-Zmiri-track-alloc-id requires a comma separated list of valid non-zero `u64` arguments: {}" ,
474
- err
475
- ) ,
476
- } ;
477
- miri_config. tracked_alloc_ids . extend ( ids) ;
478
- }
479
- arg if arg. starts_with ( "-Zmiri-compare-exchange-weak-failure-rate=" ) => {
480
- let rate = match arg
481
- . strip_prefix ( "-Zmiri-compare-exchange-weak-failure-rate=" )
482
- . unwrap ( )
483
- . parse :: < f64 > ( )
484
- {
485
- Ok ( rate) if rate >= 0.0 && rate <= 1.0 => rate,
486
- Ok ( _) =>
487
- panic ! (
488
- "-Zmiri-compare-exchange-weak-failure-rate must be between `0.0` and `1.0`"
489
- ) ,
490
- Err ( err) =>
491
- panic ! (
492
- "-Zmiri-compare-exchange-weak-failure-rate requires a `f64` between `0.0` and `1.0`: {}" ,
493
- err
494
- ) ,
495
- } ;
496
- miri_config. cmpxchg_weak_failure_rate = rate;
497
- }
498
- arg if arg. starts_with ( "-Zmiri-measureme=" ) => {
499
- let measureme_out = arg. strip_prefix ( "-Zmiri-measureme=" ) . unwrap ( ) ;
500
- miri_config. measureme_out = Some ( measureme_out. to_string ( ) ) ;
501
- }
502
- arg if arg. starts_with ( "-Zmiri-backtrace=" ) => {
503
- miri_config. backtrace_style = match arg. strip_prefix ( "-Zmiri-backtrace=" ) {
504
- Some ( "0" ) => BacktraceStyle :: Off ,
505
- Some ( "1" ) => BacktraceStyle :: Short ,
506
- Some ( "full" ) => BacktraceStyle :: Full ,
507
- _ => panic ! ( "-Zmiri-backtrace may only be 0, 1, or full" ) ,
508
- } ;
388
+ miri_config. seed = Some ( seed) ;
389
+ } else if let Some ( param) = arg. strip_prefix ( "-Zmiri-env-exclude=" ) {
390
+ miri_config. excluded_env_vars . push ( param. to_owned ( ) ) ;
391
+ } else if let Some ( param) = arg. strip_prefix ( "-Zmiri-env-forward=" ) {
392
+ miri_config. forwarded_env_vars . push ( param. to_owned ( ) ) ;
393
+ } else if let Some ( param) = arg. strip_prefix ( "-Zmiri-track-pointer-tag=" ) {
394
+ let ids: Vec < u64 > = match parse_comma_list ( param) {
395
+ Ok ( ids) => ids,
396
+ Err ( err) =>
397
+ panic ! (
398
+ "-Zmiri-track-pointer-tag requires a comma separated list of valid `u64` arguments: {}" ,
399
+ err
400
+ ) ,
401
+ } ;
402
+ for id in ids. into_iter ( ) . map ( miri:: PtrId :: new) {
403
+ if let Some ( id) = id {
404
+ miri_config. tracked_pointer_tags . insert ( id) ;
405
+ } else {
406
+ panic ! ( "-Zmiri-track-pointer-tag requires nonzero arguments" ) ;
509
407
}
510
- _ => {
511
- // Forward to rustc.
512
- rustc_args. push ( arg) ;
408
+ }
409
+ } else if let Some ( param) = arg. strip_prefix ( "-Zmiri-track-call-id=" ) {
410
+ let ids: Vec < u64 > = match parse_comma_list ( param) {
411
+ Ok ( ids) => ids,
412
+ Err ( err) =>
413
+ panic ! (
414
+ "-Zmiri-track-call-id requires a comma separated list of valid `u64` arguments: {}" ,
415
+ err
416
+ ) ,
417
+ } ;
418
+ for id in ids. into_iter ( ) . map ( miri:: CallId :: new) {
419
+ if let Some ( id) = id {
420
+ miri_config. tracked_call_ids . insert ( id) ;
421
+ } else {
422
+ panic ! ( "-Zmiri-track-call-id requires a nonzero argument" ) ;
513
423
}
514
424
}
425
+ } else if let Some ( param) = arg. strip_prefix ( "-Zmiri-track-alloc-id=" ) {
426
+ let ids: Vec < miri:: AllocId > = match parse_comma_list :: < NonZeroU64 > ( param) {
427
+ Ok ( ids) => ids. into_iter ( ) . map ( miri:: AllocId ) . collect ( ) ,
428
+ Err ( err) =>
429
+ panic ! (
430
+ "-Zmiri-track-alloc-id requires a comma separated list of valid non-zero `u64` arguments: {}" ,
431
+ err
432
+ ) ,
433
+ } ;
434
+ miri_config. tracked_alloc_ids . extend ( ids) ;
435
+ } else if let Some ( param) = arg. strip_prefix ( "-Zmiri-compare-exchange-weak-failure-rate=" ) {
436
+ let rate = match param. parse :: < f64 > ( ) {
437
+ Ok ( rate) if rate >= 0.0 && rate <= 1.0 => rate,
438
+ Ok ( _) =>
439
+ panic ! (
440
+ "-Zmiri-compare-exchange-weak-failure-rate must be between `0.0` and `1.0`"
441
+ ) ,
442
+ Err ( err) =>
443
+ panic ! (
444
+ "-Zmiri-compare-exchange-weak-failure-rate requires a `f64` between `0.0` and `1.0`: {}" ,
445
+ err
446
+ ) ,
447
+ } ;
448
+ miri_config. cmpxchg_weak_failure_rate = rate;
449
+ } else if let Some ( param) = arg. strip_prefix ( "-Zmiri-measureme=" ) {
450
+ miri_config. measureme_out = Some ( param. to_string ( ) ) ;
451
+ } else if let Some ( param) = arg. strip_prefix ( "-Zmiri-backtrace=" ) {
452
+ miri_config. backtrace_style = match param {
453
+ "0" => BacktraceStyle :: Off ,
454
+ "1" => BacktraceStyle :: Short ,
455
+ "full" => BacktraceStyle :: Full ,
456
+ _ => panic ! ( "-Zmiri-backtrace may only be 0, 1, or full" ) ,
457
+ } ;
458
+ } else {
459
+ // Forward to rustc.
460
+ rustc_args. push ( arg) ;
515
461
}
516
462
}
517
463
0 commit comments