Skip to content

Commit d30ec58

Browse files
comment
1 parent dd5c870 commit d30ec58

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

library/core/src/ptr/non_null.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1916,8 +1916,10 @@ mod verify {
19161916
let upper = kani::any_where(|x| *x < ARR_SIZE && *x >= lower);
19171917
unsafe {
19181918
// NOTE: The `index` parameter cannot be used in the function contracts without being moved.
1919-
// Since `SliceIndex` does not guarantee that `index` implements `Clone` or `Copy`. To ensure 'index' is only used once,
1920-
// we put the in-bound check in proof harness as a workaround
1919+
// Since the `SliceIndex` trait does not guarantee that `index` implements `Clone` or `Copy`,
1920+
// it cannot be reused after being consumed in the precondition. To comply with Rust's ownership
1921+
// rules and ensure `index` is only used once, the in-bounds check is moved to the proof harness
1922+
// as a workaround.
19211923
kani::assume(ptr.as_ref().get(lower..upper).is_some());
19221924
let _ = ptr.get_unchecked_mut(lower..upper);
19231925
}

0 commit comments

Comments
 (0)