Skip to content

False positive for needless_lifetimes (possibly due to async?) #4746

@tmccombs

Description

@tmccombs

Output of cargo clippy -V:

clippy 0.0.212 (4e7e71b 2019-10-11)

I have a method that looks like this:

    pub async fn wait<'a, T>(&self, guard: MutexGuard<'a, T>) -> MutexGuard<'a, T> {
        let mutex = guard_lock(&guard);

        self.await_notify(guard).await;

        mutex.lock().await
    }

Clippy flags the signature for needless lifetimes. However, replacing the 'a lifteime with the anonymous '_ as suggested, results in a lifetime mismatch error, because the lifetime of the return value comes from the guard argument, not self. As far as I understand, lifetimes cannot be elided here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingT-async-awaitType: Issues related to async/await

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions