Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 789186d

Browse files
committed
Trying out a new message that works a little better for values *and* items
1 parent 7faaf39 commit 789186d

29 files changed

+301
-226
lines changed

compiler/rustc_passes/src/dead.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -589,10 +589,11 @@ impl DeadVisitor<'tcx> {
589589
Applicability::MachineApplicable,
590590
)
591591
.note(&format!(
592-
"the leading underscore helps signal to the reader that the {} may still serve\n\
593-
a purpose even if it isn't used in a way that we can detect (e.g. the {}\nis \
594-
only used through FFI or used only for its effect when dropped)",
595-
descr, descr,
592+
"The leading underscore signals to the reader that while the {} may not be {}\n\
593+
by any Rust code, it still serves some other purpose that isn't detected by rustc.\n\
594+
(e.g. some values are used for their effect when dropped or used in FFI code\n\
595+
exclusively through raw pointers)",
596+
descr, participle,
596597
));
597598
// Force the note we added to the front, before any other subdiagnostics
598599
diag.children.rotate_right(1);

src/test/ui/associated-consts/associated-const-dead-code.stderr

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ error: associated constant is never used: `BAR`
44
LL | const BAR: u32 = 1;
55
| ^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_BAR`
66
|
7-
= note: the leading underscore helps signal to the reader that the associated constant may still serve
8-
a purpose even if it isn't used in a way that we can detect (e.g. the associated constant
9-
is only used through FFI or used only for its effect when dropped)
7+
= note: The leading underscore signals to the reader that while the associated constant may not be used
8+
by any Rust code, it still serves some other purpose that isn't detected by rustc.
9+
(e.g. some values are used for their effect when dropped or used in FFI code
10+
exclusively through raw pointers)
1011
note: the lint level is defined here
1112
--> $DIR/associated-const-dead-code.rs:1:9
1213
|

src/test/ui/derive-uninhabited-enum-38885.stderr

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ warning: variant is never constructed: `Void`
44
LL | Void(Void),
55
| ^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_Void`
66
|
7-
= note: the leading underscore helps signal to the reader that the variant may still serve
8-
a purpose even if it isn't used in a way that we can detect (e.g. the variant
9-
is only used through FFI or used only for its effect when dropped)
7+
= note: The leading underscore signals to the reader that while the variant may not be constructed
8+
by any Rust code, it still serves some other purpose that isn't detected by rustc.
9+
(e.g. some values are used for their effect when dropped or used in FFI code
10+
exclusively through raw pointers)
1011
= note: `-W dead-code` implied by `-W unused`
1112

1213
warning: 1 warning emitted

src/test/ui/issues/issue-37515.stderr

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ warning: type alias is never used: `Z`
44
LL | type Z = dyn for<'x> Send;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_Z`
66
|
7-
= note: the leading underscore helps signal to the reader that the type alias may still serve
8-
a purpose even if it isn't used in a way that we can detect (e.g. the type alias
9-
is only used through FFI or used only for its effect when dropped)
7+
= note: The leading underscore signals to the reader that while the type alias may not be used
8+
by any Rust code, it still serves some other purpose that isn't detected by rustc.
9+
(e.g. some values are used for their effect when dropped or used in FFI code
10+
exclusively through raw pointers)
1011
note: the lint level is defined here
1112
--> $DIR/issue-37515.rs:3:9
1213
|

src/test/ui/lint/dead-code/basic.stderr

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ error: function is never used: `foo`
44
LL | fn foo() {
55
| ^^^ help: if this is intentional, prefix it with an underscore: `_foo`
66
|
7-
= note: the leading underscore helps signal to the reader that the function may still serve
8-
a purpose even if it isn't used in a way that we can detect (e.g. the function
9-
is only used through FFI or used only for its effect when dropped)
7+
= note: The leading underscore signals to the reader that while the function may not be used
8+
by any Rust code, it still serves some other purpose that isn't detected by rustc.
9+
(e.g. some values are used for their effect when dropped or used in FFI code
10+
exclusively through raw pointers)
1011
note: the lint level is defined here
1112
--> $DIR/basic.rs:1:9
1213
|

