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

single_use_lifetime should not be emitted for HRTB bounds #55058

Closed
kennytm opened this issue Oct 14, 2018 · 1 comment · Fixed by #96833
Closed

single_use_lifetime should not be emitted for HRTB bounds #55058

kennytm opened this issue Oct 14, 2018 · 1 comment · Fixed by #96833
Assignees
Labels
A-lifetimes Area: lifetime related A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. F-lint-single_use_lifetimes `single_use_lifetimes` lint T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@kennytm
Copy link
Member

kennytm commented Oct 14, 2018

Repro (on 1.28-stable to 1.31-nightly)

#![warn(single_use_lifetimes)]

pub trait Tfv<'a>: Sized {
    const FOO: &'a u8;
}

pub fn g<T: for<'a> Tfv<'a>>() {}

Unexpected lint result:

warning: lifetime parameter `'a` only used once
 --> src/lib.rs:7:17
  |
7 | pub fn g<T: for<'a> Tfv<'a>>() {}
  |                 ^^      -- ...is used only here
  |                 |
  |                 this lifetime...
  |

Unless we intend to support T: Tfv<'_>, there shouldn't be a lint here. cc #44752.

@kennytm kennytm added A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. A-lifetimes Area: lifetime related T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Oct 14, 2018
@Diggsey
Copy link
Contributor

Diggsey commented Apr 7, 2020

I've only ever seen this lint fire incorrectly...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lifetimes Area: lifetime related A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. F-lint-single_use_lifetimes `single_use_lifetimes` lint T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants