diff options
| author | Nathan Nguyen <nathan.tm.nguyen@gmail.com> | 2021-02-18 05:25:45 -0600 |
|---|---|---|
| committer | Nathan Nguyen <nathan.tm.nguyen@gmail.com> | 2021-02-18 05:27:20 -0600 |
| commit | 8ddd846ce118e5f0bb423d310cb38c7f4a76890e (patch) | |
| tree | 59d7f590feaa24f1f4fe024f37924122cba3aa05 /compiler/rustc_session/src | |
| parent | 93f6a4b9d85b7eef71e17d95c113f5834238b574 (diff) | |
| download | rust-8ddd846ce118e5f0bb423d310cb38c7f4a76890e.tar.gz rust-8ddd846ce118e5f0bb423d310cb38c7f4a76890e.zip | |
nhwn: make treat_err_as_bug Option<NonZeroUsize>
Diffstat (limited to 'compiler/rustc_session/src')
| -rw-r--r-- | compiler/rustc_session/src/config.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_session/src/options.rs | 9 |
2 files changed, 7 insertions, 4 deletions
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 4533b37f10b..e4f7e140281 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -2313,6 +2313,7 @@ crate mod dep_tracking { use std::collections::hash_map::DefaultHasher; use std::collections::BTreeMap; use std::hash::Hash; + use std::num::NonZeroUsize; use std::path::PathBuf; pub trait DepTrackingHash { @@ -2353,6 +2354,7 @@ crate mod dep_tracking { impl_dep_tracking_hash_via_hash!(lint::Level); impl_dep_tracking_hash_via_hash!(Option<bool>); impl_dep_tracking_hash_via_hash!(Option<usize>); + impl_dep_tracking_hash_via_hash!(Option<NonZeroUsize>); impl_dep_tracking_hash_via_hash!(Option<String>); impl_dep_tracking_hash_via_hash!(Option<(String, u64)>); impl_dep_tracking_hash_via_hash!(Option<Vec<String>>); diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index baa0502521d..d439753d042 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -16,6 +16,7 @@ use std::collections::BTreeMap; use std::collections::hash_map::DefaultHasher; use std::hash::Hasher; +use std::num::NonZeroUsize; use std::path::PathBuf; use std::str; @@ -591,10 +592,10 @@ macro_rules! options { true } - fn parse_treat_err_as_bug(slot: &mut Option<usize>, v: Option<&str>) -> bool { + fn parse_treat_err_as_bug(slot: &mut Option<NonZeroUsize>, v: Option<&str>) -> bool { match v { - Some(s) => { *slot = s.parse().ok().filter(|&x| x != 0); slot.unwrap_or(0) != 0 } - None => { *slot = Some(1); true } + Some(s) => { *slot = s.parse().ok(); slot.is_some() } + None => { *slot = NonZeroUsize::new(1); true } } } @@ -1141,7 +1142,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "for every macro invocation, print its name and arguments (default: no)"), trap_unreachable: Option<bool> = (None, parse_opt_bool, [TRACKED], "generate trap instructions for unreachable intrinsics (default: use target setting, usually yes)"), - treat_err_as_bug: Option<usize> = (None, parse_treat_err_as_bug, [TRACKED], + treat_err_as_bug: Option<NonZeroUsize> = (None, parse_treat_err_as_bug, [TRACKED], "treat error number `val` that occurs as bug"), trim_diagnostic_paths: bool = (true, parse_bool, [UNTRACKED], "in diagnostics, use heuristics to shorten paths referring to items"), |
