`get_unchecked` has incorrect precondition in `impl SliceIndex<[T]> for ops::Range<usize>`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
get_unchecked in impl SliceIndex<[T]> for ops::Range<usize> assumes that Range.start <= Range.end, but this cannot be justified from the safety preconditions in the trait. Notably ranges with Range.start > Range.end are empty ranges and thus always in-bounds.
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 reading the SliceIndex<T> trait safety preconditions and the impl SliceIndex<T> for ops::Range<usize> implementation mentioned in the issue. Check how empty ranges with Range.start > Range.end are treated and identify the existing tests around unchecked slice indexing. Done means the implementation's precondition is justified by the trait contract for every valid range.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100