Skip to content

Commit 254cdbe

Browse files
committed
support async trait functions
dyn compatibility is a current issue but the macro might as well support it
1 parent 5cab31c commit 254cdbe

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

turbopack/crates/turbo-tasks-macros/src/value_trait_macro.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,19 @@ pub fn value_trait(args: TokenStream, input: TokenStream) -> TokenStream {
123123
}
124124
// Add a dummy implementation that derefences the box and delegates to the
125125
// actual implementation.
126-
dynamic_trait_fns.push(quote! {
127-
#sig {
128-
let reference: &dyn #trait_ident = &*self;
129-
reference.#ident(#(#args),*)
126+
dynamic_trait_fns.push(if sig.asyncness.is_some() {
127+
quote! {
128+
#sig {
129+
let reference: &dyn #trait_ident = &*self;
130+
reference.#ident(#(#args),*).await
131+
}
132+
}
133+
} else {
134+
quote! {
135+
#sig {
136+
let reference: &dyn #trait_ident = &*self;
137+
reference.#ident(#(#args),*)
138+
}
130139
}
131140
});
132141
continue;

0 commit comments

Comments
 (0)