Skip to content

Commit

Permalink
Avoid multiplication
Browse files Browse the repository at this point in the history
  • Loading branch information
tautschnig committed Aug 9, 2024
1 parent 0b62529 commit e331419
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion library/core/src/alloc/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,10 @@ impl Layout {
#[inline]
#[ensures(|result| result.is_err() || n == 0 || result.as_ref().unwrap().1 % n == 0)]
#[ensures(|result| result.is_err() || n == 0 || result.as_ref().unwrap().0.size() >= self.size())]
#[ensures(|result| result.is_err() || result.as_ref().unwrap().0.size() == n * result.as_ref().unwrap().1)]
// the below multiplication might be too costly to prove at this time
// #[ensures(|result| result.is_err() || result.as_ref().unwrap().0.size() == n * result.as_ref().unwrap().1)]
// use the weaker statement below for now
#[ensures(|result| result.is_err() || n == 0 || result.as_ref().unwrap().0.size() >= result.as_ref().unwrap().1)]
pub fn repeat(&self, n: usize) -> Result<(Self, usize), LayoutError> {
// This cannot overflow. Quoting from the invariant of Layout:
// > `size`, when rounded up to the nearest multiple of `align`,
Expand Down

0 comments on commit e331419

Please sign in to comment.