"does not live long enough" errors due to moving into match block should be more helpful #138741
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
Current output
Desired output
It should mention that borrowing
b
would allow (or might allow?) the lifetime to be fine.Rationale and extra context
The fact that
match
moves values is not super intuitive due to auto-refs. As usingT
or&T
uses the same syntax. This does not make it always apparent what the value inside the different arms actually is. And even with inline hints, this could be easily missed due to the mental model being 'correct', despite not matching what the user wrote.Other cases
Rust Version
Anything else?
Playground link: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=3416b390fa1efe640fc7c2ddaa8b060d
The text was updated successfully, but these errors were encountered: