Skip to content

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

@lcnr

Description

@lcnr
Contributor
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.

Activity

added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Nov 27, 2023
changed the title [-]lint on named lifetimes forced to be equal to another named lifetime[/-] [+]we should lint on named lifetimes forced to be equal to another named lifetime[/+] on Nov 27, 2023
added
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.
A-lifetimesArea: Lifetimes / regions
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.
T-typesRelevant to the types team, which will review and decide on the PR/issue.
and removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Nov 27, 2023
added 4 commits that reference this issue on Nov 27, 2023
58aa0f0
7a2c7d7
f5059fb
cd52ad0
added a commit that references this issue on Apr 10, 2024
fa696a3
added a commit that references this issue on Apr 10, 2024
fc1fbd7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

    Participants

    @compiler-errors@lcnr@rustbot@Noratrieb

    Issue actions

      we should lint on named lifetimes forced to be equal to another named lifetime · Issue #118376 · rust-lang/rust