1212macro_rules! kani_mem {
1313 ( $core: tt) => {
1414 use super :: kani_intrinsic;
15+ use $core:: marker:: MetaSized ;
1516 use $core:: ptr:: { DynMetadata , NonNull , Pointee } ;
1617
1718 /// Check if the pointer is valid for write access according to [crate::mem] conditions 1, 2
@@ -31,7 +32,7 @@ macro_rules! kani_mem {
3132 issue = 2690 ,
3233 reason = "experimental memory predicate API"
3334 ) ]
34- pub fn can_write<T : ? Sized >( ptr: * mut T ) -> bool {
35+ pub fn can_write<T : MetaSized >( ptr: * mut T ) -> bool {
3536 is_ptr_aligned( ptr) && is_inbounds( ptr)
3637 }
3738
@@ -49,7 +50,7 @@ macro_rules! kani_mem {
4950 issue = 2690 ,
5051 reason = "experimental memory predicate API"
5152 ) ]
52- pub fn can_write_unaligned<T : ? Sized >( ptr: * const T ) -> bool {
53+ pub fn can_write_unaligned<T : MetaSized >( ptr: * const T ) -> bool {
5354 let ( thin_ptr, metadata) = ptr. to_raw_parts( ) ;
5455 is_inbounds( ptr)
5556 }
@@ -72,7 +73,7 @@ macro_rules! kani_mem {
7273 reason = "experimental memory predicate API"
7374 ) ]
7475 #[ allow( clippy:: not_unsafe_ptr_arg_deref) ]
75- pub fn can_dereference<T : ? Sized >( ptr: * const T ) -> bool {
76+ pub fn can_dereference<T : MetaSized >( ptr: * const T ) -> bool {
7677 // Need to assert `is_initialized` because non-determinism is used under the hood, so it
7778 // does not make sense to use it inside assumption context.
7879 is_ptr_aligned( ptr)
@@ -99,7 +100,7 @@ macro_rules! kani_mem {
99100 reason = "experimental memory predicate API"
100101 ) ]
101102 #[ allow( clippy:: not_unsafe_ptr_arg_deref) ]
102- pub fn can_read_unaligned<T : ? Sized >( ptr: * const T ) -> bool {
103+ pub fn can_read_unaligned<T : MetaSized >( ptr: * const T ) -> bool {
103104 let ( thin_ptr, metadata) = ptr. to_raw_parts( ) ;
104105 // Need to assert `is_initialized` because non-determinism is used under the hood, so it
105106 // does not make sense to use it inside assumption context.
@@ -116,12 +117,15 @@ macro_rules! kani_mem {
116117 reason = "experimental memory predicate API"
117118 ) ]
118119 #[ allow( clippy:: not_unsafe_ptr_arg_deref) ]
119- pub fn same_allocation<T : ? Sized >( ptr1: * const T , ptr2: * const T ) -> bool {
120+ pub fn same_allocation<T : MetaSized >( ptr1: * const T , ptr2: * const T ) -> bool {
120121 same_allocation_internal( ptr1, ptr2)
121122 }
122123
123124 #[ allow( clippy:: not_unsafe_ptr_arg_deref) ]
124- pub ( super ) fn same_allocation_internal<T : ?Sized >( ptr1: * const T , ptr2: * const T ) -> bool {
125+ pub ( super ) fn same_allocation_internal<T : MetaSized >(
126+ ptr1: * const T ,
127+ ptr2: * const T ,
128+ ) -> bool {
125129 let addr1 = ptr1 as * const ( ) ;
126130 let addr2 = ptr2 as * const ( ) ;
127131 cbmc:: same_allocation( addr1, addr2)
@@ -135,7 +139,7 @@ macro_rules! kani_mem {
135139 /// - The computed size exceeds `isize::MAX` (the maximum safe Rust allocation size).
136140 /// TODO: Optimize this if T is sized.
137141 #[ kanitool:: fn_marker = "CheckedSizeOfIntrinsic" ]
138- pub fn checked_size_of_raw<T : ? Sized >( ptr: * const T ) -> Option <usize > {
142+ pub fn checked_size_of_raw<T : MetaSized >( ptr: * const T ) -> Option <usize > {
139143 #[ cfg( not( feature = "concrete_playback" ) ) ]
140144 return kani_intrinsic( ) ;
141145
@@ -153,7 +157,7 @@ macro_rules! kani_mem {
153157 /// Return `None` if alignment information cannot be retrieved (foreign types), or if value
154158 /// is not power-of-two.
155159 #[ kanitool:: fn_marker = "CheckedAlignOfIntrinsic" ]
156- pub fn checked_align_of_raw<T : ? Sized >( ptr: * const T ) -> Option <usize > {
160+ pub fn checked_align_of_raw<T : MetaSized >( ptr: * const T ) -> Option <usize > {
157161 #[ cfg( not( feature = "concrete_playback" ) ) ]
158162 return kani_intrinsic( ) ;
159163
@@ -180,7 +184,7 @@ macro_rules! kani_mem {
180184 issue = 3946 ,
181185 reason = "experimental memory predicate API"
182186 ) ]
183- pub fn is_inbounds<T : ? Sized >( ptr: * const T ) -> bool {
187+ pub fn is_inbounds<T : MetaSized >( ptr: * const T ) -> bool {
184188 // If size overflows, then pointer cannot be inbounds.
185189 let Some ( sz) = checked_size_of_raw( ptr) else { return false } ;
186190 if sz == 0 {
@@ -203,7 +207,7 @@ macro_rules! kani_mem {
203207
204208 // Return whether the pointer is aligned
205209 #[ allow( clippy:: manual_is_power_of_two) ]
206- fn is_ptr_aligned<T : ? Sized >( ptr: * const T ) -> bool {
210+ fn is_ptr_aligned<T : MetaSized >( ptr: * const T ) -> bool {
207211 // Cannot be aligned if pointer alignment cannot be computed.
208212 let Some ( align) = checked_align_of_raw( ptr) else { return false } ;
209213 if align > 0 && ( align & ( align - 1 ) ) == 0 {
@@ -237,19 +241,19 @@ macro_rules! kani_mem {
237241 /// - Users have to ensure that the pointed to memory is allocated.
238242 #[ kanitool:: fn_marker = "ValidValueIntrinsic" ]
239243 #[ inline( never) ]
240- unsafe fn has_valid_value<T : ? Sized >( _ptr: * const T ) -> bool {
244+ unsafe fn has_valid_value<T : MetaSized >( _ptr: * const T ) -> bool {
241245 kani_intrinsic( )
242246 }
243247
244248 /// Check whether `len * size_of::<T>()` bytes are initialized starting from `ptr`.
245249 #[ kanitool:: fn_marker = "IsInitializedIntrinsic" ]
246250 #[ inline( never) ]
247- pub ( crate ) fn is_initialized<T : ? Sized >( _ptr: * const T ) -> bool {
251+ pub ( crate ) fn is_initialized<T : MetaSized >( _ptr: * const T ) -> bool {
248252 kani_intrinsic( )
249253 }
250254
251255 /// A helper to assert `is_initialized` to use it as a part of other predicates.
252- fn assert_is_initialized<T : ? Sized >( ptr: * const T ) -> bool {
256+ fn assert_is_initialized<T : MetaSized >( ptr: * const T ) -> bool {
253257 super :: internal:: check(
254258 is_initialized( ptr) ,
255259 "Undefined Behavior: Reading from an uninitialized pointer" ,
@@ -277,7 +281,7 @@ macro_rules! kani_mem {
277281 #[ doc( hidden) ]
278282 #[ kanitool:: fn_marker = "PointerObjectHook" ]
279283 #[ inline( never) ]
280- pub ( crate ) fn pointer_object<T : ? Sized >( _ptr: * const T ) -> usize {
284+ pub ( crate ) fn pointer_object<T : MetaSized >( _ptr: * const T ) -> usize {
281285 kani_intrinsic( )
282286 }
283287
@@ -290,7 +294,7 @@ macro_rules! kani_mem {
290294 ) ]
291295 #[ kanitool:: fn_marker = "PointerOffsetHook" ]
292296 #[ inline( never) ]
293- pub fn pointer_offset<T : ? Sized >( _ptr: * const T ) -> usize {
297+ pub fn pointer_offset<T : MetaSized >( _ptr: * const T ) -> usize {
294298 kani_intrinsic( )
295299 }
296300 } ;
0 commit comments