rust/tests
Philipp Krones e2ecc4ad6e
Rollup merge of #6402 - camsteffen:collapsible-match, r=llogiq
Add Collapsible match lint

changelog: Add collapsible_match lint

Closes #1252
Closes #2521

This lint finds nested `match` or `if let` patterns that can be squashed together. It is designed to be very conservative to only find cases where merging the patterns would most likely reduce cognitive complexity.

Example:

```rust
match result {
    Ok(opt) => match opt {
        Some(x) => x,
        _ => return,
    }
    _ => return,
}
```
to
```rust
match result {
    Ok(Some(x)) => x,
    _ => return,
}
```

These criteria must be met for the lint to fire:

* The inner match has exactly 2 branches.
* Both the outer and inner match have a "wild" branch like `_ => ..`. There is a special case for `None => ..` to also be considered "wild-like".
* The contents of the wild branches are identical.
* The binding which "links" the matches is never used elsewhere.

Thanks to the hir, `if let`'s are easily included with this lint since they are desugared into equivalent `match`'es.

I think this would fit into the style category, but I would also understand changing it to pedantic.
2020-12-03 10:21:33 +01:00
..
auxiliary Remove all copyright license headers 2019-01-08 21:46:39 +01:00
cargo Merge commit '2f6439ae6a' into clippyup 2020-10-09 12:45:29 +02:00
ui Rollup merge of #6402 - camsteffen:collapsible-match, r=llogiq 2020-12-03 10:21:33 +01:00
ui-cargo Merge commit 'bf1c6f9871' into clippyup 2020-10-23 22:16:59 +02:00
ui-internal add internal-lints feature to enable clippys internal lints (off by default) 2020-11-29 21:07:43 +01:00
ui-toml add support for minimum supported rust version. 2020-11-25 12:22:47 +01:00
compile-test.rs add internal-lints feature to enable clippys internal lints (off by default) 2020-11-29 21:07:43 +01:00
dogfood.rs address review comments and rebase 2020-11-29 23:43:23 +01:00
fmt.rs Merge commit '3d0b0e66af' into clippyup 2020-08-28 18:43:25 +02:00
integration.rs Explain panic on E0463 in integration tests 2020-04-13 22:12:57 +02:00
missing-test-files.rs cargo fmt 2019-06-21 16:47:34 +02:00
versioncheck.rs test(versioncheck): Use .no_deps() 2019-01-25 21:53:44 +01:00