Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c2040dc
tests: check that enums cannot derive `Zeroable`
BennoLossin Oct 11, 2025
aaad64c
tests: ensure the guards cannot be accessed
BennoLossin Oct 20, 2025
4a14fbe
tests: ensure that the data cannot be accessed
BennoLossin Oct 20, 2025
40a9926
tests: add new test case to underscore
BennoLossin Oct 22, 2025
ed0a922
remove `try_` versions of the initializer macros
BennoLossin Oct 20, 2025
ddec0a4
allow the crate to refer to itself as `pin-init` in doc tests
BennoLossin Oct 20, 2025
39f1ff4
internal: add `syn` dependency
BennoLossin Oct 11, 2025
5e5c1ca
internal: remove `proc-macro[2]` and `quote` workarounds
BennoLossin Oct 11, 2025
13430f4
rewrite `derive(Zeroable)` and `derive(MaybeZeroable)` using `syn`
BennoLossin Oct 11, 2025
ead76f5
rewrite the `#[pinned_drop]` attribute macro using `syn`
BennoLossin Oct 11, 2025
1193508
rewrite `#[pin_data]` using `syn`
BennoLossin Oct 12, 2025
1239839
add `?Sized` bounds to traits in `#[pin_data]` macro
BennoLossin Oct 16, 2025
bef8eeb
rewrite the initializer macros using `syn`
BennoLossin Oct 17, 2025
e054b31
add `#[default_error(<type>)]` attribute to initializer macros
BennoLossin Oct 22, 2025
b519714
internal: init: add support for attributes on initializer fields
BennoLossin Dec 23, 2025
2258c42
tests: add test to check cfgs working correctly
BennoLossin Dec 23, 2025
89b7bfb
internal: init: add escape hatch for referencing initialized fields
BennoLossin Dec 23, 2025
e739150
tests: ensure that `#[disable_initialized_field_access]` does not emi…
BennoLossin Dec 23, 2025
ac6461d
tests: track the diagnostics of packed structs and field accessors
BennoLossin Dec 23, 2025
613077a
tests: update prettyplease to support modern expressions
BennoLossin Dec 23, 2025
c8f8dd0
tests: track no_field_access expansion
BennoLossin Dec 23, 2025
46d3f0b
add support for tuple structs
BennoLossin Dec 29, 2025
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
code at that point.
- Make the `[try_][pin_]init!` macros expose initialized fields via a `let`
binding as `&mut T` or `Pin<&mut T>` for later fields.
- `derive([Maybe]Zeroable)` now support tuple structs

## [0.0.10] - 2025-08-19

Expand Down
13 changes: 7 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ libc = "0.2"
trybuild = { version = "1.0", features = ["diff"] }
macrotest = "1.0"
# needed for macrotest, have to enable verbatim feature to be able to format `&raw` expressions.
prettyplease = { version = "0.2", features = ["verbatim"] }
prettyplease = { version = "0.2.37", features = ["verbatim"] }

[lints.rust]
non_ascii_idents = "deny"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ struct DriverData {

impl DriverData {
fn new() -> impl PinInit<Self, Error> {
try_pin_init!(Self {
pin_init!(Self {
status <- CMutex::new(0),
buffer: Box::init(pin_init::init_zeroed())?,
}? Error)
Expand Down
19 changes: 9 additions & 10 deletions examples/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use core::{
cell::Cell,
convert::Infallible,
marker::PhantomPinned,
pin::Pin,
ptr::{self, NonNull},
Expand All @@ -31,31 +30,31 @@ pub struct ListHead {

impl ListHead {
#[inline]
pub fn new() -> impl PinInit<Self, Infallible> {
try_pin_init!(&this in Self {
pub fn new() -> impl PinInit<Self> {
pin_init!(&this in Self {
next: unsafe { Link::new_unchecked(this) },
prev: unsafe { Link::new_unchecked(this) },
pin: PhantomPinned,
}? Infallible)
})
}

#[inline]
#[allow(dead_code)]
pub fn insert_next(list: &ListHead) -> impl PinInit<Self, Infallible> + '_ {
try_pin_init!(&this in Self {
pub fn insert_next(list: &ListHead) -> impl PinInit<Self> + '_ {
pin_init!(&this in Self {
prev: list.next.prev().replace(unsafe { Link::new_unchecked(this)}),
next: list.next.replace(unsafe { Link::new_unchecked(this)}),
pin: PhantomPinned,
}? Infallible)
})
}

#[inline]
pub fn insert_prev(list: &ListHead) -> impl PinInit<Self, Infallible> + '_ {
try_pin_init!(&this in Self {
pub fn insert_prev(list: &ListHead) -> impl PinInit<Self> + '_ {
pin_init!(&this in Self {
next: list.prev.next().replace(unsafe { Link::new_unchecked(this)}),
prev: list.prev.replace(unsafe { Link::new_unchecked(this)}),
pin: PhantomPinned,
}? Infallible)
})
}

#[inline]
Expand Down
10 changes: 5 additions & 5 deletions examples/pthread_mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ mod pthread_mtx {
// SAFETY: mutex has been initialized
unsafe { pin_init_from_closure(init) }
}
try_pin_init!(Self {
data: UnsafeCell::new(data),
raw <- init_raw(),
pin: PhantomPinned,
}? Error)
pin_init!(Self {
data: UnsafeCell::new(data),
raw <- init_raw(),
pin: PhantomPinned,
}? Error)
}

#[allow(dead_code)]
Expand Down
16 changes: 14 additions & 2 deletions internal/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ proc-macro = true
[dependencies]
quote = "1.0"
proc-macro2 = "1.0"
syn = { version = "2.0.86", features = ["full", "parsing", "visit-mut", "printing"] }

[build-dependencies]
rustc_version = "0.4"
Expand Down
152 changes: 0 additions & 152 deletions internal/src/helpers.rs

This file was deleted.

Loading
Loading