rust-lang / rust-lang/rust-clippy

`extra_unused_type_parameters` fires with `#![allow(unused)]`

Open
#12,385 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug I-false-positive
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

Summary

extra_unused_type_parameters still fires with #![allow(unused)] or dead_code set. It should probably not fire in these cases.

Lint Name

extra_unused_type_parameters

Reproducer

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=3e9fab384e5c8c15f10b55ee39965114

I tried this code:

#![allow(unused)]
#![warn(clippy::extra_unused_type_parameters)]

fn foo<T: Clone>() {
    todo!()
}

I saw this happen:

warning: type parameter `T` goes unused in function definition
 --> src/lib.rs:4:7
  |
4 | fn foo<T: Clone>() {
  |       ^^^^^^^^^^ 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: the lint level is defined here
 --> src/lib.rs:2:9
  |
2 | #![warn(clippy::extra_unused_type_parameters)]
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I expected to see this happen: No error

Version
Current playground, 1.76.0
Additional Labels

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Rust Playground reproducer and the extra_unused_type_parameters lint entry point. Confirm the behavior with #![allow(unused)] and dead_code while the Clippy lint is enabled. Done means the lint no longer reports the unused type parameter in those cases, while its existing warning behavior remains covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.