rust-lang / rust-lang/rust

Suggest unused lifetime parameters

Open
#119,236 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-lifetimes A-lints C-feature-request T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
type Foo<'a> = ();

fn foo<'a>() -> Foo<'a> { () }

fn main() {
    foo();
}
Current output
Success
Desired output
warning: lifetime parameter `'a` is never used
 --> src/main.rs:1:10
  |
1 | type Foo<'a> = ();
  |          ^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: lifetime parameter `'a` is never used
 --> src/main.rs:3:8
  |
3 | fn foo<'a>() -> Foo<'a> { () }
  |        ^^
Rationale and extra context

No response

Other cases

No response

Anything else?

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by compiling the Rust snippet from the issue and compare the current output with the requested warnings for both unused lifetime parameters. Trace the compiler's unused-parameter diagnostics and related tests, then add coverage showing warnings for the type alias and function cases. Done means the example emits the expected warnings without changing valid lifetime behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.