Skip to content

single_use_lifetime should not be emitted for HRTB bounds #55058

Closed
@kennytm

Description

@kennytm

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.

Metadata

Metadata

Assignees

Labels

A-lifetimesArea: Lifetimes / regionsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.F-lint-single_use_lifetimes`single_use_lifetimes` lintT-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