Skip to content

Commit e991fb0

Browse files
some fixes
1 parent 2d6cc2d commit e991fb0

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

library/core/src/ptr/const_ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2503,7 +2503,7 @@ mod verify {
25032503
let ptr: *const [$type] = slice;
25042504

25052505
//byte_add and byte_sub need count to be usize unlike byte_offset
2506-
let count: usize = kani::any_where(|&x| x < slice.len());
2506+
let count: usize = kani::any_where(|&x| x <= slice.len());
25072507

25082508
unsafe {
25092509
ptr.$fn_name(count);

library/core/src/ptr/mut_ptr.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,9 @@ impl<T: ?Sized> *mut T {
436436
// Postcondition: If `T` is a unit type (`size_of::<T>() == 0`), no allocation check is needed.
437437
// Otherwise, for non-unit types, ensure that `self` and `result` point to the same allocated object,
438438
// verifying that the result remains within the same allocation as `self`.
439-
#[ensures(|result| (core::mem::size_of::<T>() == 0) || core::ub_checks::same_allocation(self as *const T, *result as *const T))]
439+
#[ensures(|result|
440+
(core::mem::size_of::<T>() == 0) || core::ub_checks::same_allocation(self as *const T, *result as *const T)
441+
)]
440442
pub const unsafe fn offset(self, count: isize) -> *mut T
441443
where
442444
T: Sized,
@@ -2854,7 +2856,7 @@ mod verify {
28542856
let ptr: *mut [$type] = slice;
28552857

28562858
//byte_add and byte_sub need count to be usize unlike byte_offset
2857-
let count: usize = kani::any();
2859+
let count: usize = kani::any_where(|&x| x <= slice.len());
28582860

28592861
unsafe {
28602862
ptr.$fn_name(count);
@@ -2948,7 +2950,7 @@ mod verify {
29482950
let test_ptr: *mut dyn TestTrait = trait_object;
29492951

29502952
//byte_add and byte_sub need count to be usize unlike byte_offset
2951-
let count: usize = kani::any();
2953+
let count: usize = kani::any_where(|&x| x <= core::mem::size_of_val(&test_struct));
29522954

29532955
unsafe {
29542956
test_ptr.$fn_name(count);

0 commit comments

Comments
 (0)