-
Notifications
You must be signed in to change notification settings - Fork 146
refactor: remove bump field from ChunkIter
#319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -2149,10 +2149,7 @@ impl<const MIN_ALIGN: usize> Bump<MIN_ALIGN> { | |||||||
| pub fn iter_allocated_chunks(&mut self) -> ChunkIter<'_, MIN_ALIGN> { | ||||||||
| // Safety: Ensured by mutable borrow of `self`. | ||||||||
| let raw = unsafe { self.iter_allocated_chunks_raw() }; | ||||||||
| ChunkIter { | ||||||||
| raw, | ||||||||
| bump: PhantomData, | ||||||||
| } | ||||||||
| ChunkIter { raw } | ||||||||
| } | ||||||||
|
|
||||||||
| /// Returns an iterator over raw pointers to chunks of allocated memory that | ||||||||
|
|
@@ -2388,7 +2385,6 @@ impl<const MIN_ALIGN: usize> Bump<MIN_ALIGN> { | |||||||
| #[derive(Debug)] | ||||||||
| pub struct ChunkIter<'a, const MIN_ALIGN: usize = 1> { | ||||||||
| raw: ChunkRawIter<'a, MIN_ALIGN>, | ||||||||
|
||||||||
| raw: ChunkRawIter<'a, MIN_ALIGN>, | |
| raw: ChunkRawIter<'a, MIN_ALIGN>, | |
| bump: PhantomData<&'a mut Bump<MIN_ALIGN>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The safety comment here (“Ensured by mutable borrow of
self.”) becomes incorrect ifChunkIterno longer carries aPhantomData<&'a mut Bump<MIN_ALIGN>>: the iterator only keeps an immutable borrow, andBumpexposes mutation via&self(e.g.,alloc,try_alloc_layout, etc.). This means allocations can occur while the safe iterator is alive, violating the safety preconditions for producing&'a [MaybeUninit<u8>].