src/test/ui/lint/dead-code/const-and-self.stderr

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ warning: variant is never constructed: `B`
44
LL | B,
55
| ^ help: if this is intentional, prefix it with an underscore: `_B`
66
|
7-
= note: the leading underscore helps signal to the reader that the variant may still serve
8-
a purpose even if it isn't used in a way that we can detect (e.g. the variant
9-
is only used through FFI or used only for its effect when dropped)
7+
= note: The leading underscore signals to the reader that while the variant may not be constructed
8+
by any Rust code, it still serves some other purpose that isn't detected by rustc.
9+
(e.g. some values are used for their effect when dropped or used in FFI code
10+
exclusively through raw pointers)
1011
note: the lint level is defined here
1112
--> $DIR/const-and-self.rs:3:9
1213
|
@@ -19,9 +20,10 @@ warning: variant is never constructed: `C`
1920
LL | C,
2021
| ^ help: if this is intentional, prefix it with an underscore: `_C`
2122
|
22-
= note: the leading underscore helps signal to the reader that the variant may still serve
23-
a purpose even if it isn't used in a way that we can detect (e.g. the variant
24-
is only used through FFI or used only for its effect when dropped)
23+
= note: The leading underscore signals to the reader that while the variant may not be constructed
24+
by any Rust code, it still serves some other purpose that isn't detected by rustc.
25+
(e.g. some values are used for their effect when dropped or used in FFI code
26+
exclusively through raw pointers)
2527

2628
warning: 2 warnings emitted
2729

src/test/ui/lint/dead-code/drop-only-field-issue-81658.stderr

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ error: field is never read: `guard`
44
LL | guard: MutexGuard<'a, T>,
55
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_guard`
66
|
7-
= note: the leading underscore helps signal to the reader that the field may still serve
8-
a purpose even if it isn't used in a way that we can detect (e.g. the field
9-
is only used through FFI or used only for its effect when dropped)
7+
= note: The leading underscore signals to the reader that while the field may not be read
8+
by any Rust code, it still serves some other purpose that isn't detected by rustc.
9+
(e.g. some values are used for their effect when dropped or used in FFI code
10+
exclusively through raw pointers)
1011
note: the lint level is defined here
1112
--> $DIR/drop-only-field-issue-81658.rs:8:9
1213
|

src/test/ui/lint/dead-code/empty-unused-enum.stderr

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ error: enum is never used: `E`
44
LL | enum E {}
55
| ^ help: if this is intentional, prefix it with an underscore: `_E`
66
|
7-
= note: the leading underscore helps signal to the reader that the enum may still serve
8-
a purpose even if it isn't used in a way that we can detect (e.g. the enum
9-
is only used through FFI or used only for its effect when dropped)
7+
= note: The leading underscore signals to the reader that while the enum may not be used
8+
by any Rust code, it still serves some other purpose that isn't detected by rustc.
9+
(e.g. some values are used for their effect when dropped or used in FFI code
10+
exclusively through raw pointers)
1011
note: the lint level is defined here
1112
--> $DIR/empty-unused-enum.rs:1:9
1213
|

src/test/ui/lint/dead-code/field-used-in-ffi-issue-81658.stderr

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ error: field is never read: `items`
44
LL | items: Option<Vec<T>>,
55
| ^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_items`
66
|
7-
= note: the leading underscore helps signal to the reader that the field may still serve
8-
a purpose even if it isn't used in a way that we can detect (e.g. the field
9-
is only used through FFI or used only for its effect when dropped)
7+
= note: The leading underscore signals to the reader that while the field may not be read
8+
by any Rust code, it still serves some other purpose that isn't detected by rustc.
9+
(e.g. some values are used for their effect when dropped or used in FFI code
10+
exclusively through raw pointers)
1011
note: the lint level is defined here
1112
--> $DIR/field-used-in-ffi-issue-81658.rs:7:9
1213
|

src/test/ui/lint/dead-code/impl-trait.stderr

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ error: type alias is never used: `Unused`
44
LL | type Unused = ();
55
| ^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_Unused`
66
|
7-
= note: the leading underscore helps signal to the reader that the type alias may still serve
8-
a purpose even if it isn't used in a way that we can detect (e.g. the type alias
9-
is only used through FFI or used only for its effect when dropped)
7+
= note: The leading underscore signals to the reader that while the type alias may not be used
8+
by any Rust code, it still serves some other purpose that isn't detected by rustc.
9+
(e.g. some values are used for their effect when dropped or used in FFI code
10+
exclusively through raw pointers)
1011
note: the lint level is defined here
1112
--> $DIR/impl-trait.rs:1:9
1213
|

0 commit comments

Comments
 (0)