Skip to content

Commit 036b504

Browse files
committed
small fixes
1 parent e330f83 commit 036b504

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

library/core/src/intrinsics.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -3756,11 +3756,10 @@ pub(crate) const fn miri_promise_symbolic_alignment(ptr: *const (), align: usize
37563756
const_eval_select((ptr, align), compiletime, runtime);
37573757
}
37583758

3759-
use crate::any;
37603759
#[requires(crate::mem::size_of::<T>() >= crate::mem::size_of::<U>())] //U cannot be larger than T
37613760
#[ensures(|ret: &U| (ret as *const U as usize) % crate::mem::align_of::<U>() == 0)] //check that the output has expected alignment
37623761
pub unsafe fn transmute_unchecked_wrapper<T,U>(input: T) -> U {
3763-
transmute_unchecked(input)
3762+
unsafe { transmute_unchecked(input) }
37643763
}
37653764

37663765
//This requires means [output is char implies input is valid unicode value]
@@ -3770,7 +3769,7 @@ pub unsafe fn transmute_unchecked_from_u32<T,U>(input: T) -> U
37703769
where
37713770
T: crate::ops::BitAnd<Output = T> + PartialEq + From<u32> + Copy + PartialOrd,
37723771
{
3773-
transmute_unchecked(input)
3772+
unsafe { transmute_unchecked(input) }
37743773
}
37753774

37763775
//This requires means [output is bool implies input is 0 or 1]
@@ -3780,7 +3779,7 @@ pub unsafe fn transmute_unchecked_from_u8<T,U>(input: T) -> U
37803779
where
37813780
T: crate::ops::BitAnd<Output = T> + PartialEq + From<u8> + Copy + PartialOrd,
37823781
{
3783-
transmute_unchecked(input)
3782+
unsafe { transmute_unchecked(input) }
37843783
}
37853784

37863785
#[cfg(kani)]
@@ -3842,9 +3841,8 @@ mod verify {
38423841
assert!((c as u32 <= 0xD7FF) || (c as u32 >= 0xE000 && c as u32 <= 0x10FFFF))
38433842
}
38443843

3845-
//Note: this doesn't actually panic, because violating char's
3846-
//type invariants is not something that transmute checks for
38473844
#[kani::proof]
3845+
#[kani::stub_verified(transmute_unchecked_from_u32)]
38483846
#[kani::should_panic]
38493847
fn transmute_invalid_u32_to_char() {
38503848
let num: u32 = kani::any();
@@ -3860,9 +3858,8 @@ mod verify {
38603858
assert!(b == (num == 1));
38613859
}
38623860

3863-
//Note: this doesn't actually panic, because violating bool's
3864-
//type invariants is not something that transmute checks for.
38653861
#[kani::proof]
3862+
#[kani::stub_verified(transmute_unchecked_from_u8)]
38663863
#[kani::should_panic]
38673864
fn transmute_invalid_u8_to_bool() {
38683865
let num: u8 = kani::any();

0 commit comments

Comments
 (0)