Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive unused_lifetimes warning with an async fn #86615

Closed
Hawk777 opened this issue Jun 25, 2021 · 4 comments
Closed

False positive unused_lifetimes warning with an async fn #86615

Hawk777 opened this issue Jun 25, 2021 · 4 comments
Labels
A-async-await Area: Async & Await A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Hawk777
Copy link

Hawk777 commented Jun 25, 2021

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.

@Hawk777 Hawk777 added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 25, 2021
@JohnTitor JohnTitor added A-async-await Area: Async & Await A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. and removed A-diagnostics Area: Messages for errors, warnings, and lints labels Jun 25, 2021
@tmandry tmandry added the AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. label Jun 25, 2021
@tmandry
Copy link
Member

tmandry commented Jun 25, 2021

Someone interested in fixing this might find it helpful to look at #79689.

@Aaron1011
Copy link
Member

This no longer warns as of the latest nightly.

@scottmcm
Copy link
Member

Closing as the example in the OP no longer repros.

@Aaron1011
Copy link
Member

Aaron1011 commented Dec 16, 2021

Does this need a regression test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants