Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report number of delayed bugs properly with -Ztreat-err-as-bug #101471

Merged
merged 1 commit into from
Sep 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 22 additions & 17 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1250,14 +1250,14 @@ impl HandlerInner {

fn treat_err_as_bug(&self) -> bool {
self.flags.treat_err_as_bug.map_or(false, |c| {
self.err_count()
+ self.lint_err_count
+ self.delayed_span_bugs.len()
+ self.delayed_good_path_bugs.len()
>= c.get()
self.err_count() + self.lint_err_count + self.delayed_bug_count() >= c.get()
})
}

fn delayed_bug_count(&self) -> usize {
self.delayed_span_bugs.len() + self.delayed_good_path_bugs.len()
}

fn print_error_count(&mut self, registry: &Registry) {
self.emit_stashed_diagnostics();

Expand Down Expand Up @@ -1412,12 +1412,7 @@ impl HandlerInner {
// incrementing `err_count` by one, so we need to +1 the comparing.
// FIXME: Would be nice to increment err_count in a more coherent way.
if self.flags.treat_err_as_bug.map_or(false, |c| {
self.err_count()
+ self.lint_err_count
+ self.delayed_span_bugs.len()
+ self.delayed_good_path_bugs.len()
+ 1
>= c.get()
self.err_count() + self.lint_err_count + self.delayed_bug_count() + 1 >= c.get()
}) {
// FIXME: don't abort here if report_delayed_bugs is off
self.span_bug(sp, msg);
Expand Down Expand Up @@ -1518,14 +1513,24 @@ impl HandlerInner {
if self.treat_err_as_bug() {
match (
self.err_count() + self.lint_err_count,
self.delayed_bug_count(),
self.flags.treat_err_as_bug.map(|c| c.get()).unwrap_or(0),
) {
(1, 1) => panic!("aborting due to `-Z treat-err-as-bug=1`"),
(0 | 1, _) => {}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will literally never trigger -- because if the err count is 0 or 1, then for self.treat_err_as_bug() to have evaluated to true, then we must have -Ztreat-err-as-bug=1, which would have matched the previous arm.

(count, as_bug) => panic!(
"aborting after {} errors due to `-Z treat-err-as-bug={}`",
count, as_bug,
),
(1, 0, 1) => panic!("aborting due to `-Z treat-err-as-bug=1`"),
(0, 1, 1) => panic!("aborting due delayed bug with `-Z treat-err-as-bug=1`"),
(count, delayed_count, as_bug) => {
if delayed_count > 0 {
panic!(
"aborting after {} errors and {} delayed bugs due to `-Z treat-err-as-bug={}`",
count, delayed_count, as_bug,
)
} else {
panic!(
"aborting after {} errors due to `-Z treat-err-as-bug={}`",
count, as_bug,
)
}
}
}
}
}
Expand Down