From f5686f6bc02c9b4d91d8b43c2d974ba66d79a416 Mon Sep 17 00:00:00 2001 From: Thomas de Zeeuw Date: Tue, 29 Nov 2022 14:46:10 +0100 Subject: [PATCH] Use #crate_ident in test macro Instead of ::tokio. --- tokio-macros/src/entry.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tokio-macros/src/entry.rs b/tokio-macros/src/entry.rs index 7658048c6..21164d5d5 100644 --- a/tokio-macros/src/entry.rs +++ b/tokio-macros/src/entry.rs @@ -394,12 +394,12 @@ fn parse_knobs(mut input: syn::ItemFn, is_test: bool, config: FinalConfig) -> To } }; - // For test functions wrap the body in a `Box` to reduce the amount - // `Runtime::block_on` (and related functions) copies we generate during - // compilation due to the generic parameter `F` (the future to block on). - // This could have an impact on performance, but because it's only for - // testing and the runtime already boxes the future to run it, it's unlikely - // to be very large. + // For test functions pin the body to the stack and use `Pin<&mut dyn + // Future>` to reduce the amount of `Runtime::block_on` (and related + // functions) copies we generate during compilation due to the generic + // parameter `F` (the future to block on). This could have an impact on + // performance, but because it's only for testing it's unlikely to be very + // large. // // We don't do this for the main function as it should only be used once so // there will be no benefit. @@ -413,7 +413,7 @@ fn parse_knobs(mut input: syn::ItemFn, is_test: bool, config: FinalConfig) -> To }; quote! { let body = async #body; - ::tokio::pin!(body); + #crate_ident::pin!(body); let body: ::std::pin::Pin<&mut dyn ::std::future::Future> = body; } } else {