Commit 922c7b5
authored
memchr: let compiler know that indexes returned by memchr fns are in bounds
For example, in code like:
```
let len = memchr::memchr(b'\0', slice).unwrap_or(slice.len());
&slice[..len]
```
Without this change, there is a potential panic at `&slice[..len]`, but
with this change, rustc knows the len must be valid, and no longer adds
the potential panic.
Closes #195, Closes #196, PR #2281 parent e21e9fb commit 922c7b5
1 file changed
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1132 | 1132 | | |
1133 | 1133 | | |
1134 | 1134 | | |
1135 | | - | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
1136 | 1142 | | |
1137 | 1143 | | |
1138 | 1144 | | |
| |||
0 commit comments