Skip to content

unused-lifetimes lint duplicates "parameter is never used" error #72587

Closed

Description

The following code:

#![warn(unused_lifetimes)]
struct Foo<'a>;

fn main() {}

gives the following output:

arning: lifetime parameter `'a` never used
 --> unused_lifetime.rs:2:12
  |
2 | struct Foo<'a>;
  |           -^^- help: elide the unused lifetime
  |
note: the lint level is defined here
 --> unused_lifetime.rs:1:9
  |
1 | #![warn(unused_lifetimes)]
  |         ^^^^^^^^^^^^^^^^

error[E0392]: parameter `'a` is never used
 --> unused_lifetime.rs:2:12
  |
2 | struct Foo<'a>;
  |            ^^ unused parameter
  |
  = help: consider removing `'a`, referring to it in a field, or using a marker such as `std::marker::PhantomData`

error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0392`.

The "unused lifetimes" warning is redundant - not using a lifetime parameter is a hard error, so the warning gives no additional information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lifetimesArea: Lifetimes / regionsA-lintArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.D-verboseDiagnostics: Too much output caused by a single piece of incorrect code.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.T-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