Skip to content

higher-ranked lifetime error #114866

Closed
@asquared31415

Description

@asquared31415

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.

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

Development

No branches or pull requests

Issue actions