bors
a982ab4cee
Auto merge of #6532 - matthiaskrgr:mlmm, r=llogiq
...
match_like_matches_macro: strip refs in suggestion
fixes #6503
changelog: match_like_matches_macro: strip refs in suggestion (#6503 )
2021-01-21 18:34:55 +00:00
Jason Newcomb
36ff2f739c
Rename function
2021-01-14 22:02:04 -05:00
Jason Newcomb
85edd65bf6
Address review comments
...
Add: attempt to remove address of expressions from the scrutinee expression before adding references to the pattern
2021-01-14 14:26:26 -05:00
Jason Newcomb
8d7417d807
Add: single_match will suggest using if .. == .. instead of if let when applicable
2021-01-10 23:32:23 -05:00
Matthias Krüger
39f39d5405
match_like_matches_macro: strip refs in suggestion
...
fixes #6503
changelog: match_like_matches_macro: strip refs in suggestion (#6503 )
2021-01-03 20:28:46 +01:00
xFrednet
a37af06fea
Removing false positive for the match_single_binding lint
...
* Applying suggested changes from the PR
2020-12-13 20:49:39 +00:00
bors
50bca8af1d
Auto merge of #6330 - camsteffen:redundant-else, r=ebroto
...
Add Redundant else lint
changelog: Add redundant_else lint
It seemed appropriate for "pedantic".
Closes #112 \*blows off dust*
2020-12-08 00:51:51 +00:00
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
Cameron Steffen
70f6a2cae2
Eat redundant else dogfood
2020-11-29 17:55:42 -06:00
Cameron Steffen
fff5fa6581
Eat collapsible_match dogfood
2020-11-29 15:34:11 -06:00
Suyash458
cd087e5c5e
add rustc-semver to dependencies
...
switch Version/VersionReq usages to RustcVersion
2020-11-28 21:21:04 -08:00
bors
68cf94f6a6
Auto merge of #6377 - CDirkx:redundant-pattern-match-ipaddr, r=ebroto
...
Enhance `redundant_pattern_matching` to also lint on `std::net::IpAddr`
Follow-up to #6339
r? `@ebroto`
(note: also contains a small cleanup of the other ui tests)
changelog: Enhance [`redundant_pattern_matching`] to also lint on `std::net::IpAddr`
2020-11-28 23:02:47 +00:00
Philipp Krones
84cdb0a939
Fix formatting
2020-11-28 22:40:46 +01:00
Philipp Krones
22e7775aa7
Change formulation of known problems section
2020-11-28 18:58:53 +01:00
Aleksei Latyshev
e266708c42
do not trigger MATCH_LIKE_MATCHES_MACRO lint with attrs
...
- it can't be solved completely for attrs evaluated into `false`
- change applicability to MaybeIncorrect and mention it in docs
2020-11-28 20:28:07 +03:00
flip1995
b2e2c0806e
Improve extract_msrv_attr! situation
2020-11-25 12:22:58 +01:00
Suyash458
aaa4325045
add support for minimum supported rust version.
...
add configuration option for minimum supported rust version
add msrv attribute to some lints listed in #6097
add tests
2020-11-25 12:22:47 +01:00
Christiaan Dirkx
dc075b4266
Change redundant_pattern_matching
to also lint std::net::IpAddr
...
Suggest using utility methods `is_ipv4` and `is_ipv6`.
2020-11-25 02:01:05 +01:00
Christiaan Dirkx
5a83968877
Change redundant_pattern_matching
to also lint std::task::Poll
...
Suggest using utility methods `is_pending` and `is_ready`.
2020-11-17 23:40:31 +01:00
Cameron Steffen
22cc77a232
Use const rustc sym where possible
2020-11-02 11:46:37 -06:00
Aleksei Latyshev
2b7dd31368
improve MATCH_LIKE_MATCHES_MACRO lint
...
- add tests
- refactor match_same_arms lint
- prioritize match_expr_like_matches_macro over match_same_arms
2020-10-27 23:45:58 +03:00
Takayuki Nakata
114cb218f3
Remove an extra blank line in doc examples
2020-10-19 10:34:01 +09:00
Aleksei Latyshev
d4f158fa5c
Forbid redundant_pattern_matching triggering in macros
...
- remove ice-2636 test
2020-09-21 20:49:42 +03:00
Eduardo Broto
6e07247578
Merge remote-tracking branch 'upstream/master' into rustup
2020-09-21 15:11:24 +02:00
Christiaan Dirkx
141b9c2890
Remove can_suggest
from Clippy.
...
Removes `can_suggest` from as it is no longer used.
Reverts rust-clippy#5724.
2020-09-21 00:00:33 +02:00
bors
a334ae658b
Auto merge of #76136 - CDirkx:const-result, r=dtolnay
...
Stabilize some Result methods as const
Stabilize the following methods of Result as const:
- `is_ok`
- `is_err`
- `as_ref`
A test is also included, analogous to the test for `const_option`.
These methods are currently const under the unstable feature `const_result` (tracking issue: #67520 ).
I believe these methods to be eligible for stabilization because of the stabilization of #49146 (Allow if and match in constants) and the trivial implementations, see also: [PR#75463](https://github.com/rust-lang/rust/pull/75463 ) and [PR#76135](https://github.com/rust-lang/rust/pull/76135 ).
Note: these methods are the only methods currently under the `const_result` feature, thus this PR results in the removal of the feature.
Related: #76225
2020-09-20 13:07:11 +00:00
CDirkx
ac0d069616
Update src/tools/clippy/clippy_lints/src/matches.rs
...
Co-authored-by: Ralf Jung <post@ralfj.de>
2020-09-20 12:21:23 +02:00
Christiaan Dirkx
292e2f71a7
Remove can_suggest
check for is_ok
and is_err
.
...
`is_ok` and `is_err` are stabilized as const and can thus always be suggested.
2020-09-20 10:46:30 +02:00
rail
ce06472246
replace walk_ptrs_ty
with peel_refs
2020-09-17 10:11:59 +12:00
LeSeulArtichaut
28f9b84042
ty.kind
-> ty.kind()
in rustdoc and clippy
2020-09-04 18:27:33 +02:00
flip1995
d164ab65f7
Merge commit 'da5a6fb1b65ec6581a67e942a3850f6bc15a552c' into clippyup
2020-07-26 21:07:07 +02:00
Valentin Lazureanu
5a20489c5c
Rename TypeckTables to TypeckResults.
2020-07-17 08:47:04 +00:00
flip1995
6f25adbd5a
Merge commit '2ca58e7dda4a9eb142599638c59dc04d15961175' into clippyup
2020-07-14 14:59:59 +02:00
Eduard-Mihai Burtescu
30c046ede4
Use 'tcx for references to AccessLevels wherever possible.
2020-07-03 00:04:48 +03:00
Eduard-Mihai Burtescu
f5ce0e5fe9
rustc_lint: only query typeck_tables_of
when a lint needs it.
2020-06-26 02:56:23 +03:00
Lzu Tao
8db24840f7
Merge commit 'ff0993c5e9162ddaea78e83d0f0161e68bd4ea73' into clippy
2020-06-09 14:36:01 +00:00
flip1995
a0e9f9bd0d
Merge commit '7ea7cd165ad6705603852771bf82cc2fd6560db5' into clippyup2
2020-05-28 15:45:24 +02:00
flip1995
f1d3086492
Merge commit 'e214ea82ad0a751563acf67e1cd9279cf302db3a' into clippyup
2020-05-17 17:36:26 +02:00
David Tolnay
ef28361293
Downgrade match_bool to pedantic
2020-04-23 16:30:06 -07:00
xiongmao86
d7f1a1ed2b
Change note_span argument for span_lint_and_note.
2020-04-18 18:29:36 +08:00
xiongmao86
cf4e35339b
Add an Option<Span> argument to span_lint_and_help.
2020-04-18 18:28:29 +08:00
Philipp Hansch
870ae36f85
Cleanup: Rename 'db' variable to 'diag'
2020-04-17 08:08:00 +02:00
ThibsG
7fb94c2ac9
Do not lint in macros for match lints
2020-04-16 14:57:12 +02:00
Philipp Hansch
a524be6df5
cargo dev fmt
2020-04-12 15:23:54 +02:00
Philipp Hansch
83874d0ee7
Make use of Option/Result diagnostic items
2020-04-12 15:23:07 +02:00
flip1995
30503a91d2
Move matches test in matches module
2020-04-03 22:02:27 +02:00
pmk21
4cac9786c5
Skip single_match lints in macro rules
2020-03-31 15:50:15 +05:30
Matthias Krüger
aff57e0f43
rustup https://github.com/rust-lang/rust/pull/70536
2020-03-30 11:17:58 +02:00
Matthias Krüger
0982097e4d
remove redundant import
2020-03-27 20:47:34 +01:00
Matthias Krüger
8177e49e10
rustup https://github.com/rust-lang/rust/pull/70344
2020-03-27 20:41:35 +01:00