rust-lang / rust-lang/rust-clippy
Failing auto fix for `derivable_impls`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
clippy fails to apply an auto fix correctly for the lint derivable_impls. Here's a link to the file in my repo.
Reproducer
I tried this code:
enum Direction {
North,
East,
South,
West,
}
use std::collections::HashSet;
use Direction::*;
impl Default for Direction {
fn default() -> Self {
Direction::North
}
}
I expected to see this happen:
The applied auto fix should produce:
#[derive(Default)]
enum Direction {
#[default]
North,
East,
South,
West,
}
use std::collections::HashSet;
use Direction::*;
Instead, this happened:
The manual Default implementation was removed, but the derived one was not added:
enum Direction {
North,
East,
South,
West,
}
use std::collections::HashSet;
use Direction::*;
Version
rustc 1.68.0 (2c8cc3432 2023-03-06)
binary: rustc
commit-hash: 2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74
commit-date: 2023-03-06
host: x86_64-unknown-linux-gnu
release: 1.68.0
LLVM version: 15.0.6
Additional Labels
I-suggestion-causes-error
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
Start by reproducing the derivable_impls lint with the Rust code shown in the issue and inspect the lint's auto-fix behavior. The fix is complete when applying the suggestion both removes the manual Default implementation and adds #[derive(Default)] with the appropriate #[default] variant.
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
- Mostly clear
- Newbie friendliness
- 35/100