Skip to content

Commit d1ae3a4

Browse files
authored
Rollup merge of rust-lang#97645 - lcnr:derived-impl-debug, r=cjgillot
don't use a `span_note` for ignored impls Searching for the `derive` isn't too difficult as it's right above the field definition. By using a span these errors are a lot more verbose than they should be, which is especially annoying as one can end up with a lot of `dead_code` warnings.
2 parents 0e33e97 + d7645f4 commit d1ae3a4

File tree

4 files changed

+6
-35
lines changed

4 files changed

+6
-35
lines changed

Diff for: compiler/rustc_passes/src/dead.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -722,11 +722,7 @@ impl<'tcx> DeadVisitor<'tcx> {
722722
traits_str,
723723
is_are
724724
);
725-
let multispan = ign_traits
726-
.iter()
727-
.map(|(_, impl_id)| self.tcx.def_span(*impl_id))
728-
.collect::<Vec<_>>();
729-
err.span_note(multispan, &msg);
725+
err.note(&msg);
730726
}
731727
err.emit();
732728
});

Diff for: src/test/ui/derive-uninhabited-enum-38885.stderr

+1-6
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@ LL | Void(Void),
55
| ^^^^^^^^^^
66
|
77
= note: `-W dead-code` implied by `-W unused`
8-
note: `Foo` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
9-
--> $DIR/derive-uninhabited-enum-38885.rs:10:10
10-
|
11-
LL | #[derive(Debug)]
12-
| ^^^^^
13-
= note: this warning originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
8+
= note: `Foo` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
149

1510
warning: 1 warning emitted
1611

Diff for: src/test/ui/derives/clone-debug-dead-code.stderr

+3-18
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,23 @@ error: field is never read: `f`
1616
LL | struct B { f: () }
1717
| ^^^^^
1818
|
19-
note: `B` has a derived impl for the trait `Clone`, but this is intentionally ignored during dead code analysis
20-
--> $DIR/clone-debug-dead-code.rs:9:10
21-
|
22-
LL | #[derive(Clone)]
23-
| ^^^^^
24-
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
19+
= note: `B` has a derived impl for the trait `Clone`, but this is intentionally ignored during dead code analysis
2520

2621
error: field is never read: `f`
2722
--> $DIR/clone-debug-dead-code.rs:14:12
2823
|
2924
LL | struct C { f: () }
3025
| ^^^^^
3126
|
32-
note: `C` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
33-
--> $DIR/clone-debug-dead-code.rs:13:10
34-
|
35-
LL | #[derive(Debug)]
36-
| ^^^^^
37-
= note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
27+
= note: `C` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
3828

3929
error: field is never read: `f`
4030
--> $DIR/clone-debug-dead-code.rs:18:12
4131
|
4232
LL | struct D { f: () }
4333
| ^^^^^
4434
|
45-
note: `D` has derived impls for the traits `Clone` and `Debug`, but these are intentionally ignored during dead code analysis
46-
--> $DIR/clone-debug-dead-code.rs:17:10
47-
|
48-
LL | #[derive(Debug,Clone)]
49-
| ^^^^^ ^^^^^
50-
= note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
35+
= note: `D` has derived impls for the traits `Clone` and `Debug`, but these are intentionally ignored during dead code analysis
5136

5237
error: field is never read: `f`
5338
--> $DIR/clone-debug-dead-code.rs:21:12

Diff for: src/test/ui/lint/dead-code/unused-variant.stderr

+1-6
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@ note: the lint level is defined here
99
|
1010
LL | #![deny(dead_code)]
1111
| ^^^^^^^^^
12-
note: `Enum` has a derived impl for the trait `Clone`, but this is intentionally ignored during dead code analysis
13-
--> $DIR/unused-variant.rs:3:10
14-
|
15-
LL | #[derive(Clone)]
16-
| ^^^^^
17-
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
12+
= note: `Enum` has a derived impl for the trait `Clone`, but this is intentionally ignored during dead code analysis
1813

1914
error: aborting due to previous error
2015

0 commit comments

Comments
 (0)