rust-lang / rust-lang/rust-clippy
Identify when buffer is being reused in `read_line` without clearing
Open
Nobody has claimed this yet.
A-lint
E-hard
E-medium
T-MIR
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Identify when a buffer is being reused without clearing in at least read_line, ideally in a general manner (might be impossible to do so), like in the following case:
use std::io;
fn main() {
let mut guess = String::new();
loop {
println!("Enter a number");
io::stdin().read_line(&mut guess).unwrap();
println!("guess: {}", guess);
let guess: u32 = match guess.trim().parse() {
Ok(num) => num,
Err(err) => {
println!("{:?}", err);
continue
},
};
}
CC https://github.com/rust-lang/rust/issues/56681#issuecomment-446431862
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 with the provided read_line example and investigate how Clippy could detect a reused buffer that is not cleared. Determine whether a general lint is feasible beyond this case, then define the diagnostic behavior and verify it with focused examples and tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100