Files
rust/clippy_lints
Samuel Tardieu 0c592df5a5 fix(match_as_ref): suggest as_ref when the reference needs to be cast (#15934)
I first implemented the naive version, which just talks about, and
suggests using, `Option::as_ref`. But the resulting error message
sounded a bit misleading -- after all, the manual implementation was
factually that of `Option::as_mut`, and we only suggest `as_ref` as a
means of downcasting. So then I added another help message to mention
the need for reference downcasting, which.. still looks awkward.

Honestly it might be the easiest to hide the reference downcasting into
the `.map` after all, so that it encapsulates _all_ the casting needed
following the switch to `as_ref`/`as_mut`.

changelog: [`match_as_ref`]: suggest `as_ref` when the reference needs
to be cast

r? @samueltardieu
2025-10-22 11:22:20 +00:00
..

This crate contains Clippy lints. For the main crate, check GitHub.