Skip to content

unused-lifetimes lint false-positives with async functions #61115

Closed

Description

@Seeker14491

Async functions that take references seem to always trigger the unused-lifetimes lint (which is allow-by-default). Example:

#![feature(async_await)]

#![warn(unused_lifetimes)]

pub async fn print(s: &str) {
    println!("{}", s);
}
warning: lifetime parameter `'_` never used
 --> src/lib.rs:5:23
  |
5 | pub async fn print(s: &str) {
  |                       ^
  |

Activity

  1. Seeker14491 commented on May 24, 2019

    @Seeker14491
    ContributorAuthor

    I found this clippy issue which describes basically the same problem.

  2. added
    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.
    A-lifetimesArea: Lifetimes / regions
    C-bugCategory: This is a bug.
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on May 24, 2019
  3. added
    AsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.
    on Jun 4, 2019
  4. nikomatsakis commented on Jun 4, 2019

    @nikomatsakis
    Contributor

    Seeing as this lint is not enabled by default, marking as deferred, though this would be good to fix and probably not too hard.

  5. added a commit that references this issue on Jul 23, 2019
  6. gilescope commented on Sep 17, 2019

    @gilescope
    Contributor

    @rustbot claim

  7. gilescope commented on Sep 17, 2019

    @gilescope
    Contributor

    Looks the same issue as #64493.

    A little inelegant but if

        !"5 | pub async fn print(s: &str) {".contains("'_")
    

    we can suppress the lint I think...

  8. added
    AsyncAwait-PolishAsync-await issues that are part of the "polish" area
    AsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.
    and removed
    AsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.
    on Oct 1, 2019
  9. added a commit that references this issue on Oct 15, 2019
    c1f51b6
  10. added a commit that references this issue on Oct 15, 2019
    fcef4b1
  11. added
    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.
    and removed
    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.
    on Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-async-awaitArea: Async & AwaitA-lifetimesArea: Lifetimes / regionsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.AsyncAwait-PolishAsync-await issues that are part of the "polish" areaAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions