Skip to content

Commit a8f50f7

Browse files
change loop invariant
1 parent 3fdf8cd commit a8f50f7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

library/core/src/str/pattern.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,11 +1958,11 @@ unsafe fn small_slice_eq(x: &[u8], y: &[u8]) -> bool {
19581958
unsafe {
19591959
let (mut px, mut py) = (x.as_ptr(), y.as_ptr());
19601960
let (pxend, pyend) = (px.add(x.len() - 4), py.add(y.len() - 4));
1961-
#[loop_invariant(crate::ub_checks::same_allocation(x.as_ptr(), px)
1962-
&& crate::ub_checks::same_allocation(y.as_ptr(), py)
1963-
&& px.addr() >= x.as_ptr().addr()
1964-
&& py.addr() >= y.as_ptr().addr()
1965-
&& px.addr() - x.as_ptr().addr() == py.addr() - y.as_ptr().addr())]
1961+
#[loop_invariant(crate::ub_checks::same_allocation(on_entry(px), px)
1962+
&& crate::ub_checks::same_allocation(on_entry(py), py)
1963+
&& px.addr() >= on_entry(px).addr()
1964+
&& py.addr() >= on_entry(py).addr()
1965+
&& px.addr() - on_entry(px).addr() == py.addr() - on_entry(py).addr())]
19661966
while px < pxend {
19671967
let vx = (px as *const u32).read_unaligned();
19681968
let vy = (py as *const u32).read_unaligned();

0 commit comments

Comments
 (0)