rust/tests
bors 0b63e95dce Auto merge of #10949 - y21:issue8010, r=Alexendoo
[`manual_filter_map`]: lint on `matches` and pattern matching

Fixes #8010

Previously this lint only worked specifically for a very limited set of methods on the filter call (`.filter(|opt| opt.is_some())` and `.filter(|res| res.is_ok())`). This PR extends it to also recognize `matches!` in the `filter` and pattern matching with `if let` or `match` in the `map`.

Example:
```rs
enum Enum {
  A(i32),
  B,
}

let _ = [Enum::A(123), Enum::B].into_iter()
  .filter(|x| matches!(x, Enum::A(_)))
  .map(|x| if let Enum::A(s) = x { s } else { unreachable!() });
```
Now suggests:
```diff
-  .filter(|x| matches!(x, Enum::A(_))).map(if let Enum::A(s) = x { s } else { unreachable!() })
+  .filter_map(|x| match x { Enum::A(s) => Some(s), _ => None })
```

Adding this required a somewhat large change in code because it originally seemed to be specifically written with only method calls in the filter in mind, and `matches!` has different behavior in the map, so this new setup should make it possible to support more "generic" cases that need different handling for the filter and map calls.

changelog: [`manual_filter_map`]: lint on `matches` and pattern matching (and some internal refactoring)
2023-07-19 12:59:51 +00:00
..
test_utils Revert "Dogfood missing_assert_message on Clippy" 2023-03-08 08:51:50 +00:00
ui Auto merge of #10949 - y21:issue8010, r=Alexendoo 2023-07-19 12:59:51 +00:00
ui-cargo Remove unused flags from ui-cargo tests 2023-07-18 18:46:09 +00:00
ui-internal clippy-driver: Update bug URL to use the ice template 2023-07-16 11:51:01 +02:00
ui-toml Add imports_granularity = "Module" to rustfmt.toml 2023-07-13 12:44:57 +00:00
workspace_test Merge commit '37f4c1725d' into clippyup 2023-07-02 14:59:02 +02:00
check-fmt.rs Merge commit 'f51aade56f' into clippyup 2022-08-31 09:24:45 -04:00
clippy.toml
compile-test.rs Merge remote-tracking branch 'upstream/master' into rustup 2023-07-14 13:36:16 +02:00
dogfood.rs Merge commit '371120bdbf' into clippyup 2023-05-05 17:45:49 +02:00
headers.rs Merge commit '37f4c1725d' into clippyup 2023-07-02 14:59:02 +02:00
integration.rs Revert "Dogfood missing_assert_message on Clippy" 2023-03-08 08:51:50 +00:00
lint_message_convention.rs Merge commit '37f4c1725d' into clippyup 2023-07-02 14:59:02 +02:00
missing-test-files.rs Merge commit '37f4c1725d' into clippyup 2023-07-02 14:59:02 +02:00
versioncheck.rs Merge commit '4bdfb0741d' into clippyup 2022-12-17 14:12:54 +01:00
workspace.rs Merge commit '37f4c1725d' into clippyup 2023-07-02 14:59:02 +02:00