Confusing error message when eliding lifetimes in trait impl #73520
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-lifetimes
Area: Lifetimes / regions
A-trait-system
Area: Trait system
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.
The following code:
produces the following error:
The issue is that the elided lifetimes in the impl header (
impl Foo<&u8> for ()
) and the method implementationfn make_it(&self) -> &u8
do not desugar to the same lifetime. However, we currently emit a nonsensical error message instead of explaining this.We should explain the behavior of lifetime elision, and suggest introducing a lifetime parameter in the impl header.
The text was updated successfully, but these errors were encountered: