Skip to content

Commit

Permalink
Pin Future to stack in #[tokio::test]
Browse files Browse the repository at this point in the history
Instead of boxing it.
  • Loading branch information
Thomas de Zeeuw authored and Thomasdezeeuw committed Nov 29, 2022
1 parent 2fcc6c2 commit 224acd2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tokio-macros/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,9 @@ fn parse_knobs(mut input: syn::ItemFn, is_test: bool, config: FinalConfig) -> To
syn::ReturnType::Type(_, ret_type) => quote! { #ret_type },
};
quote! {
let body: ::std::pin::Pin<::std::boxed::Box<dyn ::std::future::Future<Output = #output_type>>> =
::std::boxed::Box::pin(async #body);
let body = async #body;
::tokio::pin!(body);
let body: ::std::pin::Pin<&mut dyn ::std::future::Future<Output = #output_type>> = body;
}
} else {
quote! {
Expand Down

0 comments on commit 224acd2

Please sign in to comment.