diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2025-04-06 10:42:29 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-06 10:42:29 +0000 |
| commit | cf9cffa114ce5a780aa8283096bf85c51be7a4f5 (patch) | |
| tree | 6c99356bdd054d73c18f13dfd093ac4608dd8a27 /tests/rustdoc/source-code-pages/source-code-highlight.rs | |
| parent | a5a033d029eb49ceeea82ec9c9b6245b01b6bfb6 (diff) | |
| parent | 2cd3ea1f9d756f9029e969ed1758492e7620ab99 (diff) | |
| download | rust-cf9cffa114ce5a780aa8283096bf85c51be7a4f5.tar.gz rust-cf9cffa114ce5a780aa8283096bf85c51be7a4f5.zip | |
Fixes for `missing_asserts_for_indexing` (#14108)
This PR fixes issues with the `missing_asserts_for_indexing` lint.
- false positive when the first index is the highest(or equal) value in
a list of indexes:
```rust
pub fn foo(slice: &[i32]) -> i32{
slice[1] * slice[0]
}
```
- false negative when an assert statement if found after the indexing
operation.
```rust
pub fn bar(slice: &[i32]) -> i32 {
let product = slice[0] * slice[1];
assert!(slice.len() > 1);
product
}
```
examples: https://godbolt.org/z/s7Y47vKdE
closes: #14079
changelog: [`missing_asserts_for_indexing`]: ignore asserts found after
indexing, and do not require asserts if the first index is highest.
Diffstat (limited to 'tests/rustdoc/source-code-pages/source-code-highlight.rs')
0 files changed, 0 insertions, 0 deletions
