On error due to reference introduced by default binding modes, point out where reference was introduced #70933
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Simple example:
(plus if/when
Some(&val)
works to destrucure the borrow, suggest that instead)Initially suggested on irlo, cc @joshtriplett @rpjohnst
This should help remove some of the pain points people have had around default binding modes ("match ergonomics") introducing needless borrows, as the error message now also points at the pattern, like it did before default binding modes were introduced.
(As a side note: a (clippy) lint for binding a
Copy
value by reference that could be bound by copy would also help here, independently of improving the error message.)@rustbot modify labels: +A-diagnostics
The text was updated successfully, but these errors were encountered: