rust-lang / rust-lang/rust-analyzer

Quick fix to declare an unresolved lifetime

Open
#11,039 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-diagnostics C-feature E-has-instructions S-actionable
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

With inband lifetimes going away (https://github.com/rust-lang/rust/issues/44524), I believe we should just fix the ergonomics at the ide layer.

Typing fn foo(&'a str) should emit an error for unresolved 'a, and a quick fix to declare a lifetime: fn foo<'a>(&'a str).

See how NoSuchField diagnostics is treated, which has a similar flow with a fix: https://github.com/rust-analyzer/rust-analyzer/search?q=NoSuchField.

@Veykril I believe you did name resolution for lifetimes, could you add a code link for where it is happening?

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 tracing the NoSuchField diagnostic flow in rust-analyzer and the lifetime name-resolution code requested in the issue. Confirm how an unresolved 'a reaches the diagnostic layer, then compare the quick-fix outcome with the stated fn foo<'a>(&'a str) form and add coverage alongside the existing diagnostic tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.