Skip to content

Commit b1bad7a

Browse files
committed
Global::alloc_impl isn't unsafe, so we should only have post-conditions
1 parent cb4b650 commit b1bad7a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/alloc/src/alloc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use core::hint;
1010
#[cfg(not(test))]
1111
use core::ptr::{self, NonNull};
1212

13-
use safety::requires;
13+
use safety::{ensures,requires};
1414
#[cfg(kani)]
1515
#[unstable(feature="kani", issue="none")]
1616
use core::kani;
@@ -177,8 +177,8 @@ pub unsafe fn alloc_zeroed(layout: Layout) -> *mut u8 {
177177

178178
#[cfg(not(test))]
179179
impl Global {
180-
#[requires(layout.size() == 0 || layout.align() != 0)]
181180
#[inline]
181+
#[ensures(|ret| layout.size() != 0 || ret.is_ok())]
182182
fn alloc_impl(&self, layout: Layout, zeroed: bool) -> Result<NonNull<[u8]>, AllocError> {
183183
match layout.size() {
184184
0 => Ok(NonNull::slice_from_raw_parts(layout.dangling(), 0)),

0 commit comments

Comments
 (0)