Keep current behavior while accepting error count
This commit is contained in:
parent
754037de13
commit
c41ddf1773
3 changed files with 30 additions and 11 deletions
|
@ -816,6 +816,8 @@ macro_rules! options {
|
||||||
Some("crate=integer");
|
Some("crate=integer");
|
||||||
pub const parse_unpretty: Option<&str> =
|
pub const parse_unpretty: Option<&str> =
|
||||||
Some("`string` or `string=string`");
|
Some("`string` or `string=string`");
|
||||||
|
pub const parse_treat_err_as_bug: Option<&str> =
|
||||||
|
Some("either no value or a number bigger than 0");
|
||||||
pub const parse_lto: Option<&str> =
|
pub const parse_lto: Option<&str> =
|
||||||
Some("either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, \
|
Some("either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, \
|
||||||
`fat`, or omitted");
|
`fat`, or omitted");
|
||||||
|
@ -1022,6 +1024,13 @@ macro_rules! options {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn parse_treat_err_as_bug(slot: &mut Option<usize>, 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 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn parse_lto(slot: &mut LtoCli, v: Option<&str>) -> bool {
|
fn parse_lto(slot: &mut LtoCli, v: Option<&str>) -> bool {
|
||||||
if v.is_some() {
|
if v.is_some() {
|
||||||
let mut bool_arg = None;
|
let mut bool_arg = None;
|
||||||
|
@ -1234,7 +1243,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
|
||||||
"parse only; do not compile, assemble, or link"),
|
"parse only; do not compile, assemble, or link"),
|
||||||
no_codegen: bool = (false, parse_bool, [TRACKED],
|
no_codegen: bool = (false, parse_bool, [TRACKED],
|
||||||
"run all passes except codegen; no output"),
|
"run all passes except codegen; no output"),
|
||||||
treat_err_as_bug: Option<usize> = (None, parse_opt_uint, [TRACKED],
|
treat_err_as_bug: Option<usize> = (None, parse_treat_err_as_bug, [TRACKED],
|
||||||
"treat all errors that occur as bugs"),
|
"treat all errors that occur as bugs"),
|
||||||
report_delayed_bugs: bool = (false, parse_bool, [TRACKED],
|
report_delayed_bugs: bool = (false, parse_bool, [TRACKED],
|
||||||
"immediately print bugs registered with `delay_span_bug`"),
|
"immediately print bugs registered with `delay_span_bug`"),
|
||||||
|
@ -3212,7 +3221,7 @@ mod tests {
|
||||||
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
|
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
|
||||||
|
|
||||||
opts = reference.clone();
|
opts = reference.clone();
|
||||||
opts.debugging_opts.treat_err_as_bug = Some(0);
|
opts.debugging_opts.treat_err_as_bug = Some(1);
|
||||||
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
|
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
|
||||||
|
|
||||||
opts = reference.clone();
|
opts = reference.clone();
|
||||||
|
|
|
@ -517,7 +517,19 @@ impl Handler {
|
||||||
|
|
||||||
fn panic_if_treat_err_as_bug(&self) {
|
fn panic_if_treat_err_as_bug(&self) {
|
||||||
if self.treat_err_as_bug() {
|
if self.treat_err_as_bug() {
|
||||||
panic!("encountered error with `-Z treat_err_as_bug");
|
let s = match (self.err_count(), self.flags.treat_err_as_bug.unwrap_or(0)) {
|
||||||
|
(0, _) => return,
|
||||||
|
(1, 1) => "aborting due to `-Z treat-err-as-bug=1`".to_string(),
|
||||||
|
(1, _) => return,
|
||||||
|
(count, as_bug) => {
|
||||||
|
format!(
|
||||||
|
"aborting after {} errors due to `-Z treat-err-as-bug={}`",
|
||||||
|
count,
|
||||||
|
as_bug,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
panic!(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -645,14 +657,12 @@ impl Handler {
|
||||||
1 => "aborting due to previous error".to_string(),
|
1 => "aborting due to previous error".to_string(),
|
||||||
_ => format!("aborting due to {} previous errors", self.err_count())
|
_ => format!("aborting due to {} previous errors", self.err_count())
|
||||||
};
|
};
|
||||||
|
let err_as_bug = self.flags.treat_err_as_bug.unwrap_or(0);
|
||||||
|
if self.err_count() >= err_as_bug {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let _ = if self.treat_err_as_bug() {
|
let _ = self.fatal(&s);
|
||||||
self.fatal(&s)
|
|
||||||
} else {
|
|
||||||
// only emit one backtrace when using `-Z treat-err-as-bug=X`
|
|
||||||
DiagnosticBuilder::new(self, Fatal, &s).emit();
|
|
||||||
FatalError
|
|
||||||
};
|
|
||||||
|
|
||||||
let can_show_explain = self.emitter.borrow().should_show_explain();
|
let can_show_explain = self.emitter.borrow().should_show_explain();
|
||||||
let are_there_diagnostics = !self.emitted_diagnostic_codes.borrow().is_empty();
|
let are_there_diagnostics = !self.emitted_diagnostic_codes.borrow().is_empty();
|
||||||
|
|
|
@ -67,7 +67,7 @@ pub fn run(mut options: Options) -> isize {
|
||||||
let source_map = Lrc::new(SourceMap::new(sessopts.file_path_mapping()));
|
let source_map = Lrc::new(SourceMap::new(sessopts.file_path_mapping()));
|
||||||
let handler =
|
let handler =
|
||||||
errors::Handler::with_tty_emitter(ColorConfig::Auto,
|
errors::Handler::with_tty_emitter(ColorConfig::Auto,
|
||||||
true, false,
|
true, None,
|
||||||
Some(source_map.clone()));
|
Some(source_map.clone()));
|
||||||
|
|
||||||
let mut sess = session::build_session_(
|
let mut sess = session::build_session_(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue