Skip to content

Commit 941d435

Browse files
committed
Auto merge of #69926 - RoccoDev:master, r=estebank,varkor
rustc: Add a warning count upon completion This adds a `build completed with one warning/x warnings` message, similar to the already present `aborted due to previous error` message.
2 parents 378901d + b85c64c commit 941d435

File tree

308 files changed

+515
-132
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

308 files changed

+515
-132
lines changed

src/librustc_errors/lib.rs

+24-3
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,9 @@ struct HandlerInner {
312312
/// The stashed diagnostics count towards the total error count.
313313
/// When `.abort_if_errors()` is called, these are also emitted.
314314
stashed_diagnostics: FxIndexMap<(Span, StashKey), Diagnostic>,
315+
316+
/// The warning count, used for a recap upon finishing
317+
deduplicated_warn_count: usize,
315318
}
316319

317320
/// A key denoting where from a diagnostic was stashed.
@@ -414,6 +417,7 @@ impl Handler {
414417
flags,
415418
err_count: 0,
416419
deduplicated_err_count: 0,
420+
deduplicated_warn_count: 0,
417421
emitter,
418422
delayed_span_bugs: Vec::new(),
419423
taught_diagnostics: Default::default(),
@@ -439,6 +443,7 @@ impl Handler {
439443
let mut inner = self.inner.borrow_mut();
440444
inner.err_count = 0;
441445
inner.deduplicated_err_count = 0;
446+
inner.deduplicated_warn_count = 0;
442447

443448
// actually free the underlying memory (which `clear` would not do)
444449
inner.delayed_span_bugs = Default::default();
@@ -745,6 +750,8 @@ impl HandlerInner {
745750
self.emitter.emit_diagnostic(diagnostic);
746751
if diagnostic.is_error() {
747752
self.deduplicated_err_count += 1;
753+
} else if diagnostic.level == Warning {
754+
self.deduplicated_warn_count += 1;
748755
}
749756
}
750757
if diagnostic.is_error() {
@@ -763,16 +770,30 @@ impl HandlerInner {
763770
fn print_error_count(&mut self, registry: &Registry) {
764771
self.emit_stashed_diagnostics();
765772

766-
let s = match self.deduplicated_err_count {
767-
0 => return,
773+
let warnings = match self.deduplicated_warn_count {
774+
0 => String::new(),
775+
1 => "1 warning emitted".to_string(),
776+
count => format!("{} warnings emitted", count),
777+
};
778+
let errors = match self.deduplicated_err_count {
779+
0 => String::new(),
768780
1 => "aborting due to previous error".to_string(),
769781
count => format!("aborting due to {} previous errors", count),
770782
};
771783
if self.treat_err_as_bug() {
772784
return;
773785
}
774786

775-
let _ = self.fatal(&s);
787+
match (errors.len(), warnings.len()) {
788+
(0, 0) => return,
789+
(0, _) => self.emit_diagnostic(&Diagnostic::new(Level::Warning, &warnings)),
790+
(_, 0) => {
791+
let _ = self.fatal(&errors);
792+
}
793+
(_, _) => {
794+
let _ = self.fatal(&format!("{}; {}", &errors, &warnings));
795+
}
796+
}
776797

777798
let can_show_explain = self.emitter.should_show_explain();
778799
let are_there_diagnostics = !self.emitted_diagnostic_codes.is_empty();

src/test/rustdoc-ui/deprecated-attrs.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ warning: the `#![doc(passes = "...")]` attribute is considered deprecated
77
|
88
= warning: see issue #44136 <https://github.com/rust-lang/rust/issues/44136> for more information
99

10+
warning: 2 warnings emitted
11+

src/test/rustdoc-ui/intra-links-warning-crlf.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ LL | * It also has an [error].
3131
|
3232
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
3333

34+
warning: 4 warnings emitted
35+

src/test/rustdoc-ui/intra-links-warning.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,5 @@ LL | f!("Foo\nbar [BarF] bar\nbaz");
177177
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
178178
= note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
179179

180+
warning: 19 warnings emitted
181+

src/test/rustdoc-ui/invalid-syntax.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,5 @@ help: mark blocks that do not contain Rust code as text
147147
LL | /// ```text
148148
| ^^^^^^^
149149

150+
warning: 12 warnings emitted
151+

src/test/ui-fulldeps/feature-gate-plugin.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ LL | #![plugin(empty_plugin)]
1515
|
1616
= note: `#[warn(deprecated)]` on by default
1717

18-
error: aborting due to previous error
18+
error: aborting due to previous error; 1 warning emitted
1919

2020
For more information about this error, try `rustc --explain E0658`.

src/test/ui-fulldeps/gated-plugin.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ LL | #![plugin(empty_plugin)]
1515
|
1616
= note: `#[warn(deprecated)]` on by default
1717

18-
error: aborting due to previous error
18+
error: aborting due to previous error; 1 warning emitted
1919

2020
For more information about this error, try `rustc --explain E0658`.

src/test/ui-fulldeps/issue-15778-fail.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ LL | | pub fn main() { }
1818
|
1919
= note: requested on the command line with `-D crate-not-okay`
2020

21-
error: aborting due to previous error
21+
error: aborting due to previous error; 1 warning emitted
2222

src/test/ui-fulldeps/issue-15778-pass.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ LL | #![plugin(lint_for_crate_rpass)]
66
|
77
= note: `#[warn(deprecated)]` on by default
88

9+
warning: 1 warning emitted
10+

src/test/ui-fulldeps/issue-40001.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ LL | #![plugin(issue_40001_plugin)]
66
|
77
= note: `#[warn(deprecated)]` on by default
88

9+
warning: 1 warning emitted
10+

src/test/ui-fulldeps/lint-group-plugin-deny-cmdline.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ LL | fn pleaselintme() { }
2222
|
2323
= note: `-D please-lint` implied by `-D lint-me`
2424

25-
error: aborting due to 2 previous errors
25+
error: aborting due to 2 previous errors; 1 warning emitted
2626

src/test/ui-fulldeps/lint-group-plugin.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ LL | fn pleaselintme() { }
2222
|
2323
= note: `#[warn(please_lint)]` on by default
2424

25+
warning: 3 warnings emitted
26+

src/test/ui-fulldeps/lint-plugin-cmdline-allow.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ LL | #![plugin(lint_plugin_test)]
66
|
77
= note: `#[warn(deprecated)]` on by default
88

9+
warning: 1 warning emitted
10+

src/test/ui-fulldeps/lint-plugin-cmdline-load.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ LL | fn lintme() { }
1414
|
1515
= note: `#[warn(test_lint)]` on by default
1616

17+
warning: 2 warnings emitted
18+

src/test/ui-fulldeps/lint-plugin-deny-attr.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ note: the lint level is defined here
1818
LL | #![deny(test_lint)]
1919
| ^^^^^^^^^
2020

21-
error: aborting due to previous error
21+
error: aborting due to previous error; 1 warning emitted
2222

src/test/ui-fulldeps/lint-plugin-deny-cmdline.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ LL | fn lintme() { }
1414
|
1515
= note: requested on the command line with `-D test-lint`
1616

17-
error: aborting due to previous error
17+
error: aborting due to previous error; 1 warning emitted
1818

src/test/ui-fulldeps/lint-plugin-forbid-attrs.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ LL | #![forbid(test_lint)]
4545
LL | #[allow(test_lint)]
4646
| ^^^^^^^^^ overruled by previous forbid
4747

48-
error: aborting due to 4 previous errors
48+
error: aborting due to 4 previous errors; 1 warning emitted
4949

5050
For more information about this error, try `rustc --explain E0453`.

src/test/ui-fulldeps/lint-plugin-forbid-cmdline.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ LL | #[allow(test_lint)]
3838
|
3939
= note: `forbid` lint level was set on command line
4040

41-
error: aborting due to 4 previous errors
41+
error: aborting due to 4 previous errors; 1 warning emitted
4242

4343
For more information about this error, try `rustc --explain E0453`.

src/test/ui-fulldeps/lint-plugin.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ LL | fn lintme() { }
1414
|
1515
= note: `#[warn(test_lint)]` on by default
1616

17+
warning: 2 warnings emitted
18+

src/test/ui-fulldeps/lint-tool-cmdline-allow.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ warning: lint name `test_lint` is deprecated and does not have an effect anymore
3030
|
3131
= note: requested on the command line with `-A test_lint`
3232

33+
warning: 6 warnings emitted
34+

src/test/ui-fulldeps/lint-tool-test.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,5 @@ warning: lint name `test_group` is deprecated and may not have an effect in the
9696
LL | #[allow(test_group)]
9797
| ^^^^^^^^^^ help: change it to: `clippy::test_group`
9898

99-
error: aborting due to 2 previous errors
99+
error: aborting due to 2 previous errors; 11 warnings emitted
100100

src/test/ui-fulldeps/lto-syntax-extension.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ LL | #![plugin(lto_syntax_extension_plugin)]
66
|
77
= note: `#[warn(deprecated)]` on by default
88

9+
warning: 1 warning emitted
10+

src/test/ui-fulldeps/macro-crate-rlib.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ LL | #![plugin(rlib_crate_test)]
1212
|
1313
= note: `#[warn(deprecated)]` on by default
1414

15-
error: aborting due to previous error
15+
error: aborting due to previous error; 1 warning emitted
1616

src/test/ui-fulldeps/outlive-expansion-phase.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ LL | #![plugin(outlive_expansion_phase)]
66
|
77
= note: `#[warn(deprecated)]` on by default
88

9+
warning: 1 warning emitted
10+

src/test/ui-fulldeps/plugin-args.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ LL | #![plugin(empty_plugin(args))]
1212
|
1313
= note: `#[warn(deprecated)]` on by default
1414

15-
error: aborting due to previous error
15+
error: aborting due to previous error; 1 warning emitted
1616

src/test/ui/anon-params/anon-params-deprecated.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ LL | fn bar_with_default_impl(String, String) {}
3030
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
3131
= note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>
3232

33+
warning: 3 warnings emitted
34+

src/test/ui/array-slice-vec/match_arr_unknown_len.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ LL | [1, 2] => true,
1515
= note: expected array `[u32; 2]`
1616
found array `[u32; _]`
1717

18-
error: aborting due to previous error
18+
error: aborting due to previous error; 1 warning emitted
1919

2020
For more information about this error, try `rustc --explain E0308`.

src/test/ui/asm/asm-misplaced-option.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ warning: expected a clobber, found an option
1010
LL | llvm_asm!("add $2, $1; mov $1, $0" : "=r"(x) : "r"(x), "r"(8_usize) : "cc", "volatile");
1111
| ^^^^^^^^^^
1212

13+
warning: 2 warnings emitted
14+

src/test/ui/associated-type-bounds/duplicate.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,6 @@ error: could not find defining uses
726726
LL | type TADyn3 = dyn Iterator<Item: 'static, Item: 'static>;
727727
| ^^^^^^^^^^^^^
728728

729-
error: aborting due to 96 previous errors
729+
error: aborting due to 96 previous errors; 1 warning emitted
730730

731731
For more information about this error, try `rustc --explain E0719`.

src/test/ui/associated-type-bounds/dyn-lcsit.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ LL | #![feature(impl_trait_in_bindings)]
66
|
77
= note: `#[warn(incomplete_features)]` on by default
88

9+
warning: 1 warning emitted
10+

src/test/ui/associated-type-bounds/lcsit.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ LL | #![feature(impl_trait_in_bindings)]
66
|
77
= note: `#[warn(incomplete_features)]` on by default
88

9+
warning: 1 warning emitted
10+

src/test/ui/associated-type-bounds/type-alias.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,5 @@ help: the bound will not be checked when the type alias is used, and should be r
131131
LL | type _TaInline6<T> = T;
132132
| --
133133

134+
warning: 12 warnings emitted
135+

src/test/ui/async-await/issues/issue-54752-async-block.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ LL | fn main() { let _a = (async { }); }
66
|
77
= note: `#[warn(unused_parens)]` on by default
88

9+
warning: 1 warning emitted
10+

src/test/ui/bad/bad-lint-cap3.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ LL | #![deny(warnings)]
1111
| ^^^^^^^^
1212
= note: `#[warn(unused_imports)]` implied by `#[warn(warnings)]`
1313

14+
warning: 1 warning emitted
15+

src/test/ui/binding/const-param.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ error[E0158]: const parameters cannot be referenced in patterns
1212
LL | N => {}
1313
| ^
1414

15-
error: aborting due to previous error
15+
error: aborting due to previous error; 1 warning emitted
1616

1717
For more information about this error, try `rustc --explain E0158`.

src/test/ui/binding/issue-53114-safety-checks.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,6 @@ LL | match (&u2.a,) { (_,) => { } }
9595
|
9696
= note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
9797

98-
error: aborting due to 7 previous errors
98+
error: aborting due to 7 previous errors; 4 warnings emitted
9999

100100
For more information about this error, try `rustc --explain E0133`.

src/test/ui/block-expr-precedence.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ LL | if (true) { 12; };;; -num;
66
|
77
= note: `#[warn(redundant_semicolons)]` on by default
88

9+
warning: 1 warning emitted
10+

src/test/ui/block-result/block-must-not-have-result-while.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ error[E0308]: mismatched types
1212
LL | true
1313
| ^^^^ expected `()`, found `bool`
1414

15-
error: aborting due to previous error
15+
error: aborting due to previous error; 1 warning emitted
1616

1717
For more information about this error, try `rustc --explain E0308`.

src/test/ui/borrowck/mut-borrow-in-loop.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ LL | (self.func)(arg)
4242
| | mutable borrow starts here in previous iteration of loop
4343
| argument requires that `*arg` is borrowed for `'a`
4444

45-
error: aborting due to 3 previous errors
45+
error: aborting due to 3 previous errors; 1 warning emitted
4646

4747
For more information about this error, try `rustc --explain E0499`.

src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.migrate2015.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ LL | v.push(shared.len());
3535
= warning: this borrowing pattern was not meant to be accepted, and may become a hard error in the future
3636
= note: for more information, see issue #59159 <https://github.com/rust-lang/rust/issues/59159>
3737

38-
error: aborting due to 2 previous errors
38+
error: aborting due to 2 previous errors; 1 warning emitted
3939

4040
For more information about this error, try `rustc --explain E0502`.

src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.migrate2018.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ LL | v.push(shared.len());
3535
= warning: this borrowing pattern was not meant to be accepted, and may become a hard error in the future
3636
= note: for more information, see issue #59159 <https://github.com/rust-lang/rust/issues/59159>
3737

38-
error: aborting due to 2 previous errors
38+
error: aborting due to 2 previous errors; 1 warning emitted
3939

4040
For more information about this error, try `rustc --explain E0502`.

src/test/ui/borrowck/two-phase-reservation-sharing-interference-future-compat-lint.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ LL | #![deny(mutable_borrow_reservation_conflict)]
3636
= warning: this borrowing pattern was not meant to be accepted, and may become a hard error in the future
3737
= note: for more information, see issue #59159 <https://github.com/rust-lang/rust/issues/59159>
3838

39-
error: aborting due to previous error
39+
error: aborting due to previous error; 1 warning emitted
4040

src/test/ui/codemap_tests/unicode_3.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ LL | let s = "ZͨA͑ͦ͒͋ͤ͑̚L̄͑͋Ĝͨͥ̿͒̽̈́Oͥ͛ͭ!̏"; while tru
66
|
77
= note: `#[warn(while_true)]` on by default
88

9+
warning: 1 warning emitted
10+

src/test/ui/coherence/coherence-subtyping.old.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ LL | impl TheTrait for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
1212
= note: for more information, see issue #56105 <https://github.com/rust-lang/rust/issues/56105>
1313
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
1414

15+
warning: 1 warning emitted
16+

src/test/ui/coherence/coherence-subtyping.re.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ LL | impl TheTrait for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
1212
= note: for more information, see issue #56105 <https://github.com/rust-lang/rust/issues/56105>
1313
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
1414

15+
warning: 1 warning emitted
16+

src/test/ui/conditional-compilation/cfg-attr-multi-true.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,5 @@ note: the lint level is defined here
3636
LL | #![warn(unused_must_use)]
3737
| ^^^^^^^^^^^^^^^
3838

39+
warning: 5 warnings emitted
40+

src/test/ui/const-generics/apit-with-const-param.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ LL | #![feature(const_generics)]
66
|
77
= note: `#[warn(incomplete_features)]` on by default
88

9+
warning: 1 warning emitted
10+

src/test/ui/const-generics/argument_order.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ LL | #![feature(const_generics)]
1212
|
1313
= note: `#[warn(incomplete_features)]` on by default
1414

15-
error: aborting due to previous error
15+
error: aborting due to previous error; 1 warning emitted
1616

src/test/ui/const-generics/array-size-in-generic-struct-param.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ LL | arr: [u8; CFG.arr_size],
2222
|
2323
= note: this may fail depending on what value the parameter takes
2424

25-
error: aborting due to 2 previous errors
25+
error: aborting due to 2 previous errors; 1 warning emitted
2626

src/test/ui/const-generics/array-wrapper-struct-ctor.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ LL | #![feature(const_generics)]
66
|
77
= note: `#[warn(incomplete_features)]` on by default
88

9+
warning: 1 warning emitted
10+

0 commit comments

Comments
 (0)