Commit graph

3313 commits

Author SHA1 Message Date
bors
d2ba777159 Auto merge of #7036 - horacimacias:master, r=giraffate
consider mutability on useless_vec suggestions

fixes #7035

changelog: Now the suggested by `useless_vec` considers mutability to suggest either `&[]`, as before, or `&mut []` if the used reference is mutable.
2021-04-06 13:38:08 +00:00
Horaci Macias
8a50923da4 consider mutability on useless_vec suggestions
https://github.com/rust-lang/rust-clippy/issues/7035
2021-04-06 11:09:52 +02:00
bors
57406c93df Auto merge of #7018 - Y-Nak:same_item_push, r=Manishearth
Don't trigger `same_item_push` if the vec is used in the loop body

fixes #6987
changelog: `same_item_push`: Don't trigger if the `vec` is used in the loop body
2021-04-05 22:57:33 +00:00
bors
25c1ed38aa Auto merge of #7029 - ABouttefeux:master, r=Manishearth
fix `missing_panics_doc` not detecting `assert_eq!` and `assert_ne!`

fixes #6997
changelog: `missing_panics_doc` detects `assert_eq!` and `assert_ne!`

---
searching for `assert_eq!` and `assert_ne!` in `FindPanicUnwrap`
2021-04-05 19:14:55 +00:00
xFrednet
a6f54f5dfd Renaming the lint to branches_sharing_code and fixing typos 2021-04-05 13:35:51 +02:00
xFrednet
7c9e192e05 Test for empty blocks and update from master 2021-04-05 13:35:51 +02:00
xFrednet
617c65baa9 Moving shared_code_in_if_blocks to clippy::complexity and running lintcheck 2021-04-05 13:35:51 +02:00
xFrednet
c74e49eab9 Adapted the lint to use the new SpanlessEq 2021-04-05 13:35:51 +02:00
xFrednet
65ed5a632f Updated code for dogfood 2021-04-05 13:33:45 +02:00
xFrednet
b1d26e544f Improved shared_code_in_if_blocks message and added test stderrs 2021-04-05 13:33:45 +02:00
xFrednet
8efc6acc05 Improved shared_code_in_if_blocks output readability and added tests 2021-04-05 13:33:45 +02:00
xFrednet
469ff96db3 The shared_code_in_if_blocks lint only operats on entire if expr not else ifs 2021-04-05 13:33:45 +02:00
xFrednet
d1df73228a A new lint for shared code in if blocks
* Added expression check for shared_code_in_if_blocks
* Finishing touches for the shared_code_in_if_blocks lint
* Applying PR suggestions
* Update lints yay
* Moved test into subfolder
2021-04-05 13:33:45 +02:00
Aliénore Bouttefeux
8e5dd4b2e9 add test for missing_panic_doc on assert_eq/assert_ne 2021-04-05 09:16:48 +02:00
Jason Newcomb
a00de90ceb
Fix ICE in missing_panics_doc 2021-04-05 00:09:13 -04:00
Cameron Steffen
7014340d57 Fix ICE 2021-04-03 14:17:58 -05:00
Cameron Steffen
33798bb064 Improve needless_collect output 2021-04-02 10:10:54 -05:00
bors
1931db20b1 Auto merge of #6988 - mikerite:fix-6984, r=camsteffen
Fix hidden variant suggestion on single variant

Fixes #6984

changelog: Fix hidden variant suggestion on `match_wildcard_for_single_variants`
2021-04-02 12:42:40 +00:00
Yoshitomo Nakanishi
9f6f001988 same_item_push: Don't trigger same_item_push if the vec is used in the loop body 2021-04-02 16:28:16 +09:00
bors
72eb60a28b Auto merge of #7013 - Y-Nak:fix-needless-paren, r=flip1995
clippy_utils: fix needless parenthesis output from sugg::Sugg::maybe_par

changelog: clippy_utils: fix needless parenthesis output from `sugg::Sugg::maybe_par`

fixes: #6767
2021-04-01 15:09:46 +00:00
bors
92c4fc3cd8 Auto merge of #7011 - Jarcho:redundant_clone_fp, r=flip1995
Fix `redundant_clone` fp

fixes: #5973
fixes: #5595
fixes: #6998

