Skip to content

Commit

Permalink
Drop async move hack
Browse files Browse the repository at this point in the history
  • Loading branch information
lnicola committed May 7, 2019
1 parent 16e4f02 commit efeecb6
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 34 deletions.
25 changes: 0 additions & 25 deletions tower-web-macros/src/resource/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ impl Resource {
let match_extract = self.match_extract();
let match_into_response = self.match_into_response();

let async_helper_macro = self.async_helper_macro();

// Define `Resource` on the struct.
quote! {
macro_rules! try_ready {
Expand All @@ -134,8 +132,6 @@ impl Resource {
}}
}

#async_helper_macro

pub struct __GeneratedResource<S, B, T>
where S: __tw::response::Serializer,
B: __tw::util::BufStream,
Expand Down Expand Up @@ -783,27 +779,6 @@ impl Resource {
})
}

fn async_helper_macro(&self) -> TokenStream {
if self.is_async() {
// Works around limitations around emiting 2018 syntax in current Rust.
quote! {
macro_rules! async_move_hax {
($e:expr) => {
async move { $e }
}
}
}
} else {
quote!()
}
}

/// Returns true if at least one route is an async fn.
fn is_async(&self) -> bool {
self.routes.iter()
.any(|route| route.is_async())
}

/// The resource's future type
fn handler_future_ty(&self) -> TokenStream {
TyTree::new(&self.routes[..])
Expand Down
4 changes: 0 additions & 4 deletions tower-web-macros/src/resource/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ impl Route {
self.sig.args()
}

pub fn is_async(&self) -> bool {
self.sig.is_async()
}

pub fn template(&self) -> Option<&str> {
self.attributes.template()
}
Expand Down
6 changes: 1 addition & 5 deletions tower-web-macros/src/resource/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ impl Signature {
&self.ret
}

pub fn is_async(&self) -> bool {
self.is_async
}

/// The response future type
pub fn future_ty(&self) -> TokenStream {
let ty = self.ret();
Expand All @@ -87,7 +83,7 @@ impl Signature {

quote! {
let inner = #inner.clone();
let ret: #ty = __tw::codegen::async_await::async_to_box_future_send(async_move_hax! {
let ret: #ty = __tw::codegen::async_await::async_to_box_future_send(async move {
r#await!(inner.handler.#ident(#(#args),*))
});
ret
Expand Down

0 comments on commit efeecb6

Please sign in to comment.