Skip to content

Commit 6adfc70

Browse files
hoshinolinajannau
authored andcommitted
rust: pin-init: Support type paths in pin_init!() and friends
This makes directly initializing structures with a type name that isn't in the current scope work properly. Signed-off-by: Asahi Lina <lina@asahilina.net> Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 0cb1a8e commit 6adfc70

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

rust/pin-init/src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -780,10 +780,10 @@ macro_rules! stack_try_pin_init {
780780
// module `macros` inside of `macros.rs`.
781781
#[macro_export]
782782
macro_rules! pin_init {
783-
($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? {
783+
($(&$this:ident in)? $t:ident $(::$p:ident)* $(::<$($generics:ty),* $(,)?>)? {
784784
$($fields:tt)*
785785
}) => {
786-
$crate::try_pin_init!($(&$this in)? $t $(::<$($generics),*>)? {
786+
$crate::try_pin_init!($(&$this in)? $t $(::$p)* $(::<$($generics),*>)? {
787787
$($fields)*
788788
}? ::core::convert::Infallible)
789789
};
@@ -831,12 +831,12 @@ macro_rules! pin_init {
831831
// module `macros` inside of `macros.rs`.
832832
#[macro_export]
833833
macro_rules! try_pin_init {
834-
($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? {
834+
($(&$this:ident in)? $t:ident $(::$p:ident)* $(::<$($generics:ty),* $(,)?>)? {
835835
$($fields:tt)*
836836
}? $err:ty) => {
837837
$crate::__init_internal!(
838838
@this($($this)?),
839-
@typ($t $(::<$($generics),*>)? ),
839+
@typ($t $(::$p)* $(::<$($generics),*>)? ),
840840
@fields($($fields)*),
841841
@error($err),
842842
@data(PinData, use_data),
@@ -887,10 +887,10 @@ macro_rules! try_pin_init {
887887
// module `macros` inside of `macros.rs`.
888888
#[macro_export]
889889
macro_rules! init {
890-
($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? {
890+
($(&$this:ident in)? $t:ident $(::$p:ident)* $(::<$($generics:ty),* $(,)?>)? {
891891
$($fields:tt)*
892892
}) => {
893-
$crate::try_init!($(&$this in)? $t $(::<$($generics),*>)? {
893+
$crate::try_init!($(&$this in)? $t $(::$p)* $(::<$($generics),*>)? {
894894
$($fields)*
895895
}? ::core::convert::Infallible)
896896
}
@@ -936,12 +936,12 @@ macro_rules! init {
936936
// module `macros` inside of `macros.rs`.
937937
#[macro_export]
938938
macro_rules! try_init {
939-
($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? {
939+
($(&$this:ident in)? $t:ident $(::$p:ident)* $(::<$($generics:ty),* $(,)?>)? {
940940
$($fields:tt)*
941941
}? $err:ty) => {
942942
$crate::__init_internal!(
943943
@this($($this)?),
944-
@typ($t $(::<$($generics),*>)?),
944+
@typ($t $(::$p)* $(::<$($generics),*>)?),
945945
@fields($($fields)*),
946946
@error($err),
947947
@data(InitData, /*no use_data*/),

0 commit comments

Comments
 (0)