changelog: Fix `redundant_clone` fp  where the cloned value is modified while the clone is in use.
2021-04-01 14:06:04 +00:00
bors
38b1fd0fa7 Auto merge of #7002 - mgacek8:issue6983_wrong_self_convention_inside_trait_impls, r=phansch
wrong_self_convention: fix FP inside trait impl for `to_*` method taking `&self`

fixes #6983
changelog: `wrong_self_convention`: fix FP inside trait impl for `to_*` method taking `&self`
2021-04-01 05:48:16 +00:00
bors
75d73e95a0 Auto merge of #6976 - Jarcho:manual_map_const, r=phansch
Don't lint `manual_map` in const functions

fixes: #6967

changelog: Don't lint `manual_map` in const functions
2021-04-01 05:34:34 +00:00
Yoshitomo Nakanishi
6325fe1f54 clippy_utils: fix needless parenthesis output from sugg::Sugg::maybe_par 2021-04-01 10:40:44 +09:00
Jason Newcomb
aaba9b78a2
Fix redundant_clone fp where the cloned value is modified while the clone is in use. 2021-03-31 15:35:34 -04:00
bors
775ef473d7 Auto merge of #6342 - bbqbaron:issue-6061, r=flip1995
Lint: filter(Option::is_some).map(Option::unwrap)

Fixes #6061

*Please write a short comment explaining your change (or "none" for internal only changes)*
changelog:
* add new lint for filter(Option::is_some).map(Option::unwrap)

First Rust PR, so I'm sure I've violated some idioms. Happy to change anything.

I'm getting one test failure locally -- a stderr diff for `compile_test`. I'm having a hard time seeing how I could be causing it, so I'm tentatively opening this in the hopes that it's an artifact of my local setup against `rustc`. Hoping it can at least still be reviewed in the meantime.

I'm gathering that since this is a method lint, and `.filter(...).map(...)` is already checked, the means of implementation needs to be a little different, so I didn't exactly follow the setup boilerplate. My way of checking for method calls seems a little too direct (ie, "is the second element of the expression literally the path for `Option::is_some`?"), but it seems like that's how some other lints work, so I went with it. I'm assuming we're not concerned about, eg, closures that just end up equivalent to `Option::is_some` by eta reduction.
2021-03-31 16:19:07 +00:00
bors
c1021b806c Auto merge of #6706 - Y-Nak:excessive-for-each, r=camsteffen
New Lint: needless_for_each

resolves: #6543

changelog: Added pedantic lint: `needless_for_each`
2021-03-31 15:59:55 +00:00
Eric Loren
56fbbf7b8f Suggest flatten instead of is_some -> unwrap 2021-03-31 11:35:24 -04:00
Yoshitomo Nakanishi
e61f9782c8 Tweak a suggestion message of needless_for_each 2021-04-01 00:08:59 +09:00
Yoshitomo Nakanishi
bf1e3f7a9f Skip needless_for_each if an input stmt is local 2021-04-01 00:05:42 +09:00
Yoshitomo Nakanishi
f2cc995bcf Remove method_calls 2021-04-01 00:05:42 +09:00
Yoshitomo Nakanishi
527fbbef48 Refactor excessive_for_each 2021-04-01 00:05:42 +09:00
Yoshitomo Nakanishi
90cbbb2da3 Avoid to suggest using label 2021-04-01 00:05:42 +09:00
Yoshitomo Nakanishi
5bb0f16552 Trigger the lint iff exposure's body is ExprKind::Block. 2021-04-01 00:05:42 +09:00
Yoshitomo Nakanishi
5029dc805f New Lint: excessive_for_each 2021-04-01 00:05:42 +09:00
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
Michael Wright
8abab5561c Fix hidden variant suggestion on single variant
Fixes #6984
2021-03-31 07:36:09 +02: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
Jason Newcomb
cc7f1daab2
Don't lint manual_map in const functions 2021-03-30 10:56:08 -04: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
Mateusz Gacek
6966c78be7
wrong_self_convention: fix FP inside trait impl for to_* method
When the `to_*` method takes `&self` and it is a trait implementation,
we don't trigger the lint.
2021-03-29 23:46:03 -07: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