Skip to content

needless_lifetimes false positive with async function. #7271

Closed
@jward-bw

Description

@jward-bw

Lint name: needless_lifetimes

I tried this code:

      fn add<'a>       (x: &'a u8, _: &u8) -> &'a u8 {x}
async fn async_add<'a> (x: &'a u8, _: &u8) -> &'a u8 {x}

I expected to see this happen:
I don't expect to see any needless_lifetimes lint errors. In both functions the 'a lifetime is required to tell the compiler which input the output borrows from.

Instead, this happened:
I receive a needless_lifetimes error for async_add. There isn't a way to resolve this line without ignoring the lint rule, since replacing any combination of the lifetime parameters with the anonymous lifetime result in a compiler error.

Meta

  • cargo clippy -V: clippy 0.1.52 (9bc8c42b 2021-05-09)
  • rustc -Vv:
    rustc 1.52.1 (9bc8c42bb 2021-05-09)
    binary: rustc
    commit-hash: 9bc8c42bb2f19e745a63f3445f1ac248fb015e53
    commit-date: 2021-05-09 
    host: x86_64-apple-darwin
    release: 1.52.1
    LLVM version: 12.0.0
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions