Closed
Description
Summary
For the following code:
fn foo<T>() { () }
fn main() {
foo::<i32>();
}
We can get:
warning: unneeded unit expression
--> src/main.rs:1:15
|
1 | fn foo<T>() { () }
| ^^ help: remove the final `()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_unit
= note: `#[warn(clippy::unused_unit)]` on by default
warning: type parameter `T` goes unused in function definition
--> src/main.rs:1:7
|
1 | fn foo<T>() { () }
| ^^^ help: consider removing the parameter
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_type_parameters
= note: `#[warn(clippy::extra_unused_type_parameters)]` on by default
But no warning after removing the unneeded unit expression in foo
.
Lint Name
extra_unused_type_parameters
Reproducer
I tried this code:
fn foo<T>() {}
fn main() {
foo::<i32>();
}
I expected to see this happen:
warning: type parameter `T` goes unused in function definition
--> src/main.rs:1:7
|
1 | fn foo<T>() { () }
| ^^^ help: consider removing the parameter
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_type_parameters
= note: `#[warn(clippy::extra_unused_type_parameters)]` on by default
Instead, nothing happened.
Version
1.80.0-nightly
(2024-05-18 b1ec1bd65f89c1375d2c)