diff options
| author | Eric Arellano <ericarellano@me.com> | 2020-12-07 11:59:24 -0700 |
|---|---|---|
| committer | Eric Arellano <ericarellano@me.com> | 2020-12-07 12:48:44 -0700 |
| commit | 12db2225b6e82b861597d1a98c018d56100a741c (patch) | |
| tree | 12b5f1b8c85651b85cd98475295f01ad09ae1de1 /compiler/rustc_mir/src | |
| parent | 0f6f2d681b39c5f95459cd09cb936b6ceb27cd82 (diff) | |
| download | rust-12db2225b6e82b861597d1a98c018d56100a741c.tar.gz rust-12db2225b6e82b861597d1a98c018d56100a741c.zip | |
Dogfood 'str_split_once() with `compiler/`
Diffstat (limited to 'compiler/rustc_mir/src')
| -rw-r--r-- | compiler/rustc_mir/src/lib.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_mir/src/transform/coverage/debug.rs | 48 |
2 files changed, 26 insertions, 23 deletions
diff --git a/compiler/rustc_mir/src/lib.rs b/compiler/rustc_mir/src/lib.rs index 2ed115b1297..e6d822086f5 100644 --- a/compiler/rustc_mir/src/lib.rs +++ b/compiler/rustc_mir/src/lib.rs @@ -28,6 +28,7 @@ Rust MIR: a lowered representation of Rust. #![feature(or_patterns)] #![feature(once_cell)] #![feature(control_flow_enum)] +#![feature(str_split_once)] #![recursion_limit = "256"] #[macro_use] diff --git a/compiler/rustc_mir/src/transform/coverage/debug.rs b/compiler/rustc_mir/src/transform/coverage/debug.rs index e9528557b33..1347656c23e 100644 --- a/compiler/rustc_mir/src/transform/coverage/debug.rs +++ b/compiler/rustc_mir/src/transform/coverage/debug.rs @@ -148,23 +148,19 @@ impl DebugOptions { if let Ok(env_debug_options) = std::env::var(RUSTC_COVERAGE_DEBUG_OPTIONS) { for setting_str in env_debug_options.replace(" ", "").replace("-", "_").split(',') { - let mut setting = setting_str.splitn(2, '='); - match setting.next() { - Some(option) if option == "allow_unused_expressions" => { - allow_unused_expressions = bool_option_val(option, setting.next()); - debug!( - "{} env option `allow_unused_expressions` is set to {}", - RUSTC_COVERAGE_DEBUG_OPTIONS, allow_unused_expressions - ); - } - Some(option) if option == "counter_format" => { - if let Some(strval) = setting.next() { - counter_format = counter_format_option_val(strval); - debug!( - "{} env option `counter_format` is set to {:?}", - RUSTC_COVERAGE_DEBUG_OPTIONS, counter_format - ); - } else { + let (option, value) = match setting_str.split_once('=') { + None => (setting_str, None), + Some((k, v)) => (k, Some(v)), + }; + if option == "allow_unused_expressions" { + allow_unused_expressions = bool_option_val(option, value); + debug!( + "{} env option `allow_unused_expressions` is set to {}", + RUSTC_COVERAGE_DEBUG_OPTIONS, allow_unused_expressions + ); + } else if option == "counter_format" { + match value { + None => { bug!( "`{}` option in environment variable {} requires one or more \ plus-separated choices (a non-empty subset of \ @@ -173,14 +169,20 @@ impl DebugOptions { RUSTC_COVERAGE_DEBUG_OPTIONS ); } - } - Some("") => {} - Some(invalid) => bug!( + Some(val) => { + counter_format = counter_format_option_val(val); + debug!( + "{} env option `counter_format` is set to {:?}", + RUSTC_COVERAGE_DEBUG_OPTIONS, counter_format + ); + } + }; + } else { + bug!( "Unsupported setting `{}` in environment variable {}", - invalid, + option, RUSTC_COVERAGE_DEBUG_OPTIONS - ), - None => {} + ) } } } |
