Skip to content

Commit c2f12f3

Browse files
committed
feat(core)!: require Zeroable instead of ZeroInit in HunkDefiner::zeroed
1 parent 65bf8cd commit c2f12f3

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

src/r3_core/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- **Breaking:** `HunkDefiner::zeroed` now requires `T: Zeroable` instead of `T: ZeroInit`.
13+
1014
### Added
1115

1216
- `r3_core::utils::{Zeroable,ZeroableInOption}` (re-exported from `bytemuck ^1`)

src/r3_core/src/bind.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ use crate::{
172172
closure::Closure,
173173
hunk::Hunk,
174174
kernel::{self, cfg, prelude::*, raw, raw_cfg, StartupHook},
175-
utils::{refcell::RefCell, ComptimeVec, ConstAllocator, Init, PhantomInvariant, ZeroInit},
175+
utils::{
176+
refcell::RefCell, ComptimeVec, ConstAllocator, Init, PhantomInvariant, ZeroInit, Zeroable,
177+
},
176178
};
177179

178180
mod sorter;
@@ -213,8 +215,10 @@ impl<T> BindData<T> {
213215
}
214216
}
215217

218+
// FIXME: Derive this when <https://github.com/Lokathor/bytemuck/pull/148> is
219+
// merged
216220
// Safety: Zero-initialization is valid for `MaybeUninit`
217-
unsafe impl<T> ZeroInit for BindData<T> {}
221+
unsafe impl<T> Zeroable for BindData<T> {}
218222

219223
// Main configuration interface
220224
// ----------------------------------------------------------------------------

src/r3_core/src/hunk.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use core::{
99

1010
use crate::{
1111
kernel::{self, cfg, hunk, raw, raw_cfg, Cfg, StartupHook},
12-
utils::{Init, ZeroInit},
12+
utils::{Init, Zeroable},
1313
};
1414

1515
/// The priority of the [startup hooks] used to initialize [typed hunks]. It has
@@ -123,9 +123,9 @@ impl<System: raw::KernelBase + cfg::KernelStatic, T: ?Sized, InitTag>
123123
/// Zero-initialize the hunk.
124124
pub const fn zeroed(self) -> HunkDefiner<System, T, ZeroInitTag>
125125
where
126-
T: ZeroInit,
126+
T: Zeroable,
127127
{
128-
// Safety: `T: ZeroInit`, so it's zero-initializable
128+
// Safety: `T: Zeroable`, so it's zero-initializable
129129
unsafe { self.zeroed_unchecked() }
130130
}
131131

0 commit comments

Comments
 (0)