From f43c02236d5c5bcf7c2cad98070ca9164cebfe54 Mon Sep 17 00:00:00 2001 From: Giacomo Stevanato Date: Sun, 24 Jan 2021 21:04:18 +0100 Subject: [PATCH] Instruct LLVM that binary_search_by returns a valid index --- library/core/src/slice/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 5510bb0257e3..0aaccaed4166 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -2204,6 +2204,8 @@ impl [T] { } else if cmp == Greater { right = mid; } else { + // SAFETY: same as the `get_unchecked` above + unsafe { crate::intrinsics::assume(mid < self.len()) }; return Ok(mid); }