Skip to content

Commit

Permalink
Fix contract (incomplete)
Browse files Browse the repository at this point in the history
  • Loading branch information
tautschnig committed Oct 17, 2024
1 parent 4be20fa commit e880520
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion library/alloc/src/boxed/thin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use safety::requires;
#[cfg(kani)]
#[unstable(feature="kani", issue="none")]
use core::kani;
use core::ub_checks;

use core::error::Error;
use core::fmt::{self, Debug, Display, Formatter};
Expand Down Expand Up @@ -366,9 +367,10 @@ impl<H> WithHeader<H> {
}

// Safety:
#[requires(value.is_null() || value.is_aligned())]
// - Assumes that either `value` can be dereferenced, or is the
// `NonNull::dangling()` we use when both `T` and `H` are ZSTs.
#[requires((mem::size_of_val_raw(value) == 0 && size_of::<H>() == 0) ||
ub_checks::can_dereference(value))]
unsafe fn drop<T: ?Sized>(&self, value: *mut T) {
struct DropGuard<H> {
ptr: NonNull<u8>,
Expand Down
1 change: 1 addition & 0 deletions library/alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
// Library features:
// tidy-alphabetical-start
#![cfg_attr(kani, feature(kani))]
#![cfg_attr(kani, feature(ub_checks))]
#![cfg_attr(not(no_global_oom_handling), feature(const_alloc_error))]
#![cfg_attr(not(no_global_oom_handling), feature(const_btree_len))]
#![feature(alloc_layout_extra)]
Expand Down

0 comments on commit e880520

Please sign in to comment.