"expected X found X" diagnostic for lifetime mismatch in method signature of trait impl #79643
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-lifetimes
Area: Lifetimes / regions
C-bug
Category: This is a bug.
D-confusing
Diagnostics: Confusing error or lint that should be reworked.
D-newcomer-roadblock
Diagnostics: Confusing error or lint; hard to understand for new users.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
With this code:
The error message is:
Now, the two
help
lines do give relevant information on how to fix this, which is to have a single named lifetime and use it everywhere:However the part of the error that is more visible at first glance (at least to me) is:
My internal reaction was: if what was expected and found is the same thing, what’s the problem?
The two signature are in fact not the same because they each have their own implicit lifetime parameter which don’t necessarily match each other. Would it make sense to make those parameters explicit? Signatures in diagnostics don’t need to be entirely valid Rust syntax. Something like:
Meta
The output is the same in 1.48.0 and nightly-2020-11-30.
The text was updated successfully, but these errors were encountered: