diff --git a/src/gen.rs b/src/gen.rs index 77a9507..ffb8795 100644 --- a/src/gen.rs +++ b/src/gen.rs @@ -706,29 +706,31 @@ fn gen_method_item( // Generate the body of the function. This mainly depends on the self type, // but also on the proxy type. let fn_name = &sig.ident; + let await_token = sig.asyncness.map(|_| quote! { .await }); + let body = match self_arg { // Fn proxy types get a special treatment _ if proxy_type.is_fn() => { - quote! { ({self})(#args) } + quote! { ({self})(#args) #await_token } } // No receiver SelfType::None => { // The proxy type is a reference, smart pointer or Box. - quote! { #proxy_ty_param::#fn_name #generic_types(#args) } + quote! { #proxy_ty_param::#fn_name #generic_types(#args) #await_token } } // Receiver `self` (by value) SelfType::Value => { // The proxy type is a Box. - quote! { #proxy_ty_param::#fn_name #generic_types(*self, #args) } + quote! { #proxy_ty_param::#fn_name #generic_types(*self, #args) #await_token } } // `&self` or `&mut self` receiver SelfType::Ref | SelfType::Mut => { // The proxy type could be anything in the `Ref` case, and `&mut` // or Box in the `Mut` case. - quote! { #proxy_ty_param::#fn_name #generic_types(self, #args) } + quote! { #proxy_ty_param::#fn_name #generic_types(self, #args) #await_token } } }; diff --git a/tests/recent/compile-pass/associated_lifetime.rs b/tests/since_1.51/compile-pass/associated_lifetime.rs similarity index 100% rename from tests/recent/compile-pass/associated_lifetime.rs rename to tests/since_1.51/compile-pass/associated_lifetime.rs diff --git a/tests/recent/compile-pass/generic_const_method.rs b/tests/since_1.51/compile-pass/generic_const_method.rs similarity index 100% rename from tests/recent/compile-pass/generic_const_method.rs rename to tests/since_1.51/compile-pass/generic_const_method.rs diff --git a/tests/recent/compile-pass/generic_mix.rs b/tests/since_1.51/compile-pass/generic_mix.rs similarity index 100% rename from tests/recent/compile-pass/generic_mix.rs rename to tests/since_1.51/compile-pass/generic_mix.rs diff --git a/tests/since_1.75/compile-pass/async_trait.rs b/tests/since_1.75/compile-pass/async_trait.rs new file mode 100644 index 0000000..f3fa01b --- /dev/null +++ b/tests/since_1.75/compile-pass/async_trait.rs @@ -0,0 +1,6 @@ +#[auto_impl::auto_impl(&, &mut, Arc, Box, Rc)] +trait AsyncTrait { + async fn foo(&self); +} + +fn main() {} diff --git a/tests/ui.rs b/tests/ui.rs index e298fff..af43b29 100644 --- a/tests/ui.rs +++ b/tests/ui.rs @@ -15,7 +15,14 @@ fn ui_compile_fail() { #[rustversion::since(1.51)] #[test] -fn ui_recent_compile_pass() { +fn ui_since_1_51_compile_pass() { let t = TestCases::new(); - t.pass("tests/recent/compile-pass/*.rs"); + t.pass("tests/since_1.51/compile-pass/*.rs"); +} + +#[rustversion::since(1.75)] +#[test] +fn ui_since_1_75_compile_pass() { + let t = TestCases::new(); + t.pass("tests/since_1.75/compile-pass/*.rs"); }