1
Fork 0

Allow -Z treat-err-as-bug=0

Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
This commit is contained in:
Lieselotte 2023-09-22 13:33:55 +02:00
parent 5a4e47ebed
commit 3dd0419ea9
No known key found for this signature in database
GPG key ID: 43A6A32F83A6F9B1
2 changed files with 19 additions and 14 deletions

View file

@ -20,7 +20,7 @@ use std::collections::BTreeMap;
use std::collections::hash_map::DefaultHasher;
use std::hash::Hasher;
use std::num::NonZeroUsize;
use std::num::{IntErrorKind, NonZeroUsize};
use std::path::PathBuf;
use std::str;
@ -387,7 +387,7 @@ mod desc {
"`all` (default), `except-unused-generics`, `except-unused-functions`, or `off`";
pub const parse_instrument_xray: &str = "either a boolean (`yes`, `no`, `on`, `off`, etc), or a comma separated list of settings: `always` or `never` (mutually exclusive), `ignore-loops`, `instruction-threshold=N`, `skip-entry`, `skip-exit`";
pub const parse_unpretty: &str = "`string` or `string=string`";
pub const parse_treat_err_as_bug: &str = "either no value or a number bigger than 0";
pub const parse_treat_err_as_bug: &str = "either no value or a non-negative number";
pub const parse_trait_solver: &str =
"one of the supported solver modes (`classic`, `next`, or `next-coherence`)";
pub const parse_lto: &str =
@ -986,10 +986,16 @@ mod parse {
pub(crate) fn parse_treat_err_as_bug(slot: &mut Option<NonZeroUsize>, v: Option<&str>) -> bool {
match v {
Some(s) => {
*slot = s.parse().ok();
slot.is_some()
}
Some(s) => match s.parse() {
Ok(val) => {
*slot = Some(val);
true
}
Err(e) => {
*slot = None;
e.kind() == &IntErrorKind::Zero
}
},
None => {
*slot = NonZeroUsize::new(1);
true
@ -1846,7 +1852,8 @@ written to standard error output)"),
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<NonZeroUsize> = (None, parse_treat_err_as_bug, [TRACKED],
"treat error number `val` that occurs as bug"),
"treat the `val`th error that occurs as bug (default if not specified: 0 - don't treat errors as bugs. \
default if specified without a value: 1 - treat the first error as bug)"),
trim_diagnostic_paths: bool = (true, parse_bool, [UNTRACKED],
"in diagnostics, use heuristics to shorten paths referring to items"),
tune_cpu: Option<String> = (None, parse_opt_string, [TRACKED],