bors
07217e3370
Auto merge of #7262 - Jarcho:while_let_on_iter_closure, r=xFrednet,flip1995
...
fix `while_let_on_iterator` suggestion in a closure
fixes : #7249
A future improvement would be to check if the closure is being used as `FnOnce`, in which case the original suggestion would be correct.
changelog: Suggest `&mut iter` inside a closure for `while_let_on_iterator`
2021-06-08 15:52:40 +00:00
flip1995
6c27482115
Merge commit '3ae8faff4d46ad92f194c2a4b941c3152a701b31' into clippyup
2021-06-03 08:41:37 +02:00
Cameron Steffen
21c829e0c8
Simplify collect expr_ty
2021-05-27 20:54:56 -05:00
Cameron Steffen
6c1ba7c1bc
Fix needless_collect with binding shadowing
2021-05-27 20:39:59 -05:00
Cameron Steffen
d39a11cbe1
Remove clippy_utils::consts re-export
2021-05-27 08:52:10 -05:00
Cameron Steffen
f3e77a454a
Fix allow on some statement lints
2021-05-26 22:07:53 -05:00
mbartlett21
6d73777224
Fix same_item_push.rs
2021-05-25 02:03:31 +00:00
mbartlett21
cadad20da1
Add semicolons up to needless_for_each.rs
2021-05-25 00:54:50 +00:00
Jason Newcomb
7db0e4f791
Suggest &mut iter
inside a closure for while_let_on_iterator
2021-05-21 12:27:40 -04:00
flip1995
97705b7ea6
Merge commit '9e3cd88718cd1912a515d26dbd9c4019fd5a9577' into clippyup
2021-05-20 13:07:57 +02:00
bors
10db5a6064
Auto merge of #7188 - mgacek8:issue7164_needless_collect_FP, r=xFrednet,flip1995
...
`needless_collect` enhancements
fixes #7164
changelog: `needless_collect`: For `BTreeMap` and `HashMap` lint only `is_empty`, as `len` might produce different results than iter's `count`
changelog: `needless_collect`: Lint `LinkedList` and `BinaryHeap` in direct usage case as well
2021-05-13 16:35:42 +00:00
Mateusz Gacek
b249290448
needless_collect: use snippet_with_applicability
...
+ small code refactor - using early returns.
2021-05-13 17:09:59 +02:00
Jason Newcomb
4713e25ab0
Cleanup of while_let_on_iterator
2021-05-12 21:51:19 -04:00
Jason Newcomb
daca50a515
Improvements to while_let_on_iterator
...
* Suggest `&mut iter` when the iterator is used after the loop.
* Suggest `&mut iter` when the iterator is a field in a struct.
* Don't lint when the iterator is a field in a struct, and the struct is
used in the loop.
* Lint when the loop is nested in another loop, but suggest `&mut iter`
unless the iterator is from a local declared inside the loop.
2021-05-12 21:49:22 -04:00
Mateusz Gacek
171789eb45
needless_collect: Lint LinkedList
and BinaryHeap
in direct usage.
...
Those two types are supported already when used indirectly.
This commit adds support for direct usage as well.
2021-05-07 09:00:51 -07:00
Mateusz Gacek
59ccc1efb3
needless_collect: replace paths with diag items
...
Related to: #5393
2021-05-07 08:40:48 -07:00
Mateusz Gacek
a21607d9b5
needless_collect: For BTreeMap
and HashMap
lint only is_empty
...
- `len` might produce different results than `count`
- they don't have `contain` but `contains_key` method
2021-05-07 08:39:00 -07:00
flip1995
d605882023
Merge commit 'b71f3405606d49b9735606b479c3415a0ca9810f' into clippyup
2021-05-06 12:20:44 +02:00
Mateusz Gacek
f79a2a3990
needless_collect: use node_type_opt
instead of node_type
...
It may prevent future ICEs.
2021-05-05 04:52:03 -07:00
Mateusz Gacek
1835d8a238
needless_collect: Add BinaryHeap
for indirect usage lint
2021-05-04 12:38:30 -07:00
Mateusz Gacek
b1faaaeb0c
needless_collect: Lint cases with type annotations
2021-05-04 12:38:30 -07:00
Andre Bogus
63425de77d
while_immutable_cond: check condition for mutation
2021-04-29 10:10:58 +02:00
flip1995
ae72f1adb9
Merge commit '7c7683c8efe447b251d6c5ca6cce51233060f6e8' into clippyup
2021-04-27 16:55:11 +02:00
Andre Bogus
efc4c6c957
extend single_element_loop
to match .iter()
2021-04-26 15:58:58 +02:00
flip1995
02bf692169
Merge commit '98e2b9f25b6db4b2680a3d388456d9f95cb28344' into clippyup
2021-04-22 11:31:13 +02:00
Cameron Steffen
b049c88fbe
Eat dogfood
2021-04-16 11:39:31 -05:00
bors
c3ef585328
Auto merge of #6982 - Jarcho:explicit_into_iter_loop_fp, r=flip1995
...
Fix `explicit_into_iter_loop`
fixes : #6900
changelog: Only lint when `into_iter` is an implementation of `IntoIterator`
2021-04-12 09:45:32 +00:00
bors
aecccbc579
Auto merge of #7047 - camsteffen:lang-ctor, r=flip1995
...
Introduce `is_lang_ctor`
changelog: none
Replaces `is_some_ctor` and `is_ok_ctor`. Removes many path usages.
2021-04-12 08:52:10 +00:00
flip1995
f6d1f368db
Merge commit 'b40ea209e7f14c8193ddfc98143967b6a2f4f5c9' into clippyup
2021-04-08 17:50:13 +02:00
flip1995
ffa2b7da29
Merge remote-tracking branch 'upstream/master' into rustup
2021-04-08 17:36:41 +02:00
Cameron Steffen
7468542328
Introduce is_lang_ctor
2021-04-06 15:05:00 -05:00
Jason Newcomb
6b5778eb17
Fix explicit_into_iter_loop
...
Only lint when `into_iter` is an implementation of `IntoIterator`
Minor cleanups
2021-04-06 12:12:32 -04:00
Jason Newcomb
12fce55766
Fix all occurences of needless_borrow
internally
2021-04-06 10:43:47 -04:00
Amanieu d'Antras
879bfeca54
Use AnonConst for asm! constants
2021-04-06 12:35:41 +01: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
Cameron Steffen
6f31ed6c8d
Use DefIdMap and similar aliases
2021-04-03 18:02:49 -05:00
Cameron Steffen
33798bb064
Improve needless_collect output
2021-04-02 10:10:54 -05:00
Cameron Steffen
4356a8f8f7
Remove redundant emit()
2021-04-02 09:38:13 -05:00
Cameron Steffen
a064534b9e
Refactor needless_collect
2021-04-02 08:41:05 -05: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
Cameron Steffen
827d6aaad4
Eat dogfood
2021-03-31 14:06:27 -05:00
Josh Stone
0dddfbf9bf
Use iter::zip in src/tools/clippy/
2021-03-26 09:33:38 -07:00
flip1995
9f6b5de7de
Merge commit '0e87918536b9833bbc6c683d1f9d51ee2bf03ef1' into clippyup
2021-03-25 19:29:11 +01:00
flip1995
1f5f184105
Merge remote-tracking branch 'upstream/master' into rustup
2021-03-25 18:38:13 +01:00
Takayuki Maeda
3b8e85a5dc
fix false positive in manual_flatten
2021-03-25 00:15:21 +09: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
Cameron Steffen
0743e841f0
Don't re-export clippy_utils::*
2021-03-17 09:13:52 -05:00
Cameron Steffen
1c3a3e7dc6
Don't re-export clippy_utils::diagnostics::*
2021-03-15 20:06:01 -05:00
Cameron Steffen
6fc52a63d1
Move some utils to clippy_utils::source module
2021-03-15 15:34:15 -05:00
Cameron Steffen
eb7f8d6089
Move some utils to ty_utils
2021-03-15 13:44:09 -05:00
Roxane
9d5daa6f45
Fix error after rebase
2021-03-15 13:16:18 -04:00
Yoshitomo Nakanishi
93ee80ac3e
Use sym::Iterator instead of paths::ITERATOR
2021-03-13 02:10:54 +09:00
flip1995
a189df12bd
Clippy: HACK! Fix bootstrap error
...
This will be removed in the next sync, once beta is at 1.52. Until then
this hack avoids to put `cfg(bootstrap)` into Clippy.
2021-03-12 15:32:35 +01:00
flip1995
f2f2a005b4
Merge commit '6ed6f1e6a1a8f414ba7e6d9b8222e7e5a1686e42' into clippyup
2021-03-12 15:30:50 +01:00
flip1995
9c1dd0c227
Fix remaining dogfood errors (internal lints)
2021-03-11 10:57:49 +01:00
flip1995
78c740e2f3
Merge remote-tracking branch 'upstream/master' into rustup
2021-03-11 10:37:58 +01:00
Yoshitomo Nakanishi
19c886b407
Remove "for_loop_arg.rs"
2021-03-02 21:09:10 +09:00
Yoshitomo Nakanishi
74bd806b05
Simplify check_for_loop_arg
2021-03-02 18:14:20 +09:00
Yoshitomo Nakanishi
eaf63d6df7
Unify names of lint entry functions in loops to 'check'
2021-03-02 18:14:20 +09:00
nahuakang
845a3a061c
Include loops.rs changes from PR#6698
2021-03-02 18:14:20 +09:00
nahuakang
2229a0839e
Clean up: Rename some files to be consistent with lint names; import lints to each file
2021-03-02 18:14:20 +09:00
nahuakang
ecebfe0c9c
Move check_for_loop_arg back to mod; split into 4 lint files
2021-03-02 18:14:20 +09:00
nahuakang
7cfdef6de1
Move MinifyingSugg into manual_memcpy
2021-03-02 18:14:20 +09:00
nahuakang
7158c944a4
Refactor while let loop to its own module
2021-03-02 18:14:20 +09:00
nahuakang
287a4f8ab1
Refactor empty loop to its own module
2021-03-02 18:14:20 +09:00
nahuakang
d0b657c0b7
Refactor while let on iterator lint to its module; rename for loop explicit counter to explicit counter loop
2021-03-02 18:14:20 +09:00
nahuakang
455d0476b1
Refactor never loop to its own module
2021-03-02 18:14:20 +09:00
nahuakang
5b870e1b36
Move detect_manual_memcpy to its module; split up utils structs
2021-03-02 18:14:20 +09:00
nahuakang
2c1f676bfe
Add detect_same_item_push to its own module
2021-03-02 18:14:20 +09:00
nahuakang
453e6b97ac
Add check_needless_collect to its own module
2021-03-02 18:14:20 +09:00
nahuakang
9520cba554
Add check_infinite_loop to its own module
2021-03-02 18:13:32 +09:00
nahuakang
1e5e541ac5
Refactor check_for_single_element_loop to its own module
2021-03-02 18:13:32 +09:00
nahuakang
71026cad54
Refactor check_for_loop_explicit_counter to its own module
2021-03-02 18:13:32 +09:00
nahuakang
71c9fdf8b1
Refactor check_for_loop_range into its module
2021-03-02 18:13:32 +09:00
nahuakang
6e4663dedf
Refactor check_for_mut_range_bound to its own module
2021-03-02 18:13:32 +09:00
nahuakang
7b0f588b77
Refactor check_for_loop_over_map_kv to its own module
2021-03-02 18:13:32 +09:00
nahuakang
408368a82c
Refactor check_for_loop_arg; rename manual_flatten's lint back to check_manual_flatten
2021-03-02 18:13:32 +09:00
nahuakang
62ac4bd1b2
create loops dir; arrange manual_flatten lint and utils
2021-03-02 18:13:32 +09:00