extra_unused_type_parameters cannot be applied if fn is used #10633
Open
Description
Summary
.
Reproducer
I tried this code:
use std::backtrace::Backtrace;
#[inline(never)]
fn func_a() -> Backtrace {
func_b::<u8>()
}
#[inline(never)]
fn func_b<T>() -> Backtrace {
todo!();
}
fn main() {
eprint!("{}", func_a());
}
Clippy will suggest to remove the parameter here
warning: type parameter `T` goes unused in function definition
--> src/main.rs:8:10
|
8 | fn func_b<T>() -> Backtrace {
| ^^^ 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 we still have a call of that function with the parameter in the code which prevent cargo fix
from applying the change smoothly :/
If we --broken-code
it, rustc will error but we can't apply the suggestion of the error unfortunately
error[E0107]: function takes 0 generic arguments but 1 generic argument was supplied
--> src/main.rs:5:5
|
5 | func_b::<u8>()
| ^^^^^^------ help: remove these generics
| |
| expected 0 generic arguments
|
note: function defined here, with 0 generic parameters
--> src/main.rs:8:4
|
8 | fn func_b() -> Backtrace {
| ^^^^^^
Could we make clippy walk through the function calls and suggest the removal of the param in an auto-applicable way there by itself?
Version
clippy 0.1.70 (87a2408 2023-04-11)
Additional Labels
No response