Skip to content

Commit f43c022

Browse files
committed
Instruct LLVM that binary_search_by returns a valid index
1 parent 51748a8 commit f43c022

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

library/core/src/slice/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2204,6 +2204,8 @@ impl<T> [T] {
22042204
} else if cmp == Greater {
22052205
right = mid;
22062206
} else {
2207+
// SAFETY: same as the `get_unchecked` above
2208+
unsafe { crate::intrinsics::assume(mid < self.len()) };
22072209
return Ok(mid);
22082210
}
22092211

0 commit comments

Comments
 (0)