From b53b4e755402ef91d2104d40b8f303ad0c56d2f9 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Tue, 24 Sep 2024 11:20:00 -0700 Subject: [PATCH 1/2] Add regression test for issue 277 warning: the type of the `self` parameter does not need to be arbitrary --> tests/test.rs:1656:24 | 1656 | async fn f(mut self: &Self) { | ^^^^^^^^^^^ help: consider to change this parameter to: `&'life0 self` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_arbitrary_self_type = note: `#[warn(clippy::needless_arbitrary_self_type)]` on by default --- tests/test.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/test.rs b/tests/test.rs index 75252c2..6fd324d 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -1641,3 +1641,22 @@ pub mod issue266 { } } } + +// https://github.com/dtolnay/async-trait/issues/277 +pub mod issue277 { + use async_trait::async_trait; + + #[async_trait] + pub trait Trait { + async fn f(&self); + } + + #[async_trait] + impl Trait for () { + async fn f(mut self: &Self) { + g(&mut self); + } + } + + fn g(_: &mut &()) {} +} From 7bd974b3a4db2c3ab321de2976d09d3ea2b82348 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Tue, 24 Sep 2024 11:26:26 -0700 Subject: [PATCH 2/2] Ignore needless_arbitrary_self_type clippy lint in generated code --- src/expand.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/expand.rs b/src/expand.rs index 1eb27a2..5adba58 100644 --- a/src/expand.rs +++ b/src/expand.rs @@ -129,6 +129,7 @@ fn lint_suppress_with_body() -> Attribute { clippy::async_yields_async, clippy::diverging_sub_expression, clippy::let_unit_value, + clippy::needless_arbitrary_self_type, clippy::no_effect_underscore_binding, clippy::shadow_same, clippy::type_complexity,