Skip to content

should_implement_trait should not warn async methods #4290

Closed
@taiki-e

Description

@taiki-e

They are actually returning a different type than normal methods.

#![feature(async_await)]
#![warn(clippy::should_implement_trait)]

pub struct Foo;

impl Foo {
    // actual type: pub fn next(&mut self) -> impl Future<Output = Option<()>>
    pub async fn next(&mut self) -> Option<()> { //~ WARN: defining a method called `next` on this type; consider implementing the `std::iter::Iterator` trait or choosing a less ambiguous name
        unimplemented!()
    }
}

Playground

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingT-async-awaitType: Issues related to async/awaitgood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions