Poor error message with a function that takes a closure that takes a reference #95277
Labels
A-closures
Area: Closures (`|…| { … }`)
A-diagnostics
Area: Messages for errors, warnings, and lints
A-lifetimes
Area: Lifetimes / regions
D-confusing
Diagnostics: Confusing error or lint that should be reworked.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d21e5af3a39c5469cff10767987be29a
The current output is:
This is a poor error message for the following reasons:
Fn
, but the error message only mentionsfn
andFnOnce
, notFn
Truth be told I'm not even sure if this should be an error. It's quite confusing; neither of the following produce the same error:
So maybe this is an error in type inference?
Worth nothing that I suspect the following could be considered the "correct" fix in this case:
So, if nothing else, perhaps it should suggest explicitly specifying the lifetime on
fn qux
.The text was updated successfully, but these errors were encountered: