Skip to content

Macro-generated false positive for clippy::needless_arbitrary_self_type #277

@adamspofford-dfinity

Description

@adamspofford-dfinity

I am implementing an async trait for all T where &T: tower::Service<...>. Since Service::execute takes &mut self, this trait impl says mut self: &Self (since you cannot say mut &self). This is fine with a plain async trait, but #[async_trait] triggers the clippy lint:

warning: the type of the `self` parameter does not need to be arbitrary
    --> ic-agent/src/agent/mod.rs:1865:13
     |
1865 |         mut self: &'a Self,
     |             ^^^^^^^^^^^^^^ help: consider to change this parameter to: `&'a 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

because the generated code starts with &self and let-binds it later. It would be good if async_trait silenced the warning instead of the caller.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions