rust-lang / rust-lang/rust-clippy
Improve `indexing_slicing` help message
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
The help message reported by the indexing_slicing lint could be improved to be more specific. Currently its reports are relatively generic suggestions, i.e. slicing may panic. Consider using .get(..n) or .get_mut(..n) instead.
It would be useful if we figured out whether get() or get_mut() were the right function to suggest and reported the index/span's actual value. After these changes the above example might look something like slicing may panic. Consider using .get_mut(..3) instead
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 locating the indexing_slicing lint implementation and its existing tests. Check how the lint determines whether get() or get_mut() applies and how it represents the index or span; done means diagnostics suggest the appropriate method and include the actual value, with tests covering the improved message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100