rust-lang / rust-lang/rust-clippy
indexing does not trigger missing_panics_doc
Open
Nobody has claimed this yet.
C-bug
I-false-negative
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
missing_panics_doc does not trigger on indexing, which could panic. .get(...).unwrap() is equivalent and does get caught.
Lint Name
missing_panics_doc
Reproducer
I tried this code:
#![warn(clippy::missing_panics_doc)]
pub fn a(sl: &[u8]) {
let _ = sl[2];
}
pub fn b(sl: &[u8]) {
let _ = sl.get(2).unwrap();
}
I expected to see this happen:
warnings on both a and b
Instead, this happened:
warning only on b
Version
rustc 1.80.0 (051478957 2024-07-21)
binary: rustc
commit-hash: 051478957371ee0084a7c0913941d2a8c4757bb9
commit-date: 2024-07-21
host: x86_64-unknown-linux-gnu
release: 1.80.0
LLVM version: 18.1.7
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 missing_panics_doc lint and its handling of indexing expressions. Run the reproducer from the issue and compare diagnostics for sl[2] and sl.get(2).unwrap(). Done means the lint warns on both potentially panicking forms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100