Skip to content

Commit 8e3e6b7

Browse files
committed
Add a note to duplicate diagnostics
1 parent 2ffeb46 commit 8e3e6b7

File tree

154 files changed

+413
-174
lines changed

Some content is hidden

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

154 files changed

+413
-174
lines changed

compiler/rustc_errors/src/lib.rs

Lines changed: 8 additions & 3 deletions
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/ui/allocator/not-an-allocator.stderr

Lines changed: 3 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

tests/ui/associated-type-bounds/duplicate.stderr

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ LL | trait TRS1: Iterator<Item: Copy, Item: Send> {}
373373
| ---------- ^^^^^^^^^^ re-bound here
374374
| |
375375
| `Item` bound here first
376+
|
377+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
376378

377379
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
378380
--> $DIR/duplicate.rs:197:34
@@ -389,6 +391,8 @@ LL | trait TRS2: Iterator<Item: Copy, Item: Copy> {}
389391
| ---------- ^^^^^^^^^^ re-bound here
390392
| |
391393
| `Item` bound here first
394+
|
395+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
392396

393397
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
394398
--> $DIR/duplicate.rs:200:37
@@ -405,6 +409,8 @@ LL | trait TRS3: Iterator<Item: 'static, Item: 'static> {}
405409
| ------------- ^^^^^^^^^^^^^ re-bound here
406410
| |
407411
| `Item` bound here first
412+
|
413+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
408414

409415
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
410416
--> $DIR/duplicate.rs:205:29
@@ -445,6 +451,8 @@ LL | Self: Iterator<Item: Copy, Item: Send>,
445451
| ---------- ^^^^^^^^^^ re-bound here
446452
| |
447453
| `Item` bound here first
454+
|
455+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
448456

449457
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
450458
--> $DIR/duplicate.rs:230:32
@@ -461,6 +469,8 @@ LL | Self: Iterator<Item: Copy, Item: Copy>,
461469
| ---------- ^^^^^^^^^^ re-bound here
462470
| |
463471
| `Item` bound here first
472+
|
473+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
464474

465475
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
466476
--> $DIR/duplicate.rs:237:35
@@ -477,6 +487,8 @@ LL | Self: Iterator<Item: 'static, Item: 'static>,
477487
| ------------- ^^^^^^^^^^^^^ re-bound here
478488
| |
479489
| `Item` bound here first
490+
|
491+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
480492

481493
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
482494
--> $DIR/duplicate.rs:255:40

tests/ui/associated-types/hr-associated-type-bound-param-2.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ LL | trait Z<'a, T: ?Sized>
4545
...
4646
LL | for<'b> <T as Z<'b, u16>>::W: Clone,
4747
| ^^^^^ required by this bound in `Z`
48+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
4849

4950
error: aborting due to 3 previous errors
5051

tests/ui/async-await/drop-tracking-unresolved-typeck-results.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ LL | | });
2323
|
2424
= note: `fn(&'0 ()) -> std::future::Ready<&'0 ()> {std::future::ready::<&'0 ()>}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`...
2525
= note: ...but it actually implements `FnOnce<(&(),)>`
26+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
2627

2728
error: aborting due to 2 previous errors
2829

tests/ui/async-await/return-type-notation/issue-110963-early.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ note: the lifetime requirement is introduced here
4444
|
4545
LL | F: Future + Send + 'static,
4646
| ^^^^
47+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
4748

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

tests/ui/borrowck/regions-bound-missing-bound-in-impl.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ note: ...does not necessarily outlive the lifetime `'c` as defined here
5353
|
5454
LL | fn wrong_bound1<'b,'c,'d:'a+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>) {
5555
| ^^
56+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
5657

5758
error[E0195]: lifetime parameters or bounds on method `wrong_bound2` do not match the trait declaration
5859
--> $DIR/regions-bound-missing-bound-in-impl.rs:42:20

tests/ui/cfg/future-compat-crate-attributes-using-cfg_attr.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ LL | #![cfg_attr(foo, crate_type="bin")]
2525
|
2626
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2727
= note: for more information, see issue #91632 <https://github.com/rust-lang/rust/issues/91632>
28+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
2829

2930
error: `crate_name` within an `#![cfg_attr] attribute is deprecated`
3031
--> $DIR/future-compat-crate-attributes-using-cfg_attr.rs:9:18
@@ -34,6 +35,7 @@ LL | #![cfg_attr(foo, crate_name="bar")]
3435
|
3536
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
3637
= note: for more information, see issue #91632 <https://github.com/rust-lang/rust/issues/91632>
38+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
3739

3840
error: aborting due to 4 previous errors
3941

0 commit comments

Comments
 (0)