Skip to content

Commit f719a35

Browse files
committed
Remove generated requires clauses from safe functions
These have SAFETY comments explaining why their `unsafe` sections are indeed safe, but the overall function should be safe for all inputs.
1 parent 4683426 commit f719a35

File tree

1 file changed

+0
-14
lines changed

1 file changed

+0
-14
lines changed

library/alloc/src/boxed/thin.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ impl<T: ?Sized> ThinBox<T> {
190190
}
191191

192192
fn with_header(&self) -> &WithHeader<<T as Pointee>::Metadata> {
193-
#[requires(self.ptr.0.is_aligned())]
194193
// SAFETY: both types are transparent to `NonNull<u8>`
195194
unsafe { &*(core::ptr::addr_of!(self.ptr) as *const WithHeader<_>) }
196195
}
@@ -411,7 +410,6 @@ impl<H> WithHeader<H> {
411410
}
412411

413412
fn header(&self) -> *mut H {
414-
#[requires(self.0.as_ptr().is_aligned())]
415413
// Safety:
416414
// - At least `size_of::<H>()` bytes are allocated ahead of the pointer.
417415
// - We know that H will be aligned because the middle pointer is aligned to the greater
@@ -449,21 +447,9 @@ impl<T: ?Sized + Error> Error for ThinBox<T> {
449447
mod verify {
450448
use super::*;
451449

452-
// fn with_header(&self) -> &WithHeader<<T as Pointee>::Metadata>
453-
#[kani::proof_for_contract(impl<T::with_header)]
454-
pub fn check_with_header() {
455-
let _ = with_header(kani::any());
456-
}
457-
458450
// fn drop(&mut self)
459451
#[kani::proof_for_contract(impl<T::drop)]
460452
pub fn check_drop() {
461453
let _ = drop(kani::any());
462454
}
463-
464-
// fn header(&self) -> *mut H
465-
#[kani::proof_for_contract(::header)]
466-
pub fn check_header() {
467-
let _ = header(kani::any());
468-
}
469455
}

0 commit comments

Comments
 (0)