From 59f83eb31cdd8e795516d8ec02cb706e9eb9b9d3 Mon Sep 17 00:00:00 2001 From: EFanZh Date: Sun, 2 Jul 2023 15:59:31 +0800 Subject: [PATCH] Inline project methods (#74) --- src/lib.rs | 4 ++++ tests/expand/default/enum.expanded.rs | 3 +++ tests/expand/default/struct.expanded.rs | 2 ++ tests/expand/multifields/enum.expanded.rs | 1 + tests/expand/multifields/struct.expanded.rs | 3 +++ tests/expand/naming/enum-all.expanded.rs | 3 +++ tests/expand/naming/enum-mut.expanded.rs | 1 + tests/expand/naming/enum-ref.expanded.rs | 1 + tests/expand/naming/struct-all.expanded.rs | 3 +++ tests/expand/naming/struct-mut.expanded.rs | 2 ++ tests/expand/naming/struct-none.expanded.rs | 2 ++ tests/expand/naming/struct-ref.expanded.rs | 2 ++ tests/expand/pinned_drop/enum.expanded.rs | 2 ++ tests/expand/pinned_drop/struct.expanded.rs | 2 ++ tests/expand/pub/enum.expanded.rs | 2 ++ tests/expand/pub/struct.expanded.rs | 2 ++ 16 files changed, 35 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 5604175..89e5692 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -954,6 +954,7 @@ macro_rules! __pin_project_struct_make_proj_method { ),+ } ) => { + #[inline] $proj_vis fn $method_ident<'__pin>( self: $crate::__private::Pin<&'__pin $($mut)? Self>, ) -> $proj_ty_ident <'__pin, $($ty_generics)*> { @@ -987,6 +988,7 @@ macro_rules! __pin_project_struct_make_proj_replace_method { ),+ } ) => { + #[inline] $proj_vis fn project_replace( self: $crate::__private::Pin<&mut Self>, replacement: Self, @@ -1034,6 +1036,7 @@ macro_rules! __pin_project_enum_make_proj_method { ),+ } ) => { + #[inline] $proj_vis fn $method_ident<'__pin>( self: $crate::__private::Pin<&'__pin $($mut)? Self>, ) -> $proj_ty_ident <'__pin, $($ty_generics)*> { @@ -1077,6 +1080,7 @@ macro_rules! __pin_project_enum_make_proj_replace_method { ),+ } ) => { + #[inline] $proj_vis fn project_replace( self: $crate::__private::Pin<&mut Self>, replacement: Self, diff --git a/tests/expand/default/enum.expanded.rs b/tests/expand/default/enum.expanded.rs index d27af2d..09e8691 100644 --- a/tests/expand/default/enum.expanded.rs +++ b/tests/expand/default/enum.expanded.rs @@ -51,6 +51,7 @@ enum EnumProjReplace { #[allow(clippy::used_underscore_binding)] const _: () = { impl Enum { + #[inline] fn project<'__pin>( self: ::pin_project_lite::__private::Pin<&'__pin mut Self>, ) -> EnumProj<'__pin, T, U> { @@ -68,6 +69,7 @@ const _: () = { } } } + #[inline] fn project_ref<'__pin>( self: ::pin_project_lite::__private::Pin<&'__pin Self>, ) -> EnumProjRef<'__pin, T, U> { @@ -85,6 +87,7 @@ const _: () = { } } } + #[inline] fn project_replace( self: ::pin_project_lite::__private::Pin<&mut Self>, replacement: Self, diff --git a/tests/expand/default/struct.expanded.rs b/tests/expand/default/struct.expanded.rs index 5ed83c8..fc10dd7 100644 --- a/tests/expand/default/struct.expanded.rs +++ b/tests/expand/default/struct.expanded.rs @@ -38,6 +38,7 @@ const _: () = { unpinned: &'__pin (U), } impl Struct { + #[inline] fn project<'__pin>( self: ::pin_project_lite::__private::Pin<&'__pin mut Self>, ) -> Projection<'__pin, T, U> { @@ -49,6 +50,7 @@ const _: () = { } } } + #[inline] fn project_ref<'__pin>( self: ::pin_project_lite::__private::Pin<&'__pin Self>, ) -> ProjectionRef<'__pin, T, U> { diff --git a/tests/expand/multifields/enum.expanded.rs b/tests/expand/multifields/enum.expanded.rs index cc009e5..f6bf9dc 100644 --- a/tests/expand/multifields/enum.expanded.rs +++ b/tests/expand/multifields/enum.expanded.rs @@ -22,6 +22,7 @@ enum EnumProjReplace { #[allow(clippy::used_underscore_binding)] const _: () = { impl Enum { + #[inline] fn project_replace( self: ::pin_project_lite::__private::Pin<&mut Self>, replacement: Self, diff --git a/tests/expand/multifields/struct.expanded.rs b/tests/expand/multifields/struct.expanded.rs index 977af53..fdf6edf 100644 --- a/tests/expand/multifields/struct.expanded.rs +++ b/tests/expand/multifields/struct.expanded.rs @@ -55,6 +55,7 @@ const _: () = { unpinned2: &'__pin (U), } impl Struct { + #[inline] fn project<'__pin>( self: ::pin_project_lite::__private::Pin<&'__pin mut Self>, ) -> Projection<'__pin, T, U> { @@ -69,6 +70,7 @@ const _: () = { } } } + #[inline] fn project_ref<'__pin>( self: ::pin_project_lite::__private::Pin<&'__pin Self>, ) -> ProjectionRef<'__pin, T, U> { @@ -82,6 +84,7 @@ const _: () = { } } } + #[inline] fn project_replace( self: ::pin_project_lite::__private::Pin<&mut Self>, replacement: Self, diff --git a/tests/expand/naming/enum-all.expanded.rs b/tests/expand/naming/enum-all.expanded.rs index d27af2d..09e8691 100644 --- a/tests/expand/naming/enum-all.expanded.rs +++ b/tests/expand/naming/enum-all.expanded.rs @@ -51,6 +51,7 @@ enum EnumProjReplace { #[allow(clippy::used_underscore_binding)] const _: () = { impl Enum { + #[inline] fn project<'__pin>( self: ::pin_project_lite::__private::Pin<&'__pin mut Self>, ) -> EnumProj<'__pin, T, U> { @@ -68,6 +69,7 @@ const _: () = { } } } + #[inline] fn project_ref<'__pin>( self: ::pin_project_lite::__private::Pin<&'__pin Self>, ) -> EnumProjRef<'__pin, T, U> { @@ -85,6 +87,7 @@ const _: () = { } } } + #[inline] fn project_replace( self: ::pin_project_lite::__private::Pin<&mut Self>, replacement: Self, diff --git a/tests/expand/naming/enum-mut.expanded.rs b/tests/expand/naming/enum-mut.expanded.rs index a948b22..79c9050 100644 --- a/tests/expand/naming/enum-mut.expanded.rs +++ b/tests/expand/naming/enum-mut.expanded.rs @@ -25,6 +25,7 @@ where #[allow(clippy::used_underscore_binding)] const _: () = { impl Enum { + #[inline] fn project<'__pin>( self: ::pin_project_lite::__private::Pin<&'__pin mut Self>, ) -> EnumProj<'__pin, T, U> { diff --git a/tests/expand/naming/enum-ref.expanded.rs b/tests/expand/naming/enum-ref.expanded.rs index f45a5cb..fa155d9 100644 --- a/tests/expand/naming/enum-ref.expanded.rs +++ b/tests/expand/naming/enum-ref.expanded.rs @@ -25,6 +25,7 @@ where #[allow(clippy::used_underscore_binding)] const _: () = { impl Enum { + #[inline] fn project_ref<'__pin>( self: ::pin_project_lite::__private::Pin<&'__pin Self>, ) -> EnumProjRef<'__pin, T, U> { diff --git a/tests/expand/naming/struct-all.expanded.rs b/tests/expand/naming/struct-all.expanded.rs index fd65895..dfea762 100644 --- a/tests/expand/naming/struct-all.expanded.rs +++ b/tests/expand/naming/struct-all.expanded.rs @@ -47,6 +47,7 @@ struct StructProjReplace { #[allow(clippy::used_underscore_binding)] const _: () = { impl Struct { + #[inline] fn project<'__pin>( self: ::pin_project_lite::__private::Pin<&'__pin mut Self>, ) -> StructProj<'__pin, T, U> { @@ -58,6 +59,7 @@ const _: () = { } } } + #[inline] fn project_ref<'__pin>( self: ::pin_project_lite::__private::Pin<&'__pin Self>, ) -> StructProjRef<'__pin, T, U> { @@ -69,6 +71,7 @@ const _: () = { } } } + #[inline] fn project_replace( self: ::pin_project_lite::__private::Pin<&mut Self>, replacement: Self, diff --git a/tests/expand/naming/struct-mut.expanded.rs b/tests/expand/naming/struct-mut.expanded.rs index 3c3507a..ed05dbb 100644 --- a/tests/expand/naming/struct-mut.expanded.rs +++ b/tests/expand/naming/struct-mut.expanded.rs @@ -38,6 +38,7 @@ const _: () = { unpinned: &'__pin (U), } impl Struct { + #[inline] fn project<'__pin>( self: ::pin_project_lite::__private::Pin<&'__pin mut Self>, ) -> StructProj<'__pin, T, U> { @@ -49,6 +50,7 @@ const _: () = { } } } + #[inline] fn project_ref<'__pin>( self: ::pin_project_lite::__private::Pin<&'__pin Self>, ) -> ProjectionRef<'__pin, T, U> { diff --git a/tests/expand/naming/struct-none.expanded.rs b/tests/expand/naming/struct-none.expanded.rs index 5ed83c8..fc10dd7 100644 --- a/tests/expand/naming/struct-none.expanded.rs +++ b/tests/expand/naming/struct-none.expanded.rs @@ -38,6 +38,7 @@ const _: () = { unpinned: &'__pin (U), } impl Struct { + #[inline] fn project<'__pin>( self: ::pin_project_lite::__private::Pin<&'__pin mut Self>, ) -> Projection<'__pin, T, U> { @@ -49,6 +50,7 @@ const _: () = { } } } + #[inline] fn project_ref<'__pin>( self: ::pin_project_lite::__private::Pin<&'__pin Self>, ) -> ProjectionRef<'__pin, T, U> { diff --git a/tests/expand/naming/struct-ref.expanded.rs b/tests/expand/naming/struct-ref.expanded.rs index 00f0673..4edb631 100644 --- a/tests/expand/naming/struct-ref.expanded.rs +++ b/tests/expand/naming/struct-ref.expanded.rs @@ -38,6 +38,7 @@ const _: () = { unpinned: &'__pin mut (U), } impl Struct { + #[inline] fn project<'__pin>( self: ::pin_project_lite::__private::Pin<&'__pin mut Self>, ) -> Projection<'__pin, T, U> { @@ -49,6 +50,7 @@ const _: () = { } } } + #[inline] fn project_ref<'__pin>( self: ::pin_project_lite::__private::Pin<&'__pin Self>, ) -> StructProjRef<'__pin, T, U> { diff --git a/tests/expand/pinned_drop/enum.expanded.rs b/tests/expand/pinned_drop/enum.expanded.rs index 26d23b9..838707d 100644 --- a/tests/expand/pinned_drop/enum.expanded.rs +++ b/tests/expand/pinned_drop/enum.expanded.rs @@ -43,6 +43,7 @@ where #[allow(clippy::used_underscore_binding)] const _: () = { impl Enum { + #[inline] fn project<'__pin>( self: ::pin_project_lite::__private::Pin<&'__pin mut Self>, ) -> EnumProj<'__pin, T, U> { @@ -60,6 +61,7 @@ const _: () = { } } } + #[inline] fn project_ref<'__pin>( self: ::pin_project_lite::__private::Pin<&'__pin Self>, ) -> EnumProjRef<'__pin, T, U> { diff --git a/tests/expand/pinned_drop/struct.expanded.rs b/tests/expand/pinned_drop/struct.expanded.rs index c8aa4a8..567fefa 100644 --- a/tests/expand/pinned_drop/struct.expanded.rs +++ b/tests/expand/pinned_drop/struct.expanded.rs @@ -39,6 +39,7 @@ const _: () = { unpinned: &'__pin (U), } impl Struct { + #[inline] fn project<'__pin>( self: ::pin_project_lite::__private::Pin<&'__pin mut Self>, ) -> Projection<'__pin, T, U> { @@ -50,6 +51,7 @@ const _: () = { } } } + #[inline] fn project_ref<'__pin>( self: ::pin_project_lite::__private::Pin<&'__pin Self>, ) -> ProjectionRef<'__pin, T, U> { diff --git a/tests/expand/pub/enum.expanded.rs b/tests/expand/pub/enum.expanded.rs index 06c04a4..aebc3f7 100644 --- a/tests/expand/pub/enum.expanded.rs +++ b/tests/expand/pub/enum.expanded.rs @@ -42,6 +42,7 @@ where #[allow(clippy::used_underscore_binding)] const _: () = { impl Enum { + #[inline] pub(crate) fn project<'__pin>( self: ::pin_project_lite::__private::Pin<&'__pin mut Self>, ) -> EnumProj<'__pin, T, U> { @@ -59,6 +60,7 @@ const _: () = { } } } + #[inline] pub(crate) fn project_ref<'__pin>( self: ::pin_project_lite::__private::Pin<&'__pin Self>, ) -> EnumProjRef<'__pin, T, U> { diff --git a/tests/expand/pub/struct.expanded.rs b/tests/expand/pub/struct.expanded.rs index fd5da9b..7562eb5 100644 --- a/tests/expand/pub/struct.expanded.rs +++ b/tests/expand/pub/struct.expanded.rs @@ -38,6 +38,7 @@ const _: () = { pub unpinned: &'__pin (U), } impl Struct { + #[inline] pub(crate) fn project<'__pin>( self: ::pin_project_lite::__private::Pin<&'__pin mut Self>, ) -> Projection<'__pin, T, U> { @@ -49,6 +50,7 @@ const _: () = { } } } + #[inline] pub(crate) fn project_ref<'__pin>( self: ::pin_project_lite::__private::Pin<&'__pin Self>, ) -> ProjectionRef<'__pin, T, U> {