Skip to content

higher-ranked lifetime error #114866

@asquared31415

Description

@asquared31415
Contributor

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.

Activity

added
A-diagnosticsArea: Messages for errors, warnings, and lints
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Aug 15, 2023
added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Aug 15, 2023
added and removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Aug 15, 2023
jackh726

jackh726 commented on Aug 15, 2023

@jackh726
Member

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

self-assigned this
on Aug 15, 2023
added a commit that references this issue on Nov 16, 2023
820f06b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-borrow-checkerArea: The borrow checkerA-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @jackh726@asquared31415@rustbot

    Issue actions

      higher-ranked lifetime error · Issue #114866 · rust-lang/rust