Skip to content

Conversation

cjgillot
Copy link
Contributor

Based on #95776 and #96559.

This PR moves the elision failure diagnostics ("expected named lifetime") from HIR to the AST.
This is is done by introducing a pair of functions resolve_fn_like_elision which handles ribs for functions and elision_lifetime which resolve parameters and return the proper lifetime for elision.

I am not very confident in the elision logic: the currently implemented code allows a few more cases than is specified in the documentation. For instance, this is allowed:

fn foo(x: Pin<&Self>, y: &u32) -> &u64

This PR is WIP since its handling of impl-trait is a bit ad-hoc until #96529 is resolved.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 30, 2022
@rust-highfive
Copy link
Contributor

r? @nagisa

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 30, 2022
@cjgillot
Copy link
Contributor Author

r? @petrochenkov

@rust-highfive rust-highfive assigned petrochenkov and unassigned nagisa Apr 30, 2022
visit::walk_ty(self, ty)
}
TyKind::ImplTrait(..) => {
if let AnonymousLifetimeRib::PassThrough(_) =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be corrected to a test on universal/existential impl-trait.

@bors
Copy link
Collaborator

bors commented Apr 30, 2022

☔ The latest upstream changes (presumably #95776) made this pull request unmergeable. Please resolve the merge conflicts.

@cjgillot
Copy link
Contributor Author

Turns out this is not fully cooked yet.

@cjgillot cjgillot closed this Apr 30, 2022
@cjgillot cjgillot deleted the ast-lifetimes-anon branch April 30, 2022 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants