rust-lang / rust-lang/rust-clippy
Lint suggestion: Unnecessary Debug bound
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Hi,
for some reason I believed that #[derive(Debug)] requires all fields of a struct to implement Debug. Thus, I wrote code like the following:
#[derive(Debug)]
pub struct Example<T: Debug> {
inner: T
}
However, since then I learned that #[derive(Debug)] generates the appropriate code that Example<T> only implements Debug when T: Debug. Thus, my Debug bound was completely unnecessary.
I am not sure if this is worth turning into a new lint. If you think not, then feel free to just close this issue.
Thanks for clippy!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no implementation files or tests. Start by locating Clippy's existing lints for redundant generic trait bounds and their test coverage, then verify how a bound such as T: Debug interacts with a derived Debug implementation. Done means the unnecessary-bound pattern is detected without flagging required bounds, with regression coverage added.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100