Skip to content

Commit

Permalink
layout.is_safe() in contract
Browse files Browse the repository at this point in the history
  • Loading branch information
carolynzech committed Sep 19, 2024
1 parent 51a0cbc commit 7b21c06
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/core/src/alloc/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// collections, resulting in having to optimize down excess IR multiple times.
// Your performance intuition is useless. Run perf.

use safety::{invariant, requires};
use safety::{ensures, invariant, requires};
use crate::error::Error;
use crate::ptr::{Alignment, NonNull};
use crate::{assert_unsafe_precondition, cmp, fmt, mem};
Expand Down Expand Up @@ -132,6 +132,7 @@ impl Layout {
#[inline]
#[rustc_allow_const_fn_unstable(ptr_alignment_type)]
#[requires(Layout::from_size_align(size, align).is_ok())]
#[ensures(|layout| layout.is_safe())]
pub const unsafe fn from_size_align_unchecked(size: usize, align: usize) -> Self {
assert_unsafe_precondition!(
check_library_ub,
Expand Down Expand Up @@ -533,7 +534,6 @@ mod verify {
let layout = Layout::from_size_align_unchecked(s, a);
assert_eq!(layout.size(), s);
assert_eq!(layout.align(), a);
assert!(layout.is_safe());
}
}
}

0 comments on commit 7b21c06

Please sign in to comment.