Skip to content

Commit

Permalink
fix: wrong debug assertion for greedy consolidation (fixes #16)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluurryy committed May 1, 2024
1 parent 4b51991 commit f068eeb
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/bump_scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ where
#[inline(always)]
fn set_pos(&self, pos: NonZeroUsize, current_align: usize) {
let chunk = self.chunk.get();
debug_assert_eq!(nonnull::addr(chunk.pos()).get() % current_align, 0);
debug_assert_eq!(pos.get() % current_align, 0);

unsafe { chunk.set_pos_addr(pos.get()) }

Expand Down
1 change: 1 addition & 0 deletions src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ mod bump_vec_doc;
mod mut_bump_vec_rev_doc;
mod panic_safety;
mod pool;
mod unaligned_collection;

#[cfg(feature = "serde")]
mod serde;
Expand Down
43 changes: 43 additions & 0 deletions src/tests/unaligned_collection.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
use super::*;

either_way! {
bump_vec
mut_bump_vec
mut_bump_vec_rev
}

fn bump_vec<const UP: bool>() {
let bump = Bump::<Global, 1, UP>::new();

bump.alloc(8u8);

let mut vec = BumpVec::new_in(&bump);
vec.push(32u32);

let slice = vec.into_slice();
dbg!(slice);
}

fn mut_bump_vec<const UP: bool>() {
let mut bump = Bump::<Global, 1, UP>::new();

bump.alloc(8u8);

let mut vec = MutBumpVec::new_in(&mut bump);
vec.push(32u32);

let slice = vec.into_slice();
dbg!(slice);
}

fn mut_bump_vec_rev<const UP: bool>() {
let mut bump = Bump::<Global, 1, UP>::new();

bump.alloc(8u8);

let mut vec = MutBumpVecRev::new_in(&mut bump);
vec.push(32u32);

let slice = vec.into_slice();
dbg!(slice);
}

0 comments on commit f068eeb

Please sign in to comment.