Skip to content

Commit

Permalink
Unrolled build for rust-lang#116428
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#116428 - Alexendoo:note-duplicate-diagnostics, r=compiler-errors,estebank

Add a note to duplicate diagnostics

Helps explain why there may be a difference between manual testing and the test suite output and highlights them as something to potentially look into

For existing duplicate diagnostics I just blessed them other than a few files that had other `NOTE` annotations in
  • Loading branch information
rust-timer authored Oct 5, 2023
2 parents 3bcad65 + 5453a9f commit 5e5b8a0
Show file tree
Hide file tree
Showing 166 changed files with 460 additions and 203 deletions.
11 changes: 8 additions & 3 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1376,16 +1376,16 @@ impl HandlerInner {
self.emitted_diagnostic_codes.insert(code.clone());
}

let already_emitted = |this: &mut Self| {
let already_emitted = {
let mut hasher = StableHasher::new();
diagnostic.hash(&mut hasher);
let diagnostic_hash = hasher.finish();
!this.emitted_diagnostics.insert(diagnostic_hash)
!self.emitted_diagnostics.insert(diagnostic_hash)
};

// Only emit the diagnostic if we've been asked to deduplicate or
// haven't already emitted an equivalent diagnostic.
if !(self.flags.deduplicate_diagnostics && already_emitted(self)) {
if !(self.flags.deduplicate_diagnostics && already_emitted) {
debug!(?diagnostic);
debug!(?self.emitted_diagnostics);
let already_emitted_sub = |sub: &mut SubDiagnostic| {
Expand All @@ -1401,6 +1401,11 @@ impl HandlerInner {
};

diagnostic.children.extract_if(already_emitted_sub).for_each(|_| {});
if already_emitted {
diagnostic.note(
"duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`",
);
}

self.emitter.emit_diagnostic(diagnostic);
if diagnostic.is_error() {
Expand Down
2 changes: 2 additions & 0 deletions tests/rustdoc-ui/custom_code_classes_in_docs-warning3.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ LL | |
LL | | /// main;
LL | | /// ```
| |_______^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: aborting due to 2 previous errors

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ LL | /// [1]
| ^ no item named `1` in scope
|
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

warning: 3 warnings emitted

16 changes: 16 additions & 0 deletions tests/rustdoc-ui/issues/issue-105742.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ note: associated type defined here, with 1 lifetime parameter: `'a`
|
LL | type Item<'a, T>;
| ^^^^ --
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | <Self as SVec>::Item<'a>,
Expand All @@ -185,6 +186,7 @@ note: associated type defined here, with 1 generic parameter: `T`
|
LL | type Item<'a, T>;
| ^^^^ -
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing generic argument
|
LL | <Self as SVec>::Item<T>,
Expand All @@ -201,6 +203,7 @@ note: associated type defined here, with 1 lifetime parameter: `'a`
|
LL | type Item<'a, T>;
| ^^^^ --
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | Output = <Index<<Self as SVec>::Item<'a>,
Expand All @@ -217,6 +220,7 @@ note: associated type defined here, with 1 generic parameter: `T`
|
LL | type Item<'a, T>;
| ^^^^ -
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing generic argument
|
LL | Output = <Index<<Self as SVec>::Item<T>,
Expand All @@ -233,6 +237,7 @@ note: associated type defined here, with 1 lifetime parameter: `'a`
|
LL | type Item<'a, T>;
| ^^^^ --
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item,
Expand All @@ -249,6 +254,7 @@ note: associated type defined here, with 1 generic parameter: `T`
|
LL | type Item<'a, T>;
| ^^^^ -
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing generic argument
|
LL | Output = <Self as SVec>::Item<T>> as SVec>::Item,
Expand All @@ -265,6 +271,7 @@ note: associated type defined here, with 1 lifetime parameter: `'a`
|
LL | type Item<'a, T>;
| ^^^^ --
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>,
Expand All @@ -281,6 +288,7 @@ note: associated type defined here, with 1 generic parameter: `T`
|
LL | type Item<'a, T>;
| ^^^^ -
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing generic argument
|
LL | Output = <Self as SVec>::Item> as SVec>::Item<T>,
Expand Down Expand Up @@ -327,6 +335,7 @@ note: associated type defined here, with 1 lifetime parameter: `'a`
|
LL | type Item<'a, T>;
| ^^^^ --
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | <Self as SVec>::Item<'a>,
Expand All @@ -343,6 +352,7 @@ note: associated type defined here, with 1 generic parameter: `T`
|
LL | type Item<'a, T>;
| ^^^^ -
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing generic argument
|
LL | <Self as SVec>::Item<T>,
Expand All @@ -359,6 +369,7 @@ note: associated type defined here, with 1 lifetime parameter: `'a`
|
LL | type Item<'a, T>;
| ^^^^ --
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | Output = <Index<<Self as SVec>::Item<'a>,
Expand All @@ -375,6 +386,7 @@ note: associated type defined here, with 1 generic parameter: `T`
|
LL | type Item<'a, T>;
| ^^^^ -
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing generic argument
|
LL | Output = <Index<<Self as SVec>::Item<T>,
Expand All @@ -391,6 +403,7 @@ note: associated type defined here, with 1 lifetime parameter: `'a`
|
LL | type Item<'a, T>;
| ^^^^ --
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item,
Expand All @@ -407,6 +420,7 @@ note: associated type defined here, with 1 generic parameter: `T`
|
LL | type Item<'a, T>;
| ^^^^ -
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing generic argument
|
LL | Output = <Self as SVec>::Item<T>> as SVec>::Item,
Expand All @@ -423,6 +437,7 @@ note: associated type defined here, with 1 lifetime parameter: `'a`
|
LL | type Item<'a, T>;
| ^^^^ --
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing lifetime argument
|
LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>,
Expand All @@ -439,6 +454,7 @@ note: associated type defined here, with 1 generic parameter: `T`
|
LL | type Item<'a, T>;
| ^^^^ -
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: add missing generic argument
|
LL | Output = <Self as SVec>::Item> as SVec>::Item<T>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
// compile-flags: -Zdeduplicate-diagnostics=yes
#![deny(unknown_lints)]
//~^ NOTE defined here
#![allow(rustdoc::missing_doc_code_examples)]
//~^ ERROR unknown lint
//~| ERROR unknown lint
//~| ERROR unknown lint
//~| NOTE lint is unstable
//~| NOTE lint is unstable
//~| NOTE lint is unstable
//~| NOTE see issue
//~| NOTE see issue
//~| NOTE see issue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: unknown lint: `rustdoc::missing_doc_code_examples`
--> $DIR/feature-gate-rustdoc_missing_doc_code_examples.rs:3:1
--> $DIR/feature-gate-rustdoc_missing_doc_code_examples.rs:4:1
|
LL | #![allow(rustdoc::missing_doc_code_examples)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -8,30 +8,10 @@ LL | #![allow(rustdoc::missing_doc_code_examples)]
= note: see issue #101730 <https://github.com/rust-lang/rust/issues/101730> for more information
= help: add `#![feature(rustdoc_missing_doc_code_examples)]` to the crate attributes to enable
note: the lint level is defined here
--> $DIR/feature-gate-rustdoc_missing_doc_code_examples.rs:1:9
--> $DIR/feature-gate-rustdoc_missing_doc_code_examples.rs:2:9
|
LL | #![deny(unknown_lints)]
| ^^^^^^^^^^^^^

error: unknown lint: `rustdoc::missing_doc_code_examples`
--> $DIR/feature-gate-rustdoc_missing_doc_code_examples.rs:3:1
|
LL | #![allow(rustdoc::missing_doc_code_examples)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: the `rustdoc::missing_doc_code_examples` lint is unstable
= note: see issue #101730 <https://github.com/rust-lang/rust/issues/101730> for more information
= help: add `#![feature(rustdoc_missing_doc_code_examples)]` to the crate attributes to enable

error: unknown lint: `rustdoc::missing_doc_code_examples`
--> $DIR/feature-gate-rustdoc_missing_doc_code_examples.rs:3:1
|
LL | #![allow(rustdoc::missing_doc_code_examples)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: the `rustdoc::missing_doc_code_examples` lint is unstable
= note: see issue #101730 <https://github.com/rust-lang/rust/issues/101730> for more information
= help: add `#![feature(rustdoc_missing_doc_code_examples)]` to the crate attributes to enable

error: aborting due to 3 previous errors
error: aborting due to previous error

3 changes: 3 additions & 0 deletions tests/rustdoc-ui/unescaped_backticks.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ LL | | /// level changes.
= help: if you meant to use a literal backtick, escape it
change: or `None` if it isn't.
to this: or `None\` if it isn't.
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: unescaped backtick
--> $DIR/unescaped_backticks.rs:323:5
Expand All @@ -321,6 +322,7 @@ LL | | /// level changes.
= help: if you meant to use a literal backtick, escape it
change: `on_event` should be called.
to this: `on_event\` should be called.
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: unescaped backtick
--> $DIR/unescaped_backticks.rs:323:5
Expand All @@ -340,6 +342,7 @@ LL | | /// level changes.
= help: if you meant to use a literal backtick, escape it
change: [`rebuild_interest_cache`][rebuild] is called after the value of the max
to this: [`rebuild_interest_cache\`][rebuild] is called after the value of the max
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: unescaped backtick
--> $DIR/unescaped_backticks.rs:349:56
Expand Down
2 changes: 2 additions & 0 deletions tests/ui-fulldeps/plugin/lint-plugin-forbid-attrs.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ LL | #![forbid(test_lint)]
...
LL | #[allow(test_lint)]
| ^^^^^^^^^ overruled by previous forbid
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
--> $DIR/lint-plugin-forbid-attrs.rs:5:1
Expand Down
1 change: 1 addition & 0 deletions tests/ui-fulldeps/plugin/lint-plugin-forbid-cmdline.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ LL | #[allow(test_lint)]
| ^^^^^^^^^ overruled by previous forbid
|
= note: `forbid` lint level was set on command line
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
--> $DIR/lint-plugin-forbid-cmdline.rs:6:1
Expand Down
2 changes: 2 additions & 0 deletions tests/ui-fulldeps/plugin/lint-tool-cmdline-allow.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ warning: lint name `test_lint` is deprecated and may not have an effect in the f
|
= help: change it to clippy::test_lint
= note: requested on the command line with `-A test_lint`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

warning: item is named 'lintme'
--> $DIR/lint-tool-cmdline-allow.rs:9:1
Expand All @@ -29,6 +30,7 @@ warning: lint name `test_lint` is deprecated and may not have an effect in the f
|
= help: change it to clippy::test_lint
= note: requested on the command line with `-A test_lint`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

warning: 5 warnings emitted

12 changes: 12 additions & 0 deletions tests/ui-fulldeps/plugin/lint-tool-test.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ warning: lint name `test_lint` is deprecated and may not have an effect in the f
|
LL | #![cfg_attr(foo, warn(test_lint))]
| ^^^^^^^^^ help: change it to: `clippy::test_lint`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

warning: lint name `clippy_group` is deprecated and may not have an effect in the future.
--> $DIR/lint-tool-test.rs:13:9
|
LL | #![deny(clippy_group)]
| ^^^^^^^^^^^^ help: change it to: `clippy::group`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: item is named 'lintme'
--> $DIR/lint-tool-test.rs:18:1
Expand Down Expand Up @@ -56,6 +60,8 @@ 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`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

warning: unknown lint: `this_lint_does_not_exist`
--> $DIR/lint-tool-test.rs:33:8
Expand All @@ -78,18 +84,24 @@ warning: lint name `test_lint` is deprecated and may not have an effect in the f
|
LL | #![cfg_attr(foo, warn(test_lint))]
| ^^^^^^^^^ help: change it to: `clippy::test_lint`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

warning: lint name `clippy_group` is deprecated and may not have an effect in the future.
--> $DIR/lint-tool-test.rs:13:9
|
LL | #![deny(clippy_group)]
| ^^^^^^^^^^^^ help: change it to: `clippy::group`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

warning: lint name `test_group` is deprecated and may not have an effect in the future.
--> $DIR/lint-tool-test.rs:29:9
|
LL | #[allow(test_group)]
| ^^^^^^^^^^ help: change it to: `clippy::test_group`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

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

2 changes: 2 additions & 0 deletions tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,8 @@ error: `#[lint(...)]` is not a valid attribute
|
LL | #[lint(no_crate_example, code = "E0123")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:601:1
Expand Down
3 changes: 3 additions & 0 deletions tests/ui/allocator/not-an-allocator.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ LL | static A: usize = 0;
| ^^^^^ the trait `GlobalAlloc` is not implemented for `usize`
|
= help: the trait `GlobalAlloc` is implemented for `System`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
= note: this error originates in the attribute macro `global_allocator` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied
Expand All @@ -29,6 +30,7 @@ LL | static A: usize = 0;
| ^^^^^ the trait `GlobalAlloc` is not implemented for `usize`
|
= help: the trait `GlobalAlloc` is implemented for `System`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
= note: this error originates in the attribute macro `global_allocator` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied
Expand All @@ -40,6 +42,7 @@ LL | static A: usize = 0;
| ^^^^^ the trait `GlobalAlloc` is not implemented for `usize`
|
= help: the trait `GlobalAlloc` is implemented for `System`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
= note: this error originates in the attribute macro `global_allocator` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 4 previous errors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ note: erroneous constant encountered
LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
= note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error
Expand Down
1 change: 1 addition & 0 deletions tests/ui/associated-inherent-types/issue-109789.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ LL | fn bar(_: Foo<for<'a> fn(&'a ())>::Assoc) {}
|
= note: expected struct `Foo<fn(&'static ())>`
found struct `Foo<for<'a> fn(&'a ())>`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: aborting due to 2 previous errors

Expand Down
Loading

0 comments on commit 5e5b8a0

Please sign in to comment.