Skip to content

we should lint on named lifetimes forced to be equal to another named lifetime #118376

Closed
@lcnr

Description

@lcnr
fn foo<'a, 'b>(x: &'a &'b &'a ()) {} // WARN: `'a` and `'b` are equal

and

fn foo<'a: 'b, 'b: 'a>() {} // WARN: `'a` and `'b` are equal

and

struct Foo<T: 'static>(T);

fn bar<'a>(_: Foo<&'a ()>) {} // WARN: replace `'a` with `'static`

and

struct Foo<'a>(&'a ());

impl<'a> Foo<'a> {
    fn bar<'b: 'a>(&'b self) {} // WARN: `'a` and `'b` are equal
}

these should all warn that the named lifetimes are equal to some other named lifetime and should be removed.

Metadata

Metadata

Labels

A-lifetimesArea: Lifetimes / regionsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types 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