Commit Graph

4318 Commits

Author SHA1 Message Date
bors
3e42c35b72 Auto merge of #6981 - matthiaskrgr:6803_take_2, r=flip1995
disable upper_case_acronyms for pub items - enum edition

Fixes https://github.com/rust-lang/rust-clippy/issues/6803 (again... 😅  )

My previous fix did not work for enums because enum variants were checked separately in the `check_variant` function but it looks like we can't use that because we can't tell if the enum the variants belong to is declared as public or not (it always said `Inherited` for me)

I went and special-cased enums and iterated over all the variants "manually", but only, if the enums is not public.

---

changelog: fix upper_case_acronyms still firing on public enums (#6803)
2021-03-31 15:02:40 +00:00
bors
2e33bf6347 Auto merge of #6938 - Y-Nak:refactor-types, r=flip1995
Refactor types

r? `@flip1995`
This is the last PR to close #6724 🎉
Also, this fixes #6936.

changelog: `vec_box`: Fix FN in `const` or `static`
changelog: `linkedlist`: Fix FN in `const` or `static`
changelog: `option_option`: Fix FN in `const` or `static`
2021-03-31 14:35:48 +00:00
bors
0b76719638 Auto merge of #7007 - Y-Nak:result_unit_err, r=giraffate
result_unit_err: Fix typo

changelog: result_unit_err: fix typo in a diagnostic message

r? `@giraffate`
fixes https://github.com/rust-lang/rust-clippy/pull/6990#discussion_r603292920.
2021-03-31 04:01:15 +00:00
Yoshitomo Nakanishi
45164de59f result_unit_err: Fix typo 2021-03-31 11:18:48 +09:00
bors
4be72b0936 Auto merge of #7001 - ebobrow:non-octal-file-permissions, r=Manishearth
Add non_octal_unix_permissions lint

fixes #6934

changelog: add new lint that checks for non-octal values used to set unix file permissions
2021-03-30 23:23:50 +00:00
Elliot Bobrow
7fcd155712 Add non_octal_unix_permissions lint 2021-03-30 16:04:16 -07:00
bors
44bf60f62d Auto merge of #7004 - Jarcho:manual_map_if_then_else, r=camsteffen
Fix `manual_map` at the end of an if chain

changelog: Fix `manual_map` suggestion at the end of an if chain
2021-03-30 14:03:54 +00:00
Jason Newcomb
fa689f865e
Fix manual_map at the end of an if chain 2021-03-30 09:58:23 -04:00
bors
0552852d9a Auto merge of #7000 - Jarcho:clone_on_copy_fp, r=llogiq
Improve `clone_on_copy`

This also removes the `clone_on_copy_mut` test as the same thing is covered in the `clone_on_copy` test.

changelog: `copy_on_clone` lint on chained method calls taking self by value
changelog: `copy_on_clone` only lint when using the `Clone` trait
changelog: `copy_on_clone` correct suggestion when the cloned value is a macro call.
2021-03-30 05:25:28 +00:00
Jason Newcomb
d2657769a2
Improve clone_on_copy
Lint on `_.clone().method()` when method takes self by value
Set applicability correctly
Correct suggestion when the cloned value is a macro call. e.g. `m!(x).clone()`
Don't lint when not using the `Clone` trait
2021-03-29 16:10:37 -04:00
Yoshitomo Nakanishi
31afdfc12b missing_panics_doc: Ignore usage of debug_assert family 2021-03-29 17:20:04 +09:00
Yoshitomo Nakanishi
1f95940c24 Fix inconsistent test name 2021-03-29 16:25:30 +09:00
bors
c07103b4a2 Auto merge of #6993 - Jarcho:expl_impl_clone, r=llogiq
Improve `expl_impl_clone_on_copy`

fixes: #1254

changelog: Check to see if the generic constraints are the same as if using derive for `expl_impl_clone_on_copy`
2021-03-28 23:30:56 +00:00
Jason Newcomb
879fa5c972
Improve expl_impl_clone_on_copy
Check to see if the generic constraints are the same as if using derive
2021-03-28 07:54:00 -04:00
Matthias Krüger
e006c77d61 redundant_pattern_matching: look inside Refs
look inside refs and detect if let &None = ...

Fixes https://github.com/rust-lang/rust-clippy/issues/5396

changelog:  redundant_pattern_matching: look inside Refs to fix FNs with "if let &None = .. "
2021-03-28 00:04:44 +01:00
bors
dcee00d64b Auto merge of #6980 - Jarcho:len_without_is_empty_sig, r=llogiq
`len_without_is_empty` improvements

fixes: #6958
fixes: #6972

changelog: Check the return type of `len`. Only integral types, or an `Option` or `Result` wrapping one.
changelog: Ensure the return type of `is_empty` matches. e.g. `Option<usize>` -> `Option<bool>`
2021-03-27 13:10:43 +00:00
Jason Newcomb
12985afbca
len_without_is_empty improvements
Check the return type of `len`. Only integral types, or an `Option` or `Result` wrapping one.
Ensure the return type of `is_empty` matches. e.g. `Option<usize>` -> `Option<bool>`
2021-03-27 09:04:44 -04:00
Matthias Krüger
ca7e95501c upper_case_acronyms: add ui and ui-toml tests for private/public enums 2021-03-27 01:08:14 +01:00
bors
6f2a6fe84f Auto merge of #6977 - flip1995:or_patterns_msrv, r=llogiq
Add MSRV options to `unnested_or_patterns`

changelog: [`unnested_or_patterns`] can now be configured with the `msrv` config/attribute.

Fixes #6953
2021-03-26 15:12:50 +00:00
flip1995
1a1adad81d
Add MSRV option to unnested_or_patterns lint 2021-03-26 14:36:09 +01:00
Yoshitomo Nakanishi
bd1201a263 Fix inconsistent test names 2021-03-26 20:19:34 +09:00
Yoshitomo Nakanishi
494bc8a30c Fix FN that types lints don't work with const or static 2021-03-26 20:19:34 +09:00
Jason Newcomb
0ff68bb151
Improve redundant_slicing
Fix bad suggestion when a reborrow might be required
Fix bad suggestion when the value being sliced is a macro call
Don't lint inside of a macro due to the previous context sensitive changes
2021-03-25 22:30:14 -04:00
flip1995
1f5f184105
Merge remote-tracking branch 'upstream/master' into rustup 2021-03-25 18:38:13 +01:00
bors
981ffa7c14 Auto merge of #6959 - ebobrow:iss-6927-fix, r=camsteffen
Check for `.to_string().into_bytes()` in string_lit_to_bytes

fixes #6927

changelog: Add a check for `into_bytes()` to string_lit_to_bytes lint
2021-03-25 03:01:35 +00:00
Elliot Bobrow
e9ebc27525 check for .to_string().into_bytes() in string_lit_to_bytes
apply changes from review
2021-03-24 17:31:20 -07:00
Jason Newcomb
99b8a67198
Fix false positive with new_ret_no_self when returning Self with different generic arguments 2021-03-24 16:22:28 -04:00
Takayuki Maeda
3b8e85a5dc fix false positive in manual_flatten 2021-03-25 00:15:21 +09: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
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
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
mark
d2f0b27f0a clippy: stabilize or_patterns lint 2021-03-19 19:45:42 -05:00
Mateusz Gacek
1f2d01641d wrong_self_convention: Enhance lint message 2021-03-19 20:29:55 +01: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
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
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
bors
8af28840d2 Auto merge of #6805 - matthiaskrgr:uca_nopub_6803, r=flip1995
upper_case_acronyms: don't warn on public items

Fixes #6803

changelog: upper_case_acronyms: ignore public items
2021-03-17 10:53:02 +00:00