Skip to content

Commit

Permalink
rustc: Add a warning count upon completion
Browse files Browse the repository at this point in the history
  • Loading branch information
roccodev committed Apr 11, 2020
1 parent 1f3b659 commit b85c64c
Show file tree
Hide file tree
Showing 308 changed files with 515 additions and 132 deletions.
27 changes: 24 additions & 3 deletions src/librustc_errors/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@ struct HandlerInner {
/// The stashed diagnostics count towards the total error count.
/// When `.abort_if_errors()` is called, these are also emitted.
stashed_diagnostics: FxIndexMap<(Span, StashKey), Diagnostic>,

/// The warning count, used for a recap upon finishing
deduplicated_warn_count: usize,
}

/// A key denoting where from a diagnostic was stashed.
Expand Down Expand Up @@ -414,6 +417,7 @@ impl Handler {
flags,
err_count: 0,
deduplicated_err_count: 0,
deduplicated_warn_count: 0,
emitter,
delayed_span_bugs: Vec::new(),
taught_diagnostics: Default::default(),
Expand All @@ -439,6 +443,7 @@ impl Handler {
let mut inner = self.inner.borrow_mut();
inner.err_count = 0;
inner.deduplicated_err_count = 0;
inner.deduplicated_warn_count = 0;

// actually free the underlying memory (which `clear` would not do)
inner.delayed_span_bugs = Default::default();
Expand Down Expand Up @@ -745,6 +750,8 @@ impl HandlerInner {
self.emitter.emit_diagnostic(diagnostic);
if diagnostic.is_error() {
self.deduplicated_err_count += 1;
} else if diagnostic.level == Warning {
self.deduplicated_warn_count += 1;
}
}
if diagnostic.is_error() {
Expand All @@ -763,16 +770,30 @@ impl HandlerInner {
fn print_error_count(&mut self, registry: &Registry) {
self.emit_stashed_diagnostics();

let s = match self.deduplicated_err_count {
0 => return,
let warnings = match self.deduplicated_warn_count {
0 => String::new(),
1 => "1 warning emitted".to_string(),
count => format!("{} warnings emitted", count),
};
let errors = match self.deduplicated_err_count {
0 => String::new(),
1 => "aborting due to previous error".to_string(),
count => format!("aborting due to {} previous errors", count),
};
if self.treat_err_as_bug() {
return;
}

let _ = self.fatal(&s);
match (errors.len(), warnings.len()) {
(0, 0) => return,
(0, _) => self.emit_diagnostic(&Diagnostic::new(Level::Warning, &warnings)),
(_, 0) => {
let _ = self.fatal(&errors);
}
(_, _) => {
let _ = self.fatal(&format!("{}; {}", &errors, &warnings));
}
}

let can_show_explain = self.emitter.should_show_explain();
let are_there_diagnostics = !self.emitted_diagnostic_codes.is_empty();
Expand Down
2 changes: 2 additions & 0 deletions src/test/rustdoc-ui/deprecated-attrs.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ warning: the `#![doc(passes = "...")]` attribute is considered deprecated
|
= warning: see issue #44136 <https://github.com/rust-lang/rust/issues/44136> for more information

warning: 2 warnings emitted

2 changes: 2 additions & 0 deletions src/test/rustdoc-ui/intra-links-warning-crlf.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ LL | * It also has an [error].
|
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`

warning: 4 warnings emitted

2 changes: 2 additions & 0 deletions src/test/rustdoc-ui/intra-links-warning.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,5 @@ LL | f!("Foo\nbar [BarF] bar\nbaz");
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
= note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: 19 warnings emitted

2 changes: 2 additions & 0 deletions src/test/rustdoc-ui/invalid-syntax.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,5 @@ help: mark blocks that do not contain Rust code as text
LL | /// ```text
| ^^^^^^^

warning: 12 warnings emitted

2 changes: 1 addition & 1 deletion src/test/ui-fulldeps/feature-gate-plugin.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ LL | #![plugin(empty_plugin)]
|
= note: `#[warn(deprecated)]` on by default

error: aborting due to previous error
error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0658`.
2 changes: 1 addition & 1 deletion src/test/ui-fulldeps/gated-plugin.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ LL | #![plugin(empty_plugin)]
|
= note: `#[warn(deprecated)]` on by default

error: aborting due to previous error
error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0658`.
2 changes: 1 addition & 1 deletion src/test/ui-fulldeps/issue-15778-fail.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ LL | | pub fn main() { }
|
= note: requested on the command line with `-D crate-not-okay`

error: aborting due to previous error
error: aborting due to previous error; 1 warning emitted

2 changes: 2 additions & 0 deletions src/test/ui-fulldeps/issue-15778-pass.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ LL | #![plugin(lint_for_crate_rpass)]
|
= note: `#[warn(deprecated)]` on by default

warning: 1 warning emitted

2 changes: 2 additions & 0 deletions src/test/ui-fulldeps/issue-40001.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ LL | #![plugin(issue_40001_plugin)]
|
= note: `#[warn(deprecated)]` on by default

warning: 1 warning emitted

2 changes: 1 addition & 1 deletion src/test/ui-fulldeps/lint-group-plugin-deny-cmdline.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ LL | fn pleaselintme() { }
|
= note: `-D please-lint` implied by `-D lint-me`

error: aborting due to 2 previous errors
error: aborting due to 2 previous errors; 1 warning emitted

2 changes: 2 additions & 0 deletions src/test/ui-fulldeps/lint-group-plugin.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ LL | fn pleaselintme() { }
|
= note: `#[warn(please_lint)]` on by default

warning: 3 warnings emitted

2 changes: 2 additions & 0 deletions src/test/ui-fulldeps/lint-plugin-cmdline-allow.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ LL | #![plugin(lint_plugin_test)]
|
= note: `#[warn(deprecated)]` on by default

warning: 1 warning emitted

2 changes: 2 additions & 0 deletions src/test/ui-fulldeps/lint-plugin-cmdline-load.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ LL | fn lintme() { }
|
= note: `#[warn(test_lint)]` on by default

warning: 2 warnings emitted

2 changes: 1 addition & 1 deletion src/test/ui-fulldeps/lint-plugin-deny-attr.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ note: the lint level is defined here
LL | #![deny(test_lint)]
| ^^^^^^^^^

error: aborting due to previous error
error: aborting due to previous error; 1 warning emitted

2 changes: 1 addition & 1 deletion src/test/ui-fulldeps/lint-plugin-deny-cmdline.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ LL | fn lintme() { }
|
= note: requested on the command line with `-D test-lint`

error: aborting due to previous error
error: aborting due to previous error; 1 warning emitted

2 changes: 1 addition & 1 deletion src/test/ui-fulldeps/lint-plugin-forbid-attrs.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ LL | #![forbid(test_lint)]
LL | #[allow(test_lint)]
| ^^^^^^^^^ overruled by previous forbid

error: aborting due to 4 previous errors
error: aborting due to 4 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0453`.
2 changes: 1 addition & 1 deletion src/test/ui-fulldeps/lint-plugin-forbid-cmdline.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ LL | #[allow(test_lint)]
|
= note: `forbid` lint level was set on command line

error: aborting due to 4 previous errors
error: aborting due to 4 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0453`.
2 changes: 2 additions & 0 deletions src/test/ui-fulldeps/lint-plugin.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ LL | fn lintme() { }
|
= note: `#[warn(test_lint)]` on by default

warning: 2 warnings emitted

2 changes: 2 additions & 0 deletions src/test/ui-fulldeps/lint-tool-cmdline-allow.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ warning: lint name `test_lint` is deprecated and does not have an effect anymore
|
= note: requested on the command line with `-A test_lint`

warning: 6 warnings emitted

2 changes: 1 addition & 1 deletion src/test/ui-fulldeps/lint-tool-test.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,5 @@ warning: lint name `test_group` is deprecated and may not have an effect in the
LL | #[allow(test_group)]
| ^^^^^^^^^^ help: change it to: `clippy::test_group`

error: aborting due to 2 previous errors
error: aborting due to 2 previous errors; 11 warnings emitted

2 changes: 2 additions & 0 deletions src/test/ui-fulldeps/lto-syntax-extension.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ LL | #![plugin(lto_syntax_extension_plugin)]
|
= note: `#[warn(deprecated)]` on by default

warning: 1 warning emitted

2 changes: 1 addition & 1 deletion src/test/ui-fulldeps/macro-crate-rlib.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ LL | #![plugin(rlib_crate_test)]
|
= note: `#[warn(deprecated)]` on by default

error: aborting due to previous error
error: aborting due to previous error; 1 warning emitted

2 changes: 2 additions & 0 deletions src/test/ui-fulldeps/outlive-expansion-phase.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ LL | #![plugin(outlive_expansion_phase)]
|
= note: `#[warn(deprecated)]` on by default

warning: 1 warning emitted

2 changes: 1 addition & 1 deletion src/test/ui-fulldeps/plugin-args.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ LL | #![plugin(empty_plugin(args))]
|
= note: `#[warn(deprecated)]` on by default

error: aborting due to previous error
error: aborting due to previous error; 1 warning emitted

2 changes: 2 additions & 0 deletions src/test/ui/anon-params/anon-params-deprecated.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ LL | fn bar_with_default_impl(String, String) {}
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
= note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>

warning: 3 warnings emitted

2 changes: 1 addition & 1 deletion src/test/ui/array-slice-vec/match_arr_unknown_len.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ LL | [1, 2] => true,
= note: expected array `[u32; 2]`
found array `[u32; _]`

error: aborting due to previous error
error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0308`.
2 changes: 2 additions & 0 deletions src/test/ui/asm/asm-misplaced-option.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ warning: expected a clobber, found an option
LL | llvm_asm!("add $2, $1; mov $1, $0" : "=r"(x) : "r"(x), "r"(8_usize) : "cc", "volatile");
| ^^^^^^^^^^

warning: 2 warnings emitted

2 changes: 1 addition & 1 deletion src/test/ui/associated-type-bounds/duplicate.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,6 @@ error: could not find defining uses
LL | type TADyn3 = dyn Iterator<Item: 'static, Item: 'static>;
| ^^^^^^^^^^^^^

error: aborting due to 96 previous errors
error: aborting due to 96 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0719`.
2 changes: 2 additions & 0 deletions src/test/ui/associated-type-bounds/dyn-lcsit.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ LL | #![feature(impl_trait_in_bindings)]
|
= note: `#[warn(incomplete_features)]` on by default

warning: 1 warning emitted

2 changes: 2 additions & 0 deletions src/test/ui/associated-type-bounds/lcsit.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ LL | #![feature(impl_trait_in_bindings)]
|
= note: `#[warn(incomplete_features)]` on by default

warning: 1 warning emitted

2 changes: 2 additions & 0 deletions src/test/ui/associated-type-bounds/type-alias.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,5 @@ help: the bound will not be checked when the type alias is used, and should be r
LL | type _TaInline6<T> = T;
| --

warning: 12 warnings emitted

2 changes: 2 additions & 0 deletions src/test/ui/async-await/issues/issue-54752-async-block.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ LL | fn main() { let _a = (async { }); }
|
= note: `#[warn(unused_parens)]` on by default

warning: 1 warning emitted

2 changes: 2 additions & 0 deletions src/test/ui/bad/bad-lint-cap3.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ LL | #![deny(warnings)]
| ^^^^^^^^
= note: `#[warn(unused_imports)]` implied by `#[warn(warnings)]`

warning: 1 warning emitted

2 changes: 1 addition & 1 deletion src/test/ui/binding/const-param.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ error[E0158]: const parameters cannot be referenced in patterns
LL | N => {}
| ^

error: aborting due to previous error
error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0158`.
2 changes: 1 addition & 1 deletion src/test/ui/binding/issue-53114-safety-checks.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ LL | match (&u2.a,) { (_,) => { } }
|
= note: the field may not be properly initialized: using uninitialized data will cause undefined behavior

error: aborting due to 7 previous errors
error: aborting due to 7 previous errors; 4 warnings emitted

For more information about this error, try `rustc --explain E0133`.
2 changes: 2 additions & 0 deletions src/test/ui/block-expr-precedence.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ LL | if (true) { 12; };;; -num;
|
= note: `#[warn(redundant_semicolons)]` on by default

warning: 1 warning emitted

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ error[E0308]: mismatched types
LL | true
| ^^^^ expected `()`, found `bool`

error: aborting due to previous error
error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0308`.
2 changes: 1 addition & 1 deletion src/test/ui/borrowck/mut-borrow-in-loop.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ LL | (self.func)(arg)
| | mutable borrow starts here in previous iteration of loop
| argument requires that `*arg` is borrowed for `'a`

error: aborting due to 3 previous errors
error: aborting due to 3 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0499`.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ LL | v.push(shared.len());
= warning: this borrowing pattern was not meant to be accepted, and may become a hard error in the future
= note: for more information, see issue #59159 <https://github.com/rust-lang/rust/issues/59159>

error: aborting due to 2 previous errors
error: aborting due to 2 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0502`.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ LL | v.push(shared.len());
= warning: this borrowing pattern was not meant to be accepted, and may become a hard error in the future
= note: for more information, see issue #59159 <https://github.com/rust-lang/rust/issues/59159>

error: aborting due to 2 previous errors
error: aborting due to 2 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0502`.
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ LL | #![deny(mutable_borrow_reservation_conflict)]
= warning: this borrowing pattern was not meant to be accepted, and may become a hard error in the future
= note: for more information, see issue #59159 <https://github.com/rust-lang/rust/issues/59159>

error: aborting due to previous error
error: aborting due to previous error; 1 warning emitted

2 changes: 2 additions & 0 deletions src/test/ui/codemap_tests/unicode_3.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ LL | let s = "ZͨA͑ͦ͒͋ͤ͑̚L̄͑͋Ĝͨͥ̿͒̽̈́Oͥ͛ͭ!̏"; while tru
|
= note: `#[warn(while_true)]` on by default

warning: 1 warning emitted

2 changes: 2 additions & 0 deletions src/test/ui/coherence/coherence-subtyping.old.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ LL | impl TheTrait for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
= note: for more information, see issue #56105 <https://github.com/rust-lang/rust/issues/56105>
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details

warning: 1 warning emitted

2 changes: 2 additions & 0 deletions src/test/ui/coherence/coherence-subtyping.re.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ LL | impl TheTrait for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
= note: for more information, see issue #56105 <https://github.com/rust-lang/rust/issues/56105>
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details

warning: 1 warning emitted

Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ note: the lint level is defined here
LL | #![warn(unused_must_use)]
| ^^^^^^^^^^^^^^^

warning: 5 warnings emitted

2 changes: 2 additions & 0 deletions src/test/ui/const-generics/apit-with-const-param.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ LL | #![feature(const_generics)]
|
= note: `#[warn(incomplete_features)]` on by default

warning: 1 warning emitted

2 changes: 1 addition & 1 deletion src/test/ui/const-generics/argument_order.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ LL | #![feature(const_generics)]
|
= note: `#[warn(incomplete_features)]` on by default

error: aborting due to previous error
error: aborting due to previous error; 1 warning emitted

Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ LL | arr: [u8; CFG.arr_size],
|
= note: this may fail depending on what value the parameter takes

error: aborting due to 2 previous errors
error: aborting due to 2 previous errors; 1 warning emitted

2 changes: 2 additions & 0 deletions src/test/ui/const-generics/array-wrapper-struct-ctor.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ LL | #![feature(const_generics)]
|
= note: `#[warn(incomplete_features)]` on by default

warning: 1 warning emitted

Loading

0 comments on commit b85c64c

Please sign in to comment.