Commit graph

11210 commits

Author SHA1 Message Date
Takayuki Maeda
3b8e85a5dc fix false positive in manual_flatten 2021-03-25 00:15:21 +09:00
bors
919a1a40fe Auto merge of #6957 - camsteffen:eq-ty-kind, r=flip1995
Factor out `SpanlessEq::eq_ty_kind`

changelog: none
2021-03-23 16:25:28 +00:00
Cameron Steffen
9132dbdf31 Factor out eq_ty_kind 2021-03-23 10:49:12 -05:00
bors
b80903b727 Auto merge of #6950 - Sciencentistguy:master, r=phansch
Ignore str::len() in or_fun_call lint.

changelog: Changed `or_fun_call` to ignore `str::len`, in the same way it ignores `slice::len` and `array::len`

Closes #6943
2021-03-22 20:29:13 +00:00
bors
029777f029 Auto merge of #6896 - TaKO8Ki:refactor-lints-in-methods-module, r=phansch
Refactor lints in methods module

This PR refactors methods lints other than the lints I refactored in https://github.com/rust-lang/rust-clippy/pull/6826 and moves some functions to methods/utils.rs.
Basically, I follow the instruction described in #6680.

**For ease of review, I refactored step by step, keeping each commit small.**

closes https://github.com/rust-lang/rust-clippy/issues/6886
cc: `@phansch,` `@flip1995,` `@Y-Nak`

changelog: Move lints in methods module to their own modules and some function to methods/utils.rs.
2021-03-22 19:36:22 +00:00
Jamie Quigley
45e775697e
Ignore str::len() in or_fun_call lint. 2021-03-22 19:34:20 +00:00
bors
aca95aac7b Auto merge of #6942 - mgacek8:issue_6815_search_is_none, r=llogiq
search_is_some: add checking for `is_none()`

fixes: #6815
changelog: search_is_some: add checking for `is_none()`.

To be honest I don't know what is the process of renaming the lints. Appreciate any feedback if that needs to be handled differently. Thanks!
2021-03-22 12:58:47 +00:00
Mateusz Gacek
2ffee89b75 search_is_some: check also when search is none 2021-03-21 21:23:36 +01:00
bors
f3de78e0d6 Auto merge of #6945 - ThibsG:BadSuggestionGenericsForReassignDefault, r=Manishearth
Fix suggestion with generics for `field_reassign_with_default` lint

Fix bad suggestion where `::` is missing after type if generics are involved

Fixes #6944

changelog: none
2021-03-21 14:42:45 +00:00
ThibsG
3ddaabcbc9 Fix suggestion with generics for field_reassign_with_default lint 2021-03-21 09:58:04 +01:00
bors
0bdaa77d95 Auto merge of #6941 - ThibsG:suggMatchSingleBinding, r=llogiq
Fix bad suggestion for `match_single_binding` lint

Fix a bad suggestion that needs curly braces when the target `match` is the body of an arm.

Fixes #6572

changelog: none
2021-03-20 17:35:21 +00:00
bors
478f2581b1 Auto merge of #6939 - ThibsG:suggNewWithoutDefault, r=llogiq
Fix bad suggestion for generics in `new_without_default` lint

Fixes bad suggestion where a type parameter was missing for `new_without_default` lint.

Fixes #6933

changelog: none
2021-03-20 17:20:34 +00:00
ThibsG
7d45d8a29a Split match_single_binding tests in 2 files (too many lines for CI) 2021-03-20 16:31:39 +01:00
ThibsG
00a2d7ad7e Fix bad suggestion that needs curly braces for match_single_binding lint 2021-03-20 16:11:19 +01:00
ThibsG
296751f643 Fix bad suggestion for generics in new_without_default lint 2021-03-20 10:24:10 +01:00
bors
1d3c539fbb Auto merge of #6924 - mgacek8:issue6727_copy_types, r=llogiq
wrong_self_convention: `to_` convention respects `Copy` types

fixes #6727
changelog: wrong_self_convention: `to_` convention respects `Copy` types
2021-03-20 06:59:13 +00:00
Mateusz Gacek
1f2d01641d wrong_self_convention: Enhance lint message 2021-03-19 20:29:55 +01:00
bors
0d2e2b5f15 Auto merge of #6935 - matthiaskrgr:qmark_marco, r=flip1995
needless_question_mark: don't lint if Some(..) is inside a macro def and the ? is not.

The suggestion would fail to apply.

Fixes #6921

changelog: needless_question_mark: don't lint if Some(..) is inside a macro def and the ? is not.
2021-03-19 09:55:30 +00:00
Matthias Krüger
b42ec5e04d needless_question_mark: don't lint if Some(..) is inside a macro def and the ? is not.
The suggestion would fail to apply.

Fixes #6921

changelog: needless_question_mark: don't lint if Some(..) is inside a macro def and the ? is not.
2021-03-18 23:47:21 +01:00
bors
36aee1c526 Auto merge of #6928 - mgacek8:issue6675_or_fun_call_unsafe_blocks, r=phansch
or_fun_call: trigger on unsafe blocks

fixes #6675
changelog: or_fun_call: trigger on unsafe blocks
2021-03-18 15:55:06 +00:00
bors
4d686196b9 Auto merge of #6863 - Jarcho:wild_enum_match, r=llogiq
`match_wildcard` improvements

fixes: #6604
fixes: #5733
fixes: #6862

