-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
This is a follow-up of #58729 and #63064. PR #65830 fixed the issue of too much being highlighted for plain functions, but it appears to not apply to impl functions.
With the following example code:
fn unused() {
println!("blah");
}
fn unused2(var: i32) {
println!("foo {}", var);
}
fn unused3(
var: i32,
) {
println!("bar {}", var);
}
struct UnusedStruct {
}
impl UnusedStruct {
fn unused_impl_fn_1() {
println!("blah");
}
fn unused_impl_fn_2(var: i32) {
println!("foo {}", var);
}
fn unused_impl_fn_3(
var: i32,
) {
println!("bar {}", var);
}
}
fn main() {
println!("Hello world!");
}
The compiler produces these warnings (on 1.41.0-nightly 2019-11-21 53712f8):
warning: function is never used: `unused`
--> src/main.rs:1:4
|
1 | fn unused() {
| ^^^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: function is never used: `unused2`
--> src/main.rs:5:4
|
5 | fn unused2(var: i32) {
| ^^^^^^^
warning: function is never used: `unused3`
--> src/main.rs:9:4
|
9 | fn unused3(
| ^^^^^^^
warning: struct is never constructed: `UnusedStruct`
--> src/main.rs:15:8
|
15 | struct UnusedStruct {
| ^^^^^^^^^^^^
warning: method is never used: `unused_impl_fn_1`
--> src/main.rs:20:5
|
20 | fn unused_impl_fn_1() {
| ^^^^^^^^^^^^^^^^^^^^^
warning: method is never used: `unused_impl_fn_2`
--> src/main.rs:24:5
|
24 | fn unused_impl_fn_2(var: i32) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: method is never used: `unused_impl_fn_3`
--> src/main.rs:28:5
|
28 | / fn unused_impl_fn_3(
29 | | var: i32,
30 | | ) {
31 | | println!("bar {}", var);
32 | | }
| |_____^
This verifies that the aforementioned fix is working for unused1
/unused2
/unused3
, but not for unused_impl_fn_1
/unused_impl_fn_2
/unused_impl_fn_3
.
(pinging @Quantumplation, @estebank)
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.