Skip to content

False positive unused_lifetimes warning with an async fn #86615

Description

@Hawk777

Given the following code:

#![warn(unused_lifetimes)]

use std::borrow::Cow;

pub async fn do_thing(s: Cow<'_, str>) -> Cow<'_, str> {
	s
}

The current output is:

warning: lifetime parameter `'_` never used
 --> src/main.rs:5:47
  |
5 | pub async fn do_thing(s: Cow<'_, str>) -> Cow<'_, str> {
  |                              -----------------^^
  |                              |
  |                              help: elide the unused lifetime
  |

Removing the word async makes the warning disappear. I am currently running 1.52.1, and this also happens in 1.53.0 on the playground, as well as 1.55.0 nightly on the playground.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-async-awaitArea: Async & AwaitA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.AsyncAwait-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