Skip to content

Commit 7d4ed19

Browse files
committed
Use autoharness for several Alignment functions
1 parent c78c6c7 commit 7d4ed19

File tree

2 files changed

+6
-46
lines changed

2 files changed

+6
-46
lines changed

.github/workflows/kani.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ jobs:
8080
run: |
8181
scripts/run-kani.sh --run autoharness --kani-args \
8282
--include-pattern ptr::align_offset::mod_inv \
83+
--include-pattern ptr::alignment::Alignment::as_nonzero \
84+
--include-pattern ptr::alignment::Alignment::as_usize \
85+
--include-pattern ptr::alignment::Alignment::log2 \
86+
--include-pattern ptr::alignment::Alignment::mask \
87+
--include-pattern ptr::alignment::Alignment::new \
88+
--include-pattern ptr::alignment::Alignment::new_unchecked \
8389
--include-pattern time::Duration::from_micros \
8490
--include-pattern time::Duration::from_millis \
8591
--include-pattern time::Duration::from_nanos \

library/core/src/ptr/alignment.rs

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -410,50 +410,4 @@ mod verify {
410410
// pub fn check_of_i32() {
411411
// let _ = Alignment::of::<i32>();
412412
// }
413-
414-
// pub const fn new(align: usize) -> Option<Self>
415-
#[kani::proof_for_contract(Alignment::new)]
416-
pub fn check_new() {
417-
let a = kani::any::<usize>();
418-
let _ = Alignment::new(a);
419-
}
420-
421-
// pub const unsafe fn new_unchecked(align: usize) -> Self
422-
#[kani::proof_for_contract(Alignment::new_unchecked)]
423-
pub fn check_new_unchecked() {
424-
let a = kani::any::<usize>();
425-
unsafe {
426-
let _ = Alignment::new_unchecked(a);
427-
}
428-
}
429-
430-
// pub const fn as_usize(self) -> usize
431-
#[kani::proof_for_contract(Alignment::as_usize)]
432-
pub fn check_as_usize() {
433-
let a = kani::any::<usize>();
434-
if let Some(alignment) = Alignment::new(a) {
435-
assert_eq!(alignment.as_usize(), a);
436-
}
437-
}
438-
439-
// pub const fn as_nonzero(self) -> NonZero<usize>
440-
#[kani::proof_for_contract(Alignment::as_nonzero)]
441-
pub fn check_as_nonzero() {
442-
let alignment = kani::any::<Alignment>();
443-
let _ = alignment.as_nonzero();
444-
}
445-
446-
// pub const fn log2(self) -> u32
447-
#[kani::proof_for_contract(Alignment::log2)]
448-
pub fn check_log2() {
449-
let alignment = kani::any::<Alignment>();
450-
let _ = alignment.log2();
451-
}
452-
453-
// pub const fn mask(self) -> usize
454-
#[kani::proof_for_contract(Alignment::mask)]
455-
pub fn check_mask() {
456-
let alignment = kani::any::<Alignment>();
457-
let _ = alignment.mask();
458-
}
459413
}

0 commit comments

Comments
 (0)