#5733 is only fixed in the normal case, if different paths are used for the variants then the same problem will occur. It's cause by `def_path_str` returning an utterly useless result. I haven't dug into why yet.

For #6604 there should be some discussion before accepting this. It's easy enough to change the message rather than disable the lint for `Option` and `Result`.

changelog: Attempt to find a common path prefix for `match_wildcard_for_single_variants` and `wildcard_enum_match_arm`
changelog: Don't lint op `Option` and `Result` for `match_wildcard_for_single_variants` and `wildcard_enum_match_arm`
changelog: Consider `or` patterns and `Self` prefix for `match_wildcard_for_single_variants` and `wildcard_enum_match_arm`
2021-03-18 10:39:28 +00:00
Mateusz Gacek
032cdfe043 Adjust use_self uitest to proper self convention 2021-03-18 10:27:55 +01:00
Mateusz Gacek
b1f89ee02f or_fun_call: trigger on unsafe blocks 2021-03-18 08:44:15 +01:00
Mateusz Gacek
ea15fb2177 wrong_self_convention: to_ respects Copy types
More details here:
https://rust-lang.github.io/api-guidelines/naming.html#ad-hoc-conversions-follow-as_-to_-into_-conventions-c-conv
2021-03-17 22:00:46 +01:00
bors
ba13311c46 Auto merge of #6856 - Jarcho:manual_map_if_let, r=Manishearth
Fix `manual_map` suggestion for `if let.. else ... if let.. else` chain

fixes: #6847

changelog: Fix `manual_map` suggestion for `if let.. else ... if let.. else` chain
2021-03-17 17:47:59 +00:00
Jason Newcomb
f468d82283
Fix manual_map suggestion for if let.. else ... if let.. else chain 2021-03-17 12:57:42 -04:00
Jason Newcomb
d5a7941ead
Fix message for match_wildcard_for_single_variant 2021-03-17 12:42:18 -04:00
Takayuki Maeda
b6a2757561 replace crate::methods::utils with super::utils 2021-03-18 01:23:37 +09:00
Takayuki Maeda
0edd5f881d remove the use of paths 2021-03-18 01:06:24 +09:00
Jason Newcomb
6cc9cac4bc
Add test for #[non_exhaustive] enum in match_wildcard_for_single-variant 2021-03-17 12:04:19 -04:00
Jason Newcomb
0b7ab90eca
Improvements to match_wildcard_for_single_variants and wildcard_enum_match_arm lints
Don't lint on `Result` and `Option` types.
Considers `or` patterns.
Considers variants prefixed with `Self`
Suggestions will try to find a common prefix rather than just using the full path
2021-03-17 12:04:11 -04:00
Takayuki Maeda
602bcf3e4f move get_hint_if_single_char_arg to methods/utils.rs 2021-03-18 00:59:45 +09:00
Takayuki Maeda
27963c8dce move chars_last_cmp_with_unwrap to its own module 2021-03-18 00:59:45 +09:00
Takayuki Maeda
4d1f2bc565 extract conditions for single_char_pattern into its own module 2021-03-18 00:59:44 +09:00
Takayuki Maeda
7a7fcc0eda extract condition for into_iter_on_ref to its own module 2021-03-18 00:59:43 +09:00
Takayuki Maeda
d380769952 extract conditions for from_iter_instead_of_collect into its own module 2021-03-18 00:58:35 +09:00
Takayuki Maeda
62490c41af extract conditions into modules 2021-03-18 00:51:49 +09:00
Takayuki Maeda
3d9b45df0f move single_char_add_str to its own module 2021-03-18 00:51:18 +09:00
Takayuki Maeda
4843084946 use clippy_utils::ty::is_type_diagnostic_item 2021-03-18 00:51:18 +09:00
Takayuki Maeda
f0f7871920 fmt 2021-03-18 00:51:18 +09:00
Takayuki Maeda
b6597eec0b remove unused arguments 2021-03-18 00:51:18 +09:00
Takayuki Maeda
0c81311bf0 extract a condition into a function. 2021-03-18 00:51:18 +09:00
Takayuki Maeda
f0a101d81d remove a needless variable 2021-03-18 00:51:18 +09:00
Takayuki Maeda
1bec8b6065 use derefs_to_slice in methods/utils.rs 2021-03-18 00:51:16 +09:00
Takayuki Maeda
e578a536c7 move derefs_to_slice to methods/utils.rs 2021-03-18 00:49:50 +09:00
Takayuki Maeda
c07c046b31 refactor string_extend_chars: return when obj type is not string 2021-03-18 00:49:50 +09:00
Takayuki Maeda
058d8c878a move chars_cmp_with_unwrap, chars_last_cmp and chars_next_cmp_with_unwrap to their own modules 2021-03-18 00:49:48 +09:00
Takayuki Maeda
94fb2b58a3 move chars_cmp and chars_next_cmp to its own modules 2021-03-18 00:49:03 +09:00
bors
6595d5571b Auto merge of #6918 - camsteffen:utils-re-export, r=flip1995
Don't re-export `clippy_utils::*`

changelog: none

This should wrap up the utils-related really big changes. I personally don't see any more sub-modules to be added to `clippy_utils`.
2021-03-17 14:42:46 +00:00
Cameron Steffen
565400d1f9 Add clippy_utils::paths imports 2021-03-17 09:31:20 -05:00