diff --git a/crates/backend/src/codegen.rs b/crates/backend/src/codegen.rs index c8decb4a136..8ae6b738c00 100644 --- a/crates/backend/src/codegen.rs +++ b/crates/backend/src/codegen.rs @@ -806,6 +806,16 @@ impl TryToTokens for ast::Export { add_check(quote! { let _: #wasm_bindgen::__rt::marker::CheckSupportsConstructor<#class>; }); + + if self.function.r#async { + (quote_spanned! { + self.function.name_span => + #[deprecated(note = "async constructors are not supported")] + fn constructor() {} + constructor(); + }) + .to_tokens(into); + } } ast::MethodKind::Operation(operation) => match operation.kind { ast::OperationKind::Getter(_) | ast::OperationKind::Setter(_) => { diff --git a/crates/macro-support/src/parser.rs b/crates/macro-support/src/parser.rs index a10d823b3b3..46c76a1ef21 100644 --- a/crates/macro-support/src/parser.rs +++ b/crates/macro-support/src/parser.rs @@ -1418,11 +1418,6 @@ impl MacroParse<&ClassMarker> for &mut syn::ImplItemFn { FunctionPosition::Impl { self_ty: class }, )?; let method_kind = if opts.constructor().is_some() { - if function.r#async { - self.attrs.push(syn::parse_quote! { - #[deprecated(note = "constructors cannot be async")] - }); - } ast::MethodKind::Constructor } else { let is_static = method_self.is_none();