Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick fix to declare an unresolved lifetime #11039

Open
matklad opened this issue Dec 17, 2021 · 1 comment
Open

Quick fix to declare an unresolved lifetime #11039

matklad opened this issue Dec 17, 2021 · 1 comment
Labels
A-diagnostics diagnostics / error reporting C-feature Category: feature request E-has-instructions Issue has some instructions and pointers to code to get started S-actionable Someone could pick this issue up and work on it right now

Comments

@matklad
Copy link
Member

matklad commented Dec 17, 2021

With inband lifetimes going away (rust-lang/rust#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?

@matklad matklad added E-has-instructions Issue has some instructions and pointers to code to get started S-actionable Someone could pick this issue up and work on it right now A-diagnostics diagnostics / error reporting C-feature Category: feature request labels Dec 17, 2021
@Veykril
Copy link
Member

Veykril commented Dec 17, 2021

Since we don't use lifetimes in type inference and such yet we only actually resolve them in the ide layer(through Semantics).

So I guess we should first actually lower/resolve them in type inference(without using them afterwards, we can just keep the static lifetime hack) and then emit diagnostics from there which I think should happen somewhere around here? https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/lower.rs#L162-L351

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics diagnostics / error reporting C-feature Category: feature request E-has-instructions Issue has some instructions and pointers to code to get started S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

No branches or pull requests

2 participants