Skip to content

Commit a504db7

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 39a6a12 commit a504db7

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
@@ -778,10 +778,10 @@ macro_rules! stack_try_pin_init {
778778
// module `macros` inside of `macros.rs`.
779779
#[macro_export]
780780
macro_rules! pin_init {
781-
($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? {
781+
($(&$this:ident in)? $t:ident $(::$p:ident)* $(::<$($generics:ty),* $(,)?>)? {
782782
$($fields:tt)*
783783
}) => {
784-
$crate::try_pin_init!($(&$this in)? $t $(::<$($generics),*>)? {
784+
$crate::try_pin_init!($(&$this in)? $t $(::$p)* $(::<$($generics),*>)? {
785785
$($fields)*
786786
}? ::core::convert::Infallible)
787787
};
@@ -829,12 +829,12 @@ macro_rules! pin_init {
829829
// module `macros` inside of `macros.rs`.
830830
#[macro_export]
831831
macro_rules! try_pin_init {
832-
($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? {
832+
($(&$this:ident in)? $t:ident $(::$p:ident)* $(::<$($generics:ty),* $(,)?>)? {
833833
$($fields:tt)*
834834
}? $err:ty) => {
835835
$crate::__init_internal!(
836836
@this($($this)?),
837-
@typ($t $(::<$($generics),*>)? ),
837+
@typ($t $(::$p)* $(::<$($generics),*>)? ),
838838
@fields($($fields)*),
839839
@error($err),
840840
@data(PinData, use_data),
@@ -885,10 +885,10 @@ macro_rules! try_pin_init {
885885
// module `macros` inside of `macros.rs`.
886886
#[macro_export]
887887
macro_rules! init {
888-
($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? {
888+
($(&$this:ident in)? $t:ident $(::$p:ident)* $(::<$($generics:ty),* $(,)?>)? {
889889
$($fields:tt)*
890890
}) => {
891-
$crate::try_init!($(&$this in)? $t $(::<$($generics),*>)? {
891+
$crate::try_init!($(&$this in)? $t $(::$p)* $(::<$($generics),*>)? {
892892
$($fields)*
893893
}? ::core::convert::Infallible)
894894
}
@@ -934,12 +934,12 @@ macro_rules! init {
934934
// module `macros` inside of `macros.rs`.
935935
#[macro_export]
936936
macro_rules! try_init {
937-
($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? {
937+
($(&$this:ident in)? $t:ident $(::$p:ident)* $(::<$($generics:ty),* $(,)?>)? {
938938
$($fields:tt)*
939939
}? $err:ty) => {
940940
$crate::__init_internal!(
941941
@this($($this)?),
942-
@typ($t $(::<$($generics),*>)?),
942+
@typ($t $(::$p)* $(::<$($generics),*>)?),
943943
@fields($($fields)*),
944944
@error($err),
945945
@data(InitData, /*no use_data*/),

0 commit comments

Comments
 (0)