Closed
Description
With the following example code:
fn unused() {
println!("blah");
}
fn unused2(var: i32) {
println!("foo {}", var);
}
fn unused3(
var: i32,
) {
println!("bar {}", var);
}
fn main() {
println!("Hello world!");
}
The compiler produces these warnings:
warning: function is never used: `unused`
--> src/main.rs:1:1
|
1 | fn unused() {
| ^^^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: function is never used: `unused2`
--> src/main.rs:5:1
|
5 | fn unused2(var: i32) {
| ^^^^^^^^^^^^^^^^^^^^
warning: function is never used: `unused3`
--> src/main.rs:9:1
|
9 | / fn unused3(
10 | | var: i32,
11 | | ) {
12 | | println!("bar {}", var);
13 | | }
| |_^
Notice that for fn unused
and fn unused2
, dead_code
is reported on only the first line signature of the function, however for fn unused3
dead_code
is reported on the whole function from start to finish.
This is mostly annoying when writing new functions in an editor like vscode that rls will cause the whole function to be orange-wavy-underlined, making a huge distraction.