Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ 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.
- Silence warnings for edge cases like the projection being unused or struct members
start with underscore.

## [0.0.10] - 2025-08-19

Expand Down
3 changes: 3 additions & 0 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,7 @@ macro_rules! __pin_data {
) => {
$crate::macros::paste! {
#[doc(hidden)]
#[allow(dead_code)]
$vis struct [< $name Projection >] <'__pin, $($decl_generics)*> {
$($(#[$($p_attr)*])* $pvis $p_field : ::core::pin::Pin<&'__pin mut $p_type>,)*
$($(#[$($attr)*])* $fvis $field : &'__pin mut $type,)*
Expand Down Expand Up @@ -1083,6 +1084,7 @@ macro_rules! __pin_data {
)*
$(
$(#[$($attr)*])*
#[allow(non_snake_case)]
$fvis unsafe fn $field<E>(
self,
slot: *mut $type,
Expand All @@ -1093,6 +1095,7 @@ macro_rules! __pin_data {
}

$(#[$($attr)*])*
#[allow(non_snake_case)]
$fvis unsafe fn [<__project_ $field>]<'__slot>(
self,
slot: &'__slot mut $type,
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/compile-fail/init/wrong_generics2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ help: you might have forgotten to add the struct literal inside the block
--> src/macros.rs
|
~ ::core::ptr::write($slot, $t { SomeStruct {
|2 $($acc)*
|5 $($acc)*
~ } });
|

Expand Down
5 changes: 5 additions & 0 deletions tests/ui/expand/many_generics.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ where
_pin: PhantomPinned,
}
#[doc(hidden)]
#[allow(dead_code)]
struct FooProjection<
'__pin,
'a,
Expand Down Expand Up @@ -97,26 +98,30 @@ const _: () = {
) -> ::core::pin::Pin<&'__slot mut PhantomPinned> {
::core::pin::Pin::new_unchecked(slot)
}
#[allow(non_snake_case)]
unsafe fn array<E>(
self,
slot: *mut [u8; 1024 * 1024],
init: impl ::pin_init::Init<[u8; 1024 * 1024], E>,
) -> ::core::result::Result<(), E> {
unsafe { ::pin_init::Init::__init(init, slot) }
}
#[allow(non_snake_case)]
unsafe fn __project_array<'__slot>(
self,
slot: &'__slot mut [u8; 1024 * 1024],
) -> &'__slot mut [u8; 1024 * 1024] {
slot
}
#[allow(non_snake_case)]
unsafe fn r<E>(
self,
slot: *mut &'b mut [&'a mut T; SIZE],
init: impl ::pin_init::Init<&'b mut [&'a mut T; SIZE], E>,
) -> ::core::result::Result<(), E> {
unsafe { ::pin_init::Init::__init(init, slot) }
}
#[allow(non_snake_case)]
unsafe fn __project_r<'__slot>(
self,
slot: &'__slot mut &'b mut [&'a mut T; SIZE],
Expand Down
3 changes: 3 additions & 0 deletions tests/ui/expand/pin-data.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ struct Foo {
_pin: PhantomPinned,
}
#[doc(hidden)]
#[allow(dead_code)]
struct FooProjection<'__pin> {
_pin: ::core::pin::Pin<&'__pin mut PhantomPinned>,
array: &'__pin mut [u8; 1024 * 1024],
Expand Down Expand Up @@ -56,13 +57,15 @@ const _: () = {
) -> ::core::pin::Pin<&'__slot mut PhantomPinned> {
::core::pin::Pin::new_unchecked(slot)
}
#[allow(non_snake_case)]
unsafe fn array<E>(
self,
slot: *mut [u8; 1024 * 1024],
init: impl ::pin_init::Init<[u8; 1024 * 1024], E>,
) -> ::core::result::Result<(), E> {
unsafe { ::pin_init::Init::__init(init, slot) }
}
#[allow(non_snake_case)]
unsafe fn __project_array<'__slot>(
self,
slot: &'__slot mut [u8; 1024 * 1024],
Expand Down
3 changes: 3 additions & 0 deletions tests/ui/expand/pinned_drop.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ struct Foo {
_pin: PhantomPinned,
}
#[doc(hidden)]
#[allow(dead_code)]
struct FooProjection<'__pin> {
_pin: ::core::pin::Pin<&'__pin mut PhantomPinned>,
array: &'__pin mut [u8; 1024 * 1024],
Expand Down Expand Up @@ -56,13 +57,15 @@ const _: () = {
) -> ::core::pin::Pin<&'__slot mut PhantomPinned> {
::core::pin::Pin::new_unchecked(slot)
}
#[allow(non_snake_case)]
unsafe fn array<E>(
self,
slot: *mut [u8; 1024 * 1024],
init: impl ::pin_init::Init<[u8; 1024 * 1024], E>,
) -> ::core::result::Result<(), E> {
unsafe { ::pin_init::Init::__init(init, slot) }
}
#[allow(non_snake_case)]
unsafe fn __project_array<'__slot>(
self,
slot: &'__slot mut [u8; 1024 * 1024],
Expand Down
Loading