Skip to content
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

Don't call assume_init on Deferred's Data #779

Merged
merged 1 commit into from
Feb 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crossbeam-epoch/src/deferred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type Data = [usize; DATA_WORDS];
/// This is a handy way of keeping an unsized `FnOnce()` within a sized structure.
pub(crate) struct Deferred {
call: unsafe fn(*mut u8),
data: Data,
data: MaybeUninit<Data>,
_marker: PhantomData<*mut ()>, // !Send + !Sync
}

Expand Down Expand Up @@ -46,7 +46,7 @@ impl Deferred {

Deferred {
call: call::<F>,
data: data.assume_init(),
data,
_marker: PhantomData,
}
} else {
Expand All @@ -64,7 +64,7 @@ impl Deferred {

Deferred {
call: call::<F>,
data: data.assume_init(),
data,
_marker: PhantomData,
}
}
Expand All @@ -75,7 +75,7 @@ impl Deferred {
#[inline]
pub(crate) fn call(mut self) {
let call = self.call;
unsafe { call(&mut self.data as *mut Data as *mut u8) };
unsafe { call(self.data.as_mut_ptr() as *mut u8) };
}
}

Expand Down