Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extra_unused_type_parameters cannot be applied if fn is used #10633

Open
matthiaskrgr opened this issue Apr 11, 2023 · 0 comments
Open

extra_unused_type_parameters cannot be applied if fn is used #10633

matthiaskrgr opened this issue Apr 11, 2023 · 0 comments
Labels
C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied

Comments

@matthiaskrgr
Copy link
Member

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

@matthiaskrgr matthiaskrgr added C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied labels Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied
Projects
None yet
Development

No branches or pull requests

1 participant