Skip to content

higher-ranked lifetime error #114866

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

Closed
asquared31415 opened this issue Aug 15, 2023 · 1 comment · Fixed by #116097
Closed

higher-ranked lifetime error #114866

asquared31415 opened this issue Aug 15, 2023 · 1 comment · Fixed by #116097
Assignees
Labels
A-borrow-checker Area: The borrow checker A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@asquared31415
Copy link
Contributor

asquared31415 commented Aug 15, 2023

Code

fn assert_all<F, T>(_f: F)
where
    F: FnMut(&String) -> T,
{
}

fn id(x: &String) -> &String {
    x
}

fn main() {
    assert_all::<_, &String>(id);
}

playground

Current output

error: higher-ranked lifetime error
  --> src/main.rs:12:5
   |
12 |     assert_all::<_, &String>(id);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^

Rationale and extra context

Found while minimizing #114849. The turbofish is crucial to reproducing this error, otherwise compilation fails as seen in that issue.

I don't know enough to say what the error should be, but it shouldn't be this.

@asquared31415 asquared31415 added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 15, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 15, 2023
@jackh726 jackh726 added A-borrow-checker Area: The borrow checker and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Aug 15, 2023
@jackh726
Copy link
Member

I'm going to work on this (but going to use it as an example for a talk, so may take ~a month)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-borrow-checker Area: The borrow checker A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
3 participants