Skip to content

Commit 5453a9f

Browse files
committed
Add a note to duplicate diagnostics
1 parent 2ffeb46 commit 5453a9f

File tree

166 files changed

+460
-203
lines changed

Some content is hidden

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

166 files changed

+460
-203
lines changed

compiler/rustc_errors/src/lib.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -1376,16 +1376,16 @@ impl HandlerInner {
13761376
self.emitted_diagnostic_codes.insert(code.clone());
13771377
}
13781378

1379-
let already_emitted = |this: &mut Self| {
1379+
let already_emitted = {
13801380
let mut hasher = StableHasher::new();
13811381
diagnostic.hash(&mut hasher);
13821382
let diagnostic_hash = hasher.finish();
1383-
!this.emitted_diagnostics.insert(diagnostic_hash)
1383+
!self.emitted_diagnostics.insert(diagnostic_hash)
13841384
};
13851385

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

14031403
diagnostic.children.extract_if(already_emitted_sub).for_each(|_| {});
1404+
if already_emitted {
1405+
diagnostic.note(
1406+
"duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`",
1407+
);
1408+
}
14041409

14051410
self.emitter.emit_diagnostic(diagnostic);
14061411
if diagnostic.is_error() {

tests/rustdoc-ui/custom_code_classes_in_docs-warning3.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ LL | |
2828
LL | | /// main;
2929
LL | | /// ```
3030
| |_______^
31+
|
32+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
3133

3234
error: aborting due to 2 previous errors
3335

tests/rustdoc-ui/intra-doc/broken-link-in-unused-doc-string.stderr

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

2627
warning: 3 warnings emitted
2728

tests/rustdoc-ui/issues/issue-105742.stderr

+16
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ note: associated type defined here, with 1 lifetime parameter: `'a`
169169
|
170170
LL | type Item<'a, T>;
171171
| ^^^^ --
172+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
172173
help: add missing lifetime argument
173174
|
174175
LL | <Self as SVec>::Item<'a>,
@@ -185,6 +186,7 @@ note: associated type defined here, with 1 generic parameter: `T`
185186
|
186187
LL | type Item<'a, T>;
187188
| ^^^^ -
189+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
188190
help: add missing generic argument
189191
|
190192
LL | <Self as SVec>::Item<T>,
@@ -201,6 +203,7 @@ note: associated type defined here, with 1 lifetime parameter: `'a`
201203
|
202204
LL | type Item<'a, T>;
203205
| ^^^^ --
206+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
204207
help: add missing lifetime argument
205208
|
206209
LL | Output = <Index<<Self as SVec>::Item<'a>,
@@ -217,6 +220,7 @@ note: associated type defined here, with 1 generic parameter: `T`
217220
|
218221
LL | type Item<'a, T>;
219222
| ^^^^ -
223+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
220224
help: add missing generic argument
221225
|
222226
LL | Output = <Index<<Self as SVec>::Item<T>,
@@ -233,6 +237,7 @@ note: associated type defined here, with 1 lifetime parameter: `'a`
233237
|
234238
LL | type Item<'a, T>;
235239
| ^^^^ --
240+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
236241
help: add missing lifetime argument
237242
|
238243
LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item,
@@ -249,6 +254,7 @@ note: associated type defined here, with 1 generic parameter: `T`
249254
|
250255
LL | type Item<'a, T>;
251256
| ^^^^ -
257+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
252258
help: add missing generic argument
253259
|
254260
LL | Output = <Self as SVec>::Item<T>> as SVec>::Item,
@@ -265,6 +271,7 @@ note: associated type defined here, with 1 lifetime parameter: `'a`
265271
|
266272
LL | type Item<'a, T>;
267273
| ^^^^ --
274+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
268275
help: add missing lifetime argument
269276
|
270277
LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>,
@@ -281,6 +288,7 @@ note: associated type defined here, with 1 generic parameter: `T`
281288
|
282289
LL | type Item<'a, T>;
283290
| ^^^^ -
291+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
284292
help: add missing generic argument
285293
|
286294
LL | Output = <Self as SVec>::Item> as SVec>::Item<T>,
@@ -327,6 +335,7 @@ note: associated type defined here, with 1 lifetime parameter: `'a`
327335
|
328336
LL | type Item<'a, T>;
329337
| ^^^^ --
338+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
330339
help: add missing lifetime argument
331340
|
332341
LL | <Self as SVec>::Item<'a>,
@@ -343,6 +352,7 @@ note: associated type defined here, with 1 generic parameter: `T`
343352
|
344353
LL | type Item<'a, T>;
345354
| ^^^^ -
355+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
346356
help: add missing generic argument
347357
|
348358
LL | <Self as SVec>::Item<T>,
@@ -359,6 +369,7 @@ note: associated type defined here, with 1 lifetime parameter: `'a`
359369
|
360370
LL | type Item<'a, T>;
361371
| ^^^^ --
372+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
362373
help: add missing lifetime argument
363374
|
364375
LL | Output = <Index<<Self as SVec>::Item<'a>,
@@ -375,6 +386,7 @@ note: associated type defined here, with 1 generic parameter: `T`
375386
|
376387
LL | type Item<'a, T>;
377388
| ^^^^ -
389+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
378390
help: add missing generic argument
379391
|
380392
LL | Output = <Index<<Self as SVec>::Item<T>,
@@ -391,6 +403,7 @@ note: associated type defined here, with 1 lifetime parameter: `'a`
391403
|
392404
LL | type Item<'a, T>;
393405
| ^^^^ --
406+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
394407
help: add missing lifetime argument
395408
|
396409
LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item,
@@ -407,6 +420,7 @@ note: associated type defined here, with 1 generic parameter: `T`
407420
|
408421
LL | type Item<'a, T>;
409422
| ^^^^ -
423+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
410424
help: add missing generic argument
411425
|
412426
LL | Output = <Self as SVec>::Item<T>> as SVec>::Item,
@@ -423,6 +437,7 @@ note: associated type defined here, with 1 lifetime parameter: `'a`
423437
|
424438
LL | type Item<'a, T>;
425439
| ^^^^ --
440+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
426441
help: add missing lifetime argument
427442
|
428443
LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>,
@@ -439,6 +454,7 @@ note: associated type defined here, with 1 generic parameter: `T`
439454
|
440455
LL | type Item<'a, T>;
441456
| ^^^^ -
457+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
442458
help: add missing generic argument
443459
|
444460
LL | Output = <Self as SVec>::Item> as SVec>::Item<T>,
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1+
// compile-flags: -Zdeduplicate-diagnostics=yes
12
#![deny(unknown_lints)]
23
//~^ NOTE defined here
34
#![allow(rustdoc::missing_doc_code_examples)]
45
//~^ ERROR unknown lint
5-
//~| ERROR unknown lint
6-
//~| ERROR unknown lint
76
//~| NOTE lint is unstable
8-
//~| NOTE lint is unstable
9-
//~| NOTE lint is unstable
10-
//~| NOTE see issue
11-
//~| NOTE see issue
127
//~| NOTE see issue
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: unknown lint: `rustdoc::missing_doc_code_examples`
2-
--> $DIR/feature-gate-rustdoc_missing_doc_code_examples.rs:3:1
2+
--> $DIR/feature-gate-rustdoc_missing_doc_code_examples.rs:4:1
33
|
44
LL | #![allow(rustdoc::missing_doc_code_examples)]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -8,30 +8,10 @@ LL | #![allow(rustdoc::missing_doc_code_examples)]
88
= note: see issue #101730 <https://github.com/rust-lang/rust/issues/101730> for more information
99
= help: add `#![feature(rustdoc_missing_doc_code_examples)]` to the crate attributes to enable
1010
note: the lint level is defined here
11-
--> $DIR/feature-gate-rustdoc_missing_doc_code_examples.rs:1:9
11+
--> $DIR/feature-gate-rustdoc_missing_doc_code_examples.rs:2:9
1212
|
1313
LL | #![deny(unknown_lints)]
1414
| ^^^^^^^^^^^^^
1515

16-
error: unknown lint: `rustdoc::missing_doc_code_examples`
17-
--> $DIR/feature-gate-rustdoc_missing_doc_code_examples.rs:3:1
18-
|
19-
LL | #![allow(rustdoc::missing_doc_code_examples)]
20-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
21-
|
22-
= note: the `rustdoc::missing_doc_code_examples` lint is unstable
23-
= note: see issue #101730 <https://github.com/rust-lang/rust/issues/101730> for more information
24-
= help: add `#![feature(rustdoc_missing_doc_code_examples)]` to the crate attributes to enable
25-
26-
error: unknown lint: `rustdoc::missing_doc_code_examples`
27-
--> $DIR/feature-gate-rustdoc_missing_doc_code_examples.rs:3:1
28-
|
29-
LL | #![allow(rustdoc::missing_doc_code_examples)]
30-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
31-
|
32-
= note: the `rustdoc::missing_doc_code_examples` lint is unstable
33-
= note: see issue #101730 <https://github.com/rust-lang/rust/issues/101730> for more information
34-
= help: add `#![feature(rustdoc_missing_doc_code_examples)]` to the crate attributes to enable
35-
36-
error: aborting due to 3 previous errors
16+
error: aborting due to previous error
3717

tests/rustdoc-ui/unescaped_backticks.stderr

+3
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ LL | | /// level changes.
302302
= help: if you meant to use a literal backtick, escape it
303303
change: or `None` if it isn't.
304304
to this: or `None\` if it isn't.
305+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
305306

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

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

344347
error: unescaped backtick
345348
--> $DIR/unescaped_backticks.rs:349:56

tests/ui-fulldeps/plugin/lint-plugin-forbid-attrs.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ LL | #![forbid(test_lint)]
2727
...
2828
LL | #[allow(test_lint)]
2929
| ^^^^^^^^^ overruled by previous forbid
30+
|
31+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
3032

3133
warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
3234
--> $DIR/lint-plugin-forbid-attrs.rs:5:1

tests/ui-fulldeps/plugin/lint-plugin-forbid-cmdline.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ LL | #[allow(test_lint)]
2121
| ^^^^^^^^^ overruled by previous forbid
2222
|
2323
= note: `forbid` lint level was set on command line
24+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
2425

2526
warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
2627
--> $DIR/lint-plugin-forbid-cmdline.rs:6:1

tests/ui-fulldeps/plugin/lint-tool-cmdline-allow.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ warning: lint name `test_lint` is deprecated and may not have an effect in the f
88
|
99
= help: change it to clippy::test_lint
1010
= note: requested on the command line with `-A test_lint`
11+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
1112

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

3335
warning: 5 warnings emitted
3436

tests/ui-fulldeps/plugin/lint-tool-test.stderr

+12
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,16 @@ warning: lint name `test_lint` is deprecated and may not have an effect in the f
2323
|
2424
LL | #![cfg_attr(foo, warn(test_lint))]
2525
| ^^^^^^^^^ help: change it to: `clippy::test_lint`
26+
|
27+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
2628

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

3337
error: item is named 'lintme'
3438
--> $DIR/lint-tool-test.rs:18:1
@@ -56,6 +60,8 @@ warning: lint name `test_group` is deprecated and may not have an effect in the
5660
|
5761
LL | #[allow(test_group)]
5862
| ^^^^^^^^^^ help: change it to: `clippy::test_group`
63+
|
64+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
5965

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

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

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

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

tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,8 @@ error: `#[lint(...)]` is not a valid attribute
414414
|
415415
LL | #[lint(no_crate_example, code = "E0123")]
416416
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
417+
|
418+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
417419

418420
error: diagnostic slug not specified
419421
--> $DIR/diagnostic-derive.rs:601:1

tests/ui/allocator/not-an-allocator.stderr

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ LL | static A: usize = 0;
1818
| ^^^^^ the trait `GlobalAlloc` is not implemented for `usize`
1919
|
2020
= help: the trait `GlobalAlloc` is implemented for `System`
21+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
2122
= note: this error originates in the attribute macro `global_allocator` (in Nightly builds, run with -Z macro-backtrace for more info)
2223

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

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

4548
error: aborting due to 4 previous errors

tests/ui/associated-consts/defaults-not-assumed-fail.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ note: erroneous constant encountered
2424
LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
2525
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2626
|
27+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
2728
= note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
2829

2930
error: aborting due to previous error

tests/ui/associated-inherent-types/issue-109789.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ LL | fn bar(_: Foo<for<'a> fn(&'a ())>::Assoc) {}
1515
|
1616
= note: expected struct `Foo<fn(&'static ())>`
1717
found struct `Foo<for<'a> fn(&'a ())>`
18+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
1819

1920
error: aborting due to 2 previous errors
2021

0 commit comments

Comments
 (0)