`let-else` statements do not allow the init expression to end with '}'
Fixesrust-lang/rust-clippy#15914
changelog: [`manual_let_else`]: If the init expression ends with `'}'`
wrap it with `(...)`
Based on rust-lang/rust-clippy#15866
This adds a parsing context that can allocate from an arena. Ultimately
this will also store a source map for better error reporting, but a few
other changes are happening before that.
The arena itself is unlikely to be needed from a perf standpoint
(reading all the files should be the slow part), but having more things
be copyable is nice. For reference the perf impact of this change is
within the noise.
changelog: none
Supercedes rust-lang/rust-clippy#15270
This first PR just moves the existing code and simplifies a few things.
The switch to use the new range API isn't really used in this PR , but
it's needed by future changes to avoid having to add `.clone()` all over
the place.
changelog: none
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
It's nice to come up with a clever algorithm
(https://github.com/rust-lang/rust-clippy/pull/15667), but it's even
nicer to reuse logic that already exists elsewhere.
changelog: none
r? @samueltardieu as you reviewed the original PR
`NB!` is extremely alien + not used anywhere else in repo (per github
search).
`Notes => Note`. At first thought was convention (written from
perspective of the lint), but not seen anywhere else in repo (per github
search).
Implication: clearer docs
Changes made from github web editor; no tests/checks performed.
changelog: none
- Make the diagnostic message actually desribe the problem
- Always give the suggestion, by using `snippet_with_context`
- Make the suggestion verbose, because we sometimes lint multiline exprs
like `match`es
changelog: [`manual_option_as_slice`]: improve diagnostics
- Make the diagnostic message actually desribe the problem
- Make the suggestion verbose, because we lint multiline exprs
changelog: [`match_as_ref`]: improve diagnostics