https://godbolt.org/z/67q79vnEW
This function should be optimized away completely, but it isn't:
pub fn demo(x: usize, y: usize) {
let res = x.saturating_add(y);
assert!(res >= x);
}
Original example was this, which currently has two bounds checks (that the range end is >= than the start, and that the end of the range is in-bounds), but it should only have one:
pub fn subslice(slice: &[u8], x: usize) {
let _ = &slice[x..x.saturating_add(10)];
}
https://godbolt.org/z/67q79vnEW
This function should be optimized away completely, but it isn't:
Original example was this, which currently has two bounds checks (that the range end is >= than the start, and that the end of the range is in-bounds), but it should only have one: