Closed
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)