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
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
bors
d7a23112e3
Auto merge of #6914 - camsteffen:source-utils, r=Manishearth
...
Move some utils to `clippy_utils::source`
changelog: none
Continues #6907
2021-03-16 00:08:01 +00:00
bors
0929a24d72
Auto merge of #6828 - mgacek8:issue_6758_enhance_wrong_self_convention, r=flip1995
...
wrong_self_convention: fix lint in case of `to_*_mut` method
fixes #6758
changelog: wrong_self_convention: fix lint in case of `to_*_mut` method. When a method starts with `to_` and ends with `_mut`, clippy expects a `&mut self` parameter, otherwise `&self`.
Any feedback is welcome. I was also thinking if shouldn't we treat `to_` the same way as `as_`. Namely to accept `self` taken: `&self` or `&mut self`.
2021-03-15 22:36:57 +00: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
Ben Boeckel
ecf0c76c36
Fix suspicious_map false positives
2021-03-14 16:31:55 -05:00
Yoshitomo Nakanishi
93ee80ac3e
Use sym::Iterator instead of paths::ITERATOR
2021-03-13 02:10:54 +09:00
flip1995
f2f2a005b4
Merge commit '6ed6f1e6a1a8f414ba7e6d9b8222e7e5a1686e42' into clippyup
2021-03-12 15:30:50 +01:00
Mateusz Gacek
2547edb842
wrong_self_convention: fix lint in case of to_*_mut
method
...
When a method starts with `to_` and ends with `_mut`, it should expect a `&mut self` parameter,
otherwise `&self`.
2021-03-11 23:54:50 -08:00
Takayuki Maeda
83a955335f
fix interning-defined-symbol error
2021-03-11 20:18:33 +09:00
Takayuki Maeda
99f860768c
remove unused imports
2021-03-11 20:02:29 +09:00
Takayuki Maeda
c711de28ee
move expect_fun_call to its own module
2021-03-11 19:40:50 +09:00
Takayuki Maeda
f49349bf33
move or_fun_call to its own module
2021-03-11 19:40:24 +09:00
Takayuki Maeda
b0824bf75f
move map_unwrap_or to its own module
2021-03-11 19:40:24 +09:00
Takayuki Maeda
5557596926
move option_map_or_none to its own module
2021-03-11 19:40:24 +09:00
Takayuki Maeda
bbed852f6f
unnecessary_fold to its own module
2021-03-11 19:40:24 +09:00
Takayuki Maeda
78e572c627
move useless_asref to its own module
2021-03-11 19:40:24 +09:00
Takayuki Maeda
caaba8270c
move clone_on_copy to its own module
2021-03-11 19:40:24 +09:00
Takayuki Maeda
171c4c1485
move iter_skip_next to its own module
2021-03-11 19:40:24 +09:00
Takayuki Maeda
24909fabd2
move map_flatten and search_is_some to their own modules
2021-03-11 19:40:24 +09:00
Takayuki Maeda
37ba779a53
move flat_map_identity to its own module
2021-03-11 19:40:24 +09:00
Takayuki Maeda
f430384f04
move filter_map_flat_map to its own module
2021-03-11 19:40:24 +09:00
Takayuki Maeda
6d941616f9
move filter_flat_map to its own module
2021-03-11 19:40:24 +09:00
Takayuki Maeda
2baf043c37
move filter_map_next to its own module
2021-03-11 19:40:24 +09:00
Takayuki Maeda
805dcd12d4
move filter_map_map to its own module
2021-03-11 19:40:24 +09:00
Takayuki Maeda
183daeb961
move filter_map to its own module
2021-03-11 19:40:24 +09:00
Takayuki Maeda
2561b7ea06
move from_iter_insteam_of_collect to its own module
2021-03-11 19:40:24 +09:00
Takayuki Maeda
0c8d143515
move into_iter_on_ref and single_char_pattern to their own modules
2021-03-11 19:40:22 +09:00
Takayuki Maeda
805aa47f43
move single_char_push_string to its own module
2021-03-11 19:40:00 +09:00
Takayuki Maeda
8006dab817
move single_char_insert_string to its own module
2021-03-11 19:40:00 +09:00
Takayuki Maeda
2ade32ddf2
move string_extend_chars and clone_on_ref_ptr to their own module
2021-03-11 19:40:00 +09:00
Takayuki Maeda
b5d809a660
move wrong_self_convention to its own module
2021-03-11 19:40:00 +09:00
Takayuki Maeda
5912ca986c
move iter_nth, iter_nth_zero and iterator_step_by_zero to their own module
2021-03-11 19:39:58 +09:00
Takayuki Maeda
3fe099ba8d
move iter_next_slice to its own module
2021-03-11 19:37:16 +09:00
Takayuki Maeda
db91d9cf9a
move map_collect_result_unit to its own module
2021-03-11 19:37:16 +09:00
Takayuki Maeda
9b0a42b67d
move zst_offset to its own module
2021-03-11 19:37:16 +09:00
Takayuki Maeda
6376da70be
replace lints
and lint
with check
2021-03-11 19:37:16 +09:00
Takayuki Maeda
45ee914df0
move iter_cloned_collect to its own module
2021-03-11 19:37:16 +09:00
Takayuki Maeda
35147d4cf3
move uninit_assumed_init to its own module
2021-03-11 19:37:16 +09:00
Takayuki Maeda
8623b331ee
move filetype_is_file to its own module
2021-03-11 19:37:16 +09:00
Takayuki Maeda
60a053725e
move suspicious_map to its own module
2021-03-11 19:37:16 +09:00
Takayuki Maeda
110dac7f58
move option_as_ref_deref to its own module
2021-03-11 19:37:16 +09:00
Takayuki Maeda
483bac2dc0
move skip_while_next to its own module
2021-03-11 19:37:16 +09:00
Takayuki Maeda
f0f07accbc
move expect_used, filter_next, get_unwrap, ok_expect and unwrap_used to their own modules
2021-03-11 19:37:13 +09: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
Takayuki Nakata
e0f982bb3e
Improve doc on map_flatten
2021-03-10 00:02:24 +09:00
bors
eb04beb005
Auto merge of #6791 - TaKO8Ki:iter-count, r=matthiaskrgr
...
New lint: `iter_count`
This pull request adds a new lint named `iter_count`.
---
closes https://github.com/rust-lang/rust-clippy/issues/6262
changelog: new lint `iter_count`
2021-03-02 11:31:43 +00:00
Cameron Steffen
7984e60d9e
Use diagnostic items in into_iter_collections
2021-03-01 09:04:11 -06:00
Matthias Krüger
e00b1cc73a
change some lint messages and remove old entries from the ignorelist
2021-02-28 02:22:05 +01:00
Matthias Krüger
8eb2bd13d0
update the lint messages and tests
2021-02-28 02:22:05 +01:00
Takayuki Maeda
6041365f4b
remove pub(crate)
2021-02-27 14:16:02 +09:00
Takayuki Maeda
c297174adf
export derefs_to_slice
from methods module
2021-02-27 14:16:02 +09:00
Takayuki Maeda
77907e6dab
receive iter method name as an argument
2021-02-27 14:16:02 +09:00
Takayuki Maeda
8bae279706
remove if_chain
2021-02-27 14:16:02 +09:00
Takayuki Maeda
cc2b00055c
return when the ty doesn't have len()
2021-02-27 14:16:02 +09:00
Takayuki Maeda
9958af4229
move lints()
to iter_count.rs
2021-02-27 14:16:02 +09:00
Takayuki Maeda
204b27937c
lint for into_iter().count()
2021-02-27 14:16:02 +09:00
Takayuki Maeda
51617b83a1
new lint: iter_count
2021-02-27 14:15:57 +09:00
Cameron Steffen
2b3a731e1c
Add missing diagnostic item Symbols
2021-02-26 22:12:36 -06:00
Andrea Nall
3d3cfd3754
added new lint implicit_clone
2021-02-26 19:13:47 -06:00
bors
5c6cd87b94
Auto merge of #6790 - mgacek8:issue_6748, r=Manishearth
...
or_fun_call: fix suggestion for `or_insert(vec![])`
fixes #6748
changelog: or_fun_call: fix suggestion for `or_insert(vec![])` on `std::collections::hash_map::Entry` or `std::collections::btree_map::Entry`
2021-02-25 15:05:06 +00:00
Mateusz Gacek
2f0e9f7d3a
or_fun_call: fix suggestion for or_insert(vec![])
...
Applies for `std::collections::hash_map::Entry` and `std::collections::btree_map::Entry`
Example:
Previously, for the following code:
`let _ = hash_map.entry("test".to_owned()).or_insert(vec![]);`
clippy would suggest to use:
`or_insert_with(vec![])`, which causes a compiler error (E0277).
Now clippy suggests:
`or_insert_with(Vec::new)`
2021-02-25 14:23:38 +01:00
bors
a149f61244
Auto merge of #81993 - flip1995:clippyup, r=Manishearth
...
Update Clippy
Biweekly Clippy update
r? `@Manishearth`
2021-02-17 22:37:42 +00:00
Camille GILLOT
dbe7609414
Only store a LocalDefId in hir::ImplItem.
2021-02-15 19:32:29 +01:00
Camille GILLOT
fc9bc33bba
Only store a LocalDefId in hir::TraitItem.
2021-02-15 19:32:28 +01:00
Camille GILLOT
2dc65397ee
Only store a LocalDefId in hir::Item.
...
Items are guaranteed to be HIR owner.
2021-02-15 19:32:10 +01:00
flip1995
8b9f4a0d34
Merge commit '70c0f90453701e7d6d9b99aaa1fc6a765937b736' into clippyup
2021-02-11 15:04:38 +01:00
flip1995
00f9981f5c
Merge remote-tracking branch 'upstream/master' into rustup
2021-02-11 14:36:52 +01:00
bors
3784cdf98e
Auto merge of #6657 - ThibsG:FromIterParens, r=llogiq
...
Fix suggestions that need parens in `from_iter_instead_of_collect` lint
Fixes broken suggestions that need parens (i.e.: range)
Fixes : #6648
changelog: none
2021-02-10 19:37:27 +00:00
alpaca-tc
94b8f23baf
Fix typo
2021-02-11 00:45:28 +09:00
bors
b5e4389f53
Auto merge of #6695 - TaKO8Ki:add-bytes-nth, r=phansch
...
New lint: `bytes_nth`
This pull request adds a new lint named `bytes_nth`.
---
closes: https://github.com/rust-lang/rust-clippy/issues/6391
changelog: Added a new lint: `bytes_nth`
2021-02-10 13:54:33 +00:00
Takayuki Maeda
932cc085e6
Update clippy_lints/src/methods/bytes_nth.rs
...
Co-authored-by: Phil Hansch <dev@phansch.net>
2021-02-10 15:49:07 +09:00
ThibsG
b932587c5d
Add better turbofish extractor
2021-02-09 17:43:49 +01:00
Ömer Sinan Ağacan
34b373d309
Rename HIR UnOp variants
...
This renames the variants in HIR UnOp from
enum UnOp {
UnDeref,
UnNot,
UnNeg,
}
to
enum UnOp {
Deref,
Not,
Neg,
}
Motivations:
- This is more consistent with the rest of the code base where most enum
variants don't have a prefix.
- These variants are never used without the `UnOp` prefix so the extra
`Un` prefix doesn't help with readability. E.g. we don't have any
`UnDeref`s in the code, we only have `UnOp::UnDeref`.
- MIR `UnOp` type variants don't have a prefix so this is more
consistent with MIR types.
- "un" prefix reads like "inverse" or "reverse", so as a beginner in
rustc code base when I see "UnDeref" what comes to my mind is
something like "&*" instead of just "*".
2021-02-09 11:39:20 +03:00
Cameron Steffen
37555f8f73
Use path_to_local_id
2021-02-08 09:50:13 -06:00
Takayuki Maeda
1c3033d5cf
add a new lint bytes_nth
2021-02-08 01:34:59 +09:00
bors
ad9ceeebdc
Auto merge of #6685 - magurotuna:filter_map_identity, r=phansch
...
Add new lint `filter_map_identity`
<!--
Thank you for making Clippy better!
We're collecting our changelog from pull request descriptions.
If your PR only includes internal changes, you can just write
`changelog: none`. Otherwise, please write a short comment
explaining your change.
If your PR fixes an issue, you can add "fixes #issue_number" into this
PR description. This way the issue will be automatically closed when
your PR is merged.
If you added a new lint, here's a checklist for things that will be
checked during review or continuous integration.
- \[x] Followed [lint naming conventions][lint_naming]
- \[x] Added passing UI tests (including committed `.stderr` file)
- \[x] `cargo test` passes locally
- \[x] Executed `cargo dev update_lints`
- \[x] Added lint documentation
- \[x] Run `cargo dev fmt`
[lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints
Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.
Delete this line and everything above before opening your PR.
-->
This commit adds a new lint named filter_map_identity.
This lint is the same as `flat_map_identity` except that it checks for the usage of `filter_map`.
---
Closes #6643
changelog: Added a new lint: `filter_map_identity`
2021-02-07 09:55:32 +00:00
Yusuke Tanaka
a60c143fe0
Add new lint filter_map_identity
...
This commit adds a new lint named `filter_map_identity`. This lint is
the same as `flat_map_identity` except that it checks for `filter_map`.
Closes #6643
2021-02-06 18:03:14 +09:00
Cameron Steffen
56f7fbb4ae
Cleanup path to local checks
2021-02-05 10:24:32 -06:00
ThibsG
233fe11ce9
Set turbofish for every sugg and add more test cases
2021-02-04 19:08:08 +01:00
Mara Bos
9f7f8b71a6
Suggest panic!("{}", ..) instead of panic!(..) clippy::expect_fun_call.
2021-02-03 23:15:51 +01:00
ThibsG
7825bf36d8
Fix suggestions that need parens
2021-02-01 20:03:40 +01:00
flip1995
ac912be984
Merge commit '95c0459217d1661edfa794c8bb122452b92fb485' into clippyup
2021-01-30 18:06:34 +01:00
flip1995
e2859437f9
Merge remote-tracking branch 'upstream/master' into rustup
2021-01-30 15:51:16 +01:00
Cameron Steffen
82bab19a01
Deprecate find_map lint
2021-01-21 18:19:55 -06:00
Cameron Steffen
a752d31e0a
Replace find_map with manual_find_map
2021-01-21 18:18:21 -06:00
Cameron Steffen
c92bdc4dbb
Split filter_map into manual_filter_map
2021-01-21 18:18:18 -06:00
Cameron Steffen
e89ad4ba71
Fix comment
2021-01-21 18:17:25 -06:00
bors
d71dea40cf
Auto merge of #6577 - nahuakang:inspect_then_for_each, r=flip1995
...
New Lint: inspect_then_for_each
**Work In Progress**
This PR addresses [Issue 5209](https://github.com/rust-lang/rust-clippy/issues/5209 ) and adds a new lint called `inspect_then_for_each`.
Current seek some guidance.
If you added a new lint, here's a checklist for things that will be
checked during review or continuous integration.
- \[x] Followed [lint naming conventions][lint_naming]
- \[x] Added passing UI tests (including committed `.stderr` file)
- \[x] `cargo test` passes locally
- \[x] Executed `cargo dev update_lints`
- \[x] Added lint documentation
- \[x] Run `cargo dev fmt`
[lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints
---
changelog: Add [`inspect_for_each`] lint for the use of `inspect().for_each()` on `Iterators`.
2021-01-19 13:12:39 +00:00
nahuakang
3269070261
Create new lint for the usage of inspect for each.
2021-01-19 11:30:20 +01:00
Ashley Mannix
9009f8f031
Rollup merge of #81038 - flip1995:clippyup, r=Manishearth
...
Update Clippy
Biweekly Clippy update
r? ``@Manishearth``
2021-01-18 21:53:22 +10:00
Jack Huey
e73b8dcbca
Review changes
2021-01-16 18:56:37 -05:00
flip1995
488153ff2f
Merge commit '953f024793dab92745fee9cd2c4dee6a60451771' into clippyup
2021-01-15 10:56:44 +01:00
flip1995
9bd037d0b5
Merge remote-tracking branch 'upstream/master' into rustup
2021-01-15 10:39:53 +01:00
bors
7b3af4145b
Auto merge of #79328 - c410-f3r:hir-if, r=matthewjasper
...
Reintroduce hir::ExprKind::If
Basically copied and paste #59288/https://github.com/rust-lang/rust-clippy/pull/4080 with some modifications.
The vast majority of tests were fixed and now there are only a few remaining. Since I am still unable to figure out the missing pieces, any help with the following list is welcome.
- [ ] **Unnecessary `typeck` exception**: [Cheated on this one to make CI green.](https://github.com/rust-lang/rust/pull/79328/files#diff-3faee9ba23fc54a12b7c43364ba81f8c5660045c7e1d7989a02a0cee1c5b2051 )
- [x] **Incorrect span**: [Span should reference `then` and `else` separately.](https://github.com/rust-lang/rust/pull/79328/files#diff-cf2c46e82222ee4b1037a68fff8a1af3c4f1de7a6b3fd798aacbf3c0475abe3d )
- [x] **New note regarding `assert!`**: [Modified but not "wrong". Maybe can be a good thing?](https://github.com/rust-lang/rust/pull/79328/files#diff-9e0d7c89ed0224e2b62060c957177c27db43c30dfe3c2974cb6b5091cda9cfb5 )
- [x] **Inverted report location**: [Modified but not "wrong". Locations were inverted.](https://github.com/rust-lang/rust/pull/79328/files#diff-f637ce7c1f68d523a165aa9651765df05e36c4d7d279194b1a6b28b48a323691 )
- [x] **`src/test/ui/point-to-type-err-cause-on-impl-trait-return.rs` has weird errors**: [Not sure why this is happening.](https://github.com/rust-lang/rust/pull/79328/files#diff-c823c09660f5b112f95e97e8ff71f1797b6c7f37dbb3d16f8e98bbaea8072e95 )
- [x] **Missing diagnostic**: [???](https://github.com/rust-lang/rust/pull/79328/files#diff-6b8ab09360d725ba4513933827f9796b42ff9522b0690f80b76de067143af2fc )
2021-01-14 14:41:58 +00:00
Joshua Nelson
dfb41f4797
Separate out a hir::Impl
struct
...
This makes it possible to pass the `Impl` directly to functions, instead
of having to pass each of the many fields one at a time. It also
simplifies matches in many cases.
2021-01-12 20:32:33 -05:00
Cameron Steffen
7871ebaab9
Fix symbol string comparison dogfood
2021-01-08 14:50:00 -06:00
Caio
7d42172899
Reintroduce hir::ExprKind::If
2021-01-07 18:54:12 -03:00
flip1995
f03edfd7a1
Merge commit '4911ab124c481430672a3833b37075e6435ec34d' into clippyup
2020-12-20 17:19:49 +01:00
bors
9f9e9f7e52
Auto merge of #6316 - ThibsG:WrongSelfConventionTraitDef, r=ebroto
...
Lint also in trait def for `wrong_self_convention`
Extends `wrong_self_convention` to lint also in trait definition.
By the way, I think the `wrong_pub_self_convention` [example](dd826b4626/clippy_lints/src/methods/mod.rs (L197)
) is misleading.
On [playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=32615ab3f6009e7e42cc3754be0ca17f ), it fires `wrong_self_convention`, so the example (or the lint maybe?) needs to be reworked.
The difference with `wrong_self_convention` [example](dd826b4626/clippy_lints/src/methods/mod.rs (L172)
) is mainly the `pub` keyword on the method `as_str`, but the lint doesn't use the function visibility as condition to choose which lint to fire (in fact it uses the visibility of the impl item).
fixes : #6307
changelog: Lint `wrong_self_convention` lint in trait def also
2020-12-19 21:39:19 +00:00
bors
142f0f5eda
Auto merge of #6448 - mikerite:interning_defined_symbol, r=Manishearth
...
New internal lint: Interning defined symbol
New internal lint: interning_defined_symbol
changelog: none
2020-12-16 08:18:38 +00:00
bors
1df2e38219
Auto merge of #6443 - matthiaskrgr:clone_on_copy_type, r=ebroto
...
clone_on_copy: show the type in the lint message
changelog: clone_on_copy: show the type in the lint message
2020-12-13 16:47:33 +00:00
Michael Wright
a6aa0acbea
Fix dogfood errors
2020-12-13 06:32:41 +02:00
Matthias Krüger
b2cb6ffbe3
clone_on_copy: show the type in the lint message
...
changelog: clone_on_copy: show the type in the lint message
2020-12-12 01:23:28 +01:00
Matthias Krüger
0b145d688b
clone_double_ref: print reference type in lint message
...
changelog: clone_double_ref: print the type of the reference in lint message
2020-12-12 01:09:30 +01:00
suyash458
a7cfffef26
add MSRV to more lints specified in #6097
...
update tests
2020-12-11 11:00:03 +05:30
ThibsG
4af9382bec
Common function to lint wrong self convention from impl and trait def
2020-12-10 17:08:42 +01:00
ThibsG
a6bb9276f7
Lint wrong self convention in trait also
2020-12-10 17:08:42 +01: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
flip1995
8eca423ea1
Merge commit 'c1664c50b27a51f7a78c93ba65558e7c33eabee6' into clippyup
2020-12-06 15:01:03 +01: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
Hirochika Matsumoto
2c26cb14db
Move contains_return
to utils/mod.rs
2020-11-29 02:18:05 +09:00
Hirochika Matsumoto
f7b2098e1c
Fix a false positive in unnecessary_wraps
2020-11-29 01:55:15 +09: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
flip1995
d3d2018ead
Merge commit '3e7c6dec244539970b593824334876f8b6ed0b18' into clippyup
2020-11-23 13:51:04 +01:00
Carol (Nichols || Goulding)
034244f108
Small grammar, punctuation, and code style improvements to docs
2020-11-22 10:17:34 -05:00
bors
44d944586c
Auto merge of #6070 - matsujika:unnecessary_wrap, r=flip1995
...
Add new lint `unnecessary_wrap`
Fixes #5969
changelog: New lint [`unnecessary_wraps`]
2020-11-17 20:28:32 +00:00
bors
a8cafc6196
Auto merge of #6338 - flip1995:rustup, r=flip1995
...
Rustup
r? `@ghost`
changelog: none
2020-11-17 17:10:04 +00:00
Hirochika Matsumoto
df0d565e59
Move find_all_ret_expressions
into utils
2020-11-18 01:28:37 +09:00
Bastian Kauschke
3567ea546f
clippy: fold by value
2020-11-16 22:42:09 +01:00
rsulli55
56d252c53d
Update clippy_lints/src/methods/mod.rs
...
Co-authored-by: Philipp Krones <hello@philkrones.com>
2020-11-10 23:18:48 -07:00
Ryan Sullivant
fd303132a2
Cleaned up message and suggestion for lint_search_is_some
2020-11-10 23:18:48 -07:00
Ryan Sullivant
ee1b959054
Added period back to lint search_is_some
and ran
...
`update-all-references.sh`
2020-11-10 23:18:47 -07:00
rsulli55
fb74b4802e
Remove borrow
...
Co-authored-by: Philipp Krones <hello@philkrones.com>
2020-11-10 23:18:47 -07:00
rsulli55
e9612f3eca
Remove to_string
on msg
...
Co-authored-by: Philipp Krones <hello@philkrones.com>
2020-11-10 23:18:47 -07:00
Ryan Sullivant
a1cf2d334d
Added a lint as suggested in 6010 which recommends using contains()
...
instead of `find()` follows by `is_some()` on strings
Update clippy_lints/src/find_is_some_on_strs.rs
Co-authored-by: Takayuki Nakata <f.seasons017@gmail.com>
Update clippy_lints/src/methods/mod.rs
Co-authored-by: Philipp Krones <hello@philkrones.com>
2020-11-10 23:18:47 -07:00
Cameron Steffen
9cab08465b
Fix or_fun_call for index operator
2020-11-08 14:49:42 -06:00
Cameron Steffen
b0994064b0
Make KNOW_TYPES static
2020-11-08 14:34:06 -06:00
bors
c015622568
Auto merge of #6304 - matthiaskrgr:crash_6302, r=llogiq
...
FROM_ITER_INSTEAD_OF_COLLECT: avoid unwrapping unconditionally
Fixes #6302
changelog: fix unwrap of None when checking libcore with clippy
2020-11-07 18:10:35 +00:00
bors
4bbef42c48
Auto merge of #6272 - camsteffen:unnecesary-lazy-eval-type, r=llogiq
...
Fix unnecessary_lazy_eval suggestion applicability
changelog: Fix unnecessary_lazy_eval suggestion applicability when breaking type inference
Fixes #6240
2020-11-07 10:01:46 +00:00
Matthias Krüger
5253595b3b
FROM_ITER_INSTEAD_OF_COLLECT: avoid unwrapping unconditionally
...
Fixes #6302
2020-11-06 19:34:34 +01:00
flip1995
34244190d4
Merge commit 'b20d4c155d2fe3a8391f86dcf9a8c49e17188703' into clippyup
2020-11-05 14:29:48 +01:00
bors
c2cf40cdcd
Auto merge of #6284 - camsteffen:rustc-sym, r=flip1995
...
Use const sym where possible
I ran a regex search and replace to use const `sym` values where possible. This should give some performance boost by avoiding string interning at runtime.
Con: It is not as consistent as always using `sym!`.
I also changed an internal lint to suggest using `sym::{}`, making an assumption that this will always work for diagnostic items.
changelog: none
2020-11-04 09:22:54 +00:00
bors
a2bf404d34
Auto merge of #6101 - pitiK3U:from_iter_instead_of_collect, r=flip1995
...
Add lint: from_iter_instead_of_collect
Fixes #5679
This implements lint for `::from_iter()` from #5679 not the general issue (`std::ops::Add::add`, etc.).
This lint checks if expression is function call with `from_iter` name and if it's implementation of the `std::iter::FromIterator` trait.
changelog: Introduce from_iter_instead_of_collect lint
2020-11-03 15:59:16 +00:00
Piti the little Light
52d1ea3c9a
Fix: Don't show lint for types that doesn't implement Iterator
2020-11-03 16:44:24 +01:00
Piti the little Light
f359fb872b
Improve error message
2020-11-03 16:44:24 +01:00
Piti the little Light
abdb7aeb55
Remove backticks
2020-11-03 16:44:24 +01:00
Piti the little Light
854f2cef06
Run cargo dev fmt
2020-11-03 16:44:24 +01:00
Piti the little Light
8906040445
Improvements from PR feedback
2020-11-03 16:44:21 +01:00
Piti the little Light
8a5d78b71a
Fix from_iter_instead_of_collect
lint crashing on exprs without path segment
2020-11-03 16:42:30 +01:00
Piti the little Light
315bab0ea1
Add from_iter_instead_of_collect
lint implementation
2020-11-03 16:42:28 +01:00
Cameron Steffen
a6611de75a
Include bindings as machine applicable
2020-11-02 12:57:37 -06:00
Cameron Steffen
22cc77a232
Use const rustc sym where possible
2020-11-02 11:46:37 -06:00
Eduardo Broto
f8ac1f99ef
Address suggestions in PR review
2020-10-30 23:47:22 +01:00
Eduardo Broto
d958269fe5
Rename single_char_push_str to single_char_add_str
2020-10-30 23:29:44 +01:00
Matthias Krüger
c1eb8ceede
get_hint_if_single_char_arg: fix bug where multi-char letters are not detected properly
2020-10-30 23:29:44 +01:00
Matthias Krüger
c6412aeebc
handle macros returning Strings in single_char_push_str and single_char_insert_str
2020-10-30 23:29:38 +01:00
Matthias Krüger
2350ee75b2
single_char_push_str lint using insert_str() on single-char literals and suggest insert()
...
changelog: single_char_push_str: lint using string.insert_str() with single char literals and suggests string.insert() with a char
Fixes #6026
2020-10-30 23:28:17 +01:00
bors
7387b87bb9
Auto merge of #6197 - ThibsG:ImproveFilterNext, r=ebroto
...
Improve suggestions for several lints
This PR is a follow-up of this [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/filter_next.20lint ).
It unifies placeholders for `methods` module and improves several suggestions for `filter_next`, `filter_map_next` and `map_unwrap_or` lints.
changelog: none
2020-10-30 21:58:09 +00:00
Cameron Steffen
c0d1002d93
Fix unnecessary_lazy_eval suggestion applicability
...
Fixes #6240
2020-10-30 16:10:01 -05:00
bors
c57d8ae515
Auto merge of #6227 - HMPerson1:collect_map, r=phansch
...
Add lint for replacing `.map().collect()` with `.try_for_each()`
Fixes #6208
changelog: Add `map_collect_result_unit`
2020-10-29 15:34:15 +00:00
Nathan Whitaker
a1bb10e9b8
Remove lint from clippy
2020-10-26 18:19:48 -04:00
ThibsG
3fec6f568d
Improve some suggestions for filter_map_next
, filter_next
and map_unwrap_or
lints
2020-10-26 11:02:07 +01:00
ThibsG
2911d9c7de
Use better placeholders for some methods lint messages
2020-10-26 11:02:07 +01:00
HMPerson1
f0cf3bdca1
Add lint for replacing .map().collect()
with .try_for_each()
2020-10-25 21:20:57 -04:00
flip1995
fbf2430f02
Merge commit '2f6439ae6a6803d030cceb3ee14c9150e91b328b' into clippyup
2020-10-09 12:45:29 +02:00
bors
14e72696a6
Auto merge of #6124 - pickfire:patch-1, r=flip1995
...
Use more concrete explanation for methods
*Please keep the line below*
changelog: none
2020-10-06 23:22:28 +00:00
flip1995
b05aeaa9bc
Run fmt
2020-10-06 23:32:38 +02:00
Ivan Tham
7021d70d2e
Use more concrete explanation for methods
...
Show some code rather than "a single method call".
2020-10-06 23:58:32 +08:00
Matthew Jasper
adb7fc6283
Fix tools
2020-10-06 11:19:30 +01:00
flip1995
d1f9cad102
Merge commit 'e636b88aa180e8cab9e28802aac90adbc984234d' into clippyup
2020-09-24 14:49:22 +02:00
rail
ce06472246
replace walk_ptrs_ty
with peel_refs
2020-09-17 10:11:59 +12:00
bors
06f1902878
Auto merge of #5937 - montrivo:option_if_let_else, r=flip1995
...
option_if_let_else - distinguish pure from impure else expressions
Addresses partially #5821 .
changelog: improve the lint `option_if_let_else`. Suggest `map_or` or `map_or_else` based on the else expression purity.
2020-09-16 19:36:49 +00:00
Tim Nielens
6ba36bcfd3
option_if_let_else - distinguish pure from impure else expressions
2020-09-16 01:30:50 +02:00
Eduardo Broto
332c2dcb4d
Fix dogfood after MatchTypeOnDiagItem
2020-09-15 10:29:53 +02:00
Matthias Krüger
2487f8f461
into_iter_on_ref: rephrase lint message: will not move the x -> will not consume the x
...
imo that's a bit clearer.
2020-09-11 16:52:25 +02:00
flip1995
a12828a80a
Merge commit '5034d47f721ff4c3a3ff2aca9ef2ef3e1d067f9f' into clippyup
2020-09-10 17:47:07 +02:00
Eduardo Broto
23646e6583
Merge remote-tracking branch 'upstream/master' into sync-from-rust
2020-09-04 23:27:01 +02:00
LeSeulArtichaut
28f9b84042
ty.kind
-> ty.kind()
in rustdoc and clippy
2020-09-04 18:27:33 +02:00
Camelid
17b2ba5ded
Syntax-highlight single_char_push_str
lint
2020-08-30 11:29:17 -07:00
flip1995
282c59820b
Merge commit '3d0b0e66afdfaa519d8855b338b35b4605775945' into clippyup
2020-08-28 18:43:25 +02:00
Thibaud
73b1ee1a61
Update clippy_lints/src/methods/mod.rs
...
Co-authored-by: Eduardo Broto <ebroto@tutanota.com>
2020-08-28 09:33:05 +02:00
ThibsG
504612622f
Merge logic of looking for Self
type
2020-08-27 18:31:31 +02:00
ThibsG
3cb75c2e5c
Remove expansion restriction + fix doc and tests naming
2020-08-27 18:25:38 +02:00
ThibsG
2a3ee5fa85
Fix FP in new_ret_no_self
: trigger in trait def instead of impl block
2020-08-27 18:25:38 +02:00
Thibaud
370fc45a0a
Update clippy_lints/src/methods/mod.rs
...
Co-authored-by: Eduardo Broto <ebroto@tutanota.com>
2020-08-25 22:20:35 +02:00
ThibsG
3d820f71fe
Fix incorrect suggestion when clone_on_ref_ptr
is triggered in macros
2020-08-24 14:05:49 +02:00
Michael Wright
11efd75aeb
Fix false negative in option_as_ref_deref
2020-08-21 07:23:04 +02:00
flip1995
c680602005
Merge remote-tracking branch 'upstream/master' into rustup
2020-08-18 19:50:23 +02:00
David Wood
f13d2bfd9b
clippy: support QPath::LangItem
...
This commit updates clippy with the introduction of `QPath::LangItem` so
that it still compiles.
Signed-off-by: David Wood <david@davidtw.co>
2020-08-17 13:55:05 +01:00
Dániel Buga
fc1e07e0c1
Rename lint to use plural form
2020-08-16 22:16:39 +02:00
Dániel Buga
b7ee8685ac
Fix dogfooding test errors
2020-08-16 21:04:02 +02:00
Dániel Buga
3b52d7f780
run cargo dev fmt
2020-08-16 20:51:16 +02:00
Dániel Buga
8a14c11536
Cleanup, explain return value
2020-08-16 20:50:30 +02:00
Dániel Buga
d71b418ac5
Moved to submodule, don't trigger if map_unwrap_or does
2020-08-16 20:47:50 +02:00
Dániel Buga
9c41822d34
Apply suggested change
...
Co-authored-by: Philipp Krones <hello@philkrones.com>
2020-08-16 20:27:54 +02:00
Dániel Buga
94cf90e5a5
Apply suggested change
...
Co-authored-by: Philipp Krones <hello@philkrones.com>
2020-08-16 20:27:54 +02:00
Dániel Buga
a7083eea1c
Removed the extra lifetime parameter
2020-08-16 20:27:54 +02:00
Dániel Buga
75637c1eda
Catch function calls in argument lists, add tests that tuples don't get linted
2020-08-16 20:27:54 +02:00
Dániel Buga
a7cc5d4068
Also simplify if the closure body is an index expression
2020-08-16 20:27:54 +02:00
Dániel Buga
848af39310
Add note to or_fun_call
, list checked methods
2020-08-16 20:27:54 +02:00
Dániel Buga
a3ea65c2d9
Implement new lint
2020-08-16 20:27:22 +02:00
bors
3bd98895f1
Auto merge of #5725 - montrivo:should-impl-trait, r=flip1995
...
should_impl_trait - ignore methods with lifetime params
Fixes : #5617
changelog: don't lint should_implement_trait when an `Iterator::next` case has explicit parameters
2020-08-16 17:51:18 +00:00
Christoph Walcher
b381ade179
elide lifetimes
2020-08-15 01:40:55 +02:00
Christoph Walcher
ae56e988a2
Merge lint with single_char_pattern
2020-08-15 01:40:55 +02:00
Erich Gubler
48a142559d
docs: typo in temporary_cstring_as_ptr
: s/point/&s
2020-08-13 13:52:21 -06:00
flip1995
027780ca2c
Merge commit '09bd400243ed6f7059fedc0c1623aae3792521d6' into clippyup
2020-08-11 17:50:45 +02:00
Matthias Krüger
6af297f80e
iter-next-slice: make lint adhere to lint message convention
2020-08-11 15:15:26 +02:00
Tim Nielens
f9ba829f67
should_impl_trait - self linting
2020-08-09 16:09:08 +02:00
Tim Nielens
166c520e9a
should_impl_trait - pr comments
2020-08-09 15:10:00 +02:00
Tim Nielens
7cc1a2ed87
should_implement_trait - filter on explicit lifetime param only
2020-08-09 15:10:00 +02:00
Tim Nielens
e6b2254f9e
should_implement_trait - pr remarks
2020-08-09 15:10:00 +02:00
Tim Nielens
2bc0ecd44b
should_implement_trait - add test cases for every checked trait method
2020-08-09 15:10:00 +02:00
Tim Nielens
a77e881ec9
should_impl_trait - ignore methods with lifetime params
2020-08-09 15:10:00 +02:00
bors
2ceb8c6c2d
Auto merge of #5865 - camsteffen:unnecessary-fold-known-probs, r=Manishearth
...
Remove obsolete known problems unnecessary_fold
The known problems looks to be obsolete since NLL is stable.
changelog: none
2020-08-04 23:09:35 +00:00
Cameron Steffen
0ccdf2913a
Remove obsolete known problems unnecessary_fold
2020-08-03 16:23:20 -05:00
Dmitry Murzin
d4ba561aaf
Review fixes
2020-07-31 00:28:21 +03:00
Dmitry Murzin
a427c99f3d
Handle mapping to Option in map_flatten
lint
2020-07-30 23:23:33 +03:00
bors
2e0f8b6cc6
Auto merge of #5843 - dima74:iter_skip_next.add-suggestion, r=phansch
...
Add suggestion for `iter_skip_next` lint
changelog: Add suggestion for [`iter_skip_next`](https://rust-lang.github.io/rust-clippy/master/index.html#iter_skip_next ) lint
2020-07-29 06:10:55 +00:00
Bastian Kauschke
6ce37fab95
introduce PredicateAtom
2020-07-27 21:07:37 +02:00
Bastian Kauschke
88787083f4
this might be unqualified, but at least it's now quantified
2020-07-27 21:06:36 +02:00
Bastian Kauschke
dfa1af2059
clippy
2020-07-27 21:06:36 +02:00
flip1995
d164ab65f7
Merge commit 'da5a6fb1b65ec6581a67e942a3850f6bc15a552c' into clippyup
2020-07-26 21:07:07 +02:00
Dmitry Murzin
b375f1dd20
Add suggestion for iter_skip_next
lint
2020-07-25 17:11:55 +03:00
flip1995
0f501ac1db
Merge remote-tracking branch 'upstream/master' into rustup
2020-07-18 15:09:58 +02:00
Valentin Lazureanu
5a20489c5c
Rename TypeckTables to TypeckResults.
2020-07-17 08:47:04 +00:00
Brian Warner
e83b3eb993
formatting nits
2020-07-14 09:20:19 -07:00
flip1995
6f25adbd5a
Merge commit '2ca58e7dda4a9eb142599638c59dc04d15961175' into clippyup
2020-07-14 14:59:59 +02:00
Brian Warner
201999ccfd
improve advice in iter_nth_zero
...
The "use .next()" replacement advice is on the last line of the code snippet,
where it is vulnerable to truncation. Display that advice at the beginning
instead.
closes #5783
2020-07-13 10:59:45 -07:00
robojumper
1740dda763
fix match_like_matches_macro in clippy
2020-07-06 18:35:58 +02:00
JarredAllen
6ce981225b
Clean existing lint code to match new lint
2020-07-03 16:51:44 -07:00
JarredAllen
5150277a4f
Used clippy to clean itself
2020-07-03 16:50:45 -07:00
flip1995
a7c58e66d4
Merge remote-tracking branch 'upstream/master' into rustup
2020-07-03 12:50:41 +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
590e07bbc2
rustc_lint: avoid using TypeckTables::empty for LateContext.
2020-07-02 16:51:04 +03:00
flip1995
1e861a2663
Merge remote-tracking branch 'upstream/master' into rustup2
2020-06-30 15:40:22 +02: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
bors
a14eab389f
Auto merge of #5745 - montrivo:copy_on_clone, r=phansch
...
clone_on_copy - add machine applicability
Fix #4826 .
Change the applicability of the lint clone_on_copy. Split a test file and run rustfix on the clone_on_copy part.
changelog: clone_on_copy - add machine applicability
2020-06-24 07:11:07 +00:00
Tim Nielens
6bf5434e19
copy_on_clone - add machine applicability
2020-06-24 01:01:44 +02:00
Aaron Hill
6b3ee8f600
Update Clippy for MethodCall changes
2020-06-10 17:30:11 -04:00
Lzu Tao
8db24840f7
Merge commit 'ff0993c5e9162ddaea78e83d0f0161e68bd4ea73' into clippy
2020-06-09 14:36:01 +00:00
Mazdak Farrokhzad
78f158e80e
dogfood unnested_or_patterns
2020-06-07 21:16:03 +02:00
Philipp Hansch
623faac84e
Cleanup: Use rustc's same_types
instead of our same_tys
2020-06-06 11:50:59 +02:00
bors
5cb9ef390a
Auto merge of #5664 - ThibsG:GiveCorrectedCode, r=flip1995
...
Give corrected code
This PR adds corrected code for doc examples.
I did this in several commits to facilitate review.
Don't hesitate to tell me if I forgot some.
Also, sometimes I felt it was not necessary to give corrected code, but I maybe wrong.
fixes : #4829
changelog: Improve documentation examples across multiple lints.
2020-06-02 12:11:28 +00:00
bors
f760d77bdb
Auto merge of #5597 - esamudera:slice_iter_next, r=flip1995
...
New lint: iter_next_slice
Hello, this is a work-in-progress PR for issue: https://github.com/rust-lang/rust-clippy/issues/5572
I have implemented lint to replace `iter().next()` for `slice[index..]` and `array` with `get(index)` and `get(0)` respectively. However since I made a lot of changes, I would like to request some feedback before continuing so that I could fix mistakes.
Thank you!
---
changelog: implement `iter_next_slice` lint and test, and modify `needless_continues`, `for_loop_over_options_result` UI tests since they have `iter().next()`
2020-06-02 11:42:22 +00:00
ThibsG
137a3b4d32
Corrected doc PR fixes
2020-06-01 10:49:48 +02:00
ThibsG
9893254dff
Add more corrected code for doc
2020-06-01 10:39:52 +02:00
Ericko Samudera
32fde0b511
New lint: iter_next_slice
2020-06-01 03:08:51 +07:00
flip1995
a0e9f9bd0d
Merge commit '7ea7cd165ad6705603852771bf82cc2fd6560db5' into clippyup2
2020-05-28 15:45:24 +02:00
Jeremy Stucki
bcfeb4de15
Fix build
2020-05-25 21:41:20 +02:00
Jeremy Stucki
566377f627
Ignore calls to 'len'
2020-05-25 21:41:20 +02:00
flip1995
6b3cf63bf5
Fix dogfood fallout
2020-05-22 14:45:51 +02:00
Bastian Kauschke
091239ee60
introduce newtype'd Predicate<'tcx>
2020-05-20 15:44:34 +02:00
Bastian Kauschke
2722522fac
rename Predicate
to PredicateKind
, introduce alias
2020-05-20 15:38:03 +02:00
flip1995
f1d3086492
Merge commit 'e214ea82ad0a751563acf67e1cd9279cf302db3a' into clippyup
2020-05-17 17:36:26 +02:00
CrazyRoka
20c069beec
Fixed incorrect suggestion of clone_double_ref
lint
...
- Added `<_>` to suggestion
- Changed help message
2020-04-29 22:40:57 +03:00
Philipp Hansch
0a49935270
cargo dev fmt
2020-04-26 13:44:08 +02:00
Philipp Hansch
0480ff861a
More diagnostic items
...
In particular for:
* `VecDeque`
* `String`
* `Mutex`
* `HashMap`
* `HashSet`
cc https://github.com/rust-lang/rust/pull/71414 https://github.com/rust-lang/rust-clippy/issues/5393
2020-04-26 13:44:08 +02: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
Marcin Serwin
c20afbdfe0
Lint map_flatten if caller is an Option
2020-04-16 08:00:32 +02:00
bors
81b3e7096b
Auto merge of #5449 - phansch:diagnostic-items, r=matthiaskrgr
...
Make use of more diagnostic items
This makes use of some (not all) already existing diagnostic items. Specifically:
* 79982a2
: `core::mem::uninitialized`, `core::mem::zeroed`, `alloc::sync::Arc`, `alloc::sync::Rc`
* 83874d0
: `Option` and `Result`
cc #5393
changelog: none
2020-04-14 19:58:17 +00:00
bors
d236b30a1d
Auto merge of #5457 - phansch:sym, r=matthiaskrgr
...
Cleanup: Use our `sym!` macro more
It's much shorter than Symbol::intern and the effect should still be clear
---
changelog: none
2020-04-14 12:30:14 +00:00
bors
54344c78f4
Auto merge of #5448 - Emerentius:update_new_ret_no_self_docs, r=phansch
...
Update documentation for new_ret_no_self
changelog: Update documentation for lint new_ret_no_self to reflect that the return type must only contain `Self`, not be `Self`
The lint was changed to be more lenient than the documentation implies in PR #3338 (Related issue #3313 )
2020-04-13 20:32:44 +00:00
Philipp Hansch
31c5664f25
Cleanup: Use our sym!
macro more
...
It's much shorter that Symbol::intern and the result should still be
clear.
2020-04-13 08:57:34 +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
Philipp Hansch
79982a2813
Make use of some existing diagnostic items
2020-04-12 13:58:04 +02:00
bors
5e8c0c5ae0
Auto merge of #5441 - rabisg0:fix/clone-on-copy, r=phansch
...
Check for clone-on-copy in argument positions
Earlier if arguments to method calls matched the above pattern they were
not reported. This patch ensures such arguments are checked as well.
Fixes #5436
changelog: apply clone_on_copy lint to func args as well
2020-04-10 21:49:26 +00:00
Emerentius
ed72dc4119
Update documentation for new_ret_no_self
...
The lint was changed to be more lenient than the documentation implies in PR #3338 .
Related issue #3313
2020-04-10 19:08:31 +02:00
Philipp Hansch
3ef1dab211
Rustup to https://github.com/rust-lang/rust/pull/70913
2020-04-10 19:03:34 +02:00
Philipp Krones
90fb50fabf
Revert "Downgrade new_ret_no_self to pedantic"
2020-04-09 19:38:20 +02:00
Rabi Guha
183c4abb22
Check for clone-on-copy in argument positions
...
Earlier if arguments to method calls matched the above pattern they were
not reported. This patch ensures such arguments are checked as well.
Fixes #5436
2020-04-09 21:59:42 +05:30
bors
940bbd6aa4
Auto merge of #5437 - rabisg0:should-impl-trait, r=flip1995
...
Check fn header along with decl when suggesting to implement trait
When checking for functions that are potential candidates for trait
implementations check the function header to make sure modifiers like
asyncness, constness and safety match before triggering the lint.
Fixes #5413 , #4290
changelog: check fn header along with decl for should_implement_trait
2020-04-08 16:55:47 +00:00
Rabi Guha
c2e5534157
Check fn header along with decl when suggesting to implement trait
...
When checking for functions that are potential candidates for trait
implementations check the function header to make sure modifiers like
asyncness, constness and safety match before triggering the lint.
Fixes #5413 , #4290
2020-04-08 21:24:20 +05:30
David Tolnay
899a1b5598
Move cognitive_complexity to nursery
2020-04-08 08:37:20 -07:00
Philipp Krones
79d152190c
Rollup merge of #5425 - xiongmao86:issue5367, r=flip1995
...
Ehance opt_as_ref_deref lint.
- [x] Added passing UI tests (including committed `.stderr` file)
- [x] `cargo test` passes locally
- [x] Run `cargo dev fmt`
Lint on opt.as_ref().map(|x| &**x). Fixes #5367 .
changelog: lint on opt.as_ref().map(|x| &**x)
2020-04-08 15:50:28 +02:00
Philipp Krones
7cb5180dfb
Rollup merge of #5420 - dtolnay:newret, r=flip1995
...
Downgrade new_ret_no_self to pedantic
As motivated by #5418 . This is the second most widely suppressed Clippy style lint, and [this grep.app search](https://grep.app/search?q=%5C%5Ballow%5C%28.%2Aclippy%3A%3Anew_ret_no_self%5Cb®exp=true&case=true&filter[lang][0]=Rust ) shows a large number of diverse reasonable signatures for a `new` method.
changelog: Remove new_ret_no_self from default set of enabled lints
2020-04-08 15:50:24 +02:00
Philipp Krones
a1e49f962c
Rollup merge of #5415 - nickrtorres:master, r=flip1995
...
Add new lint for `Result<T, E>.map_or(None, Some(T))`
Fixes #5414
PR Checklist
---
- [x] Followed lint naming conventions (the name is a bit awkward, but it seems to conform)
- [x] Added passing UI tests (including committed .stderr file)
- [x] cargo test passes locally
- [x] Executed cargo dev update_lints
- [x] Added lint documentation
- [x] Run cargo dev fmt
`Result<T, E>` has an [`ok()`](https://doc.rust-lang.org/std/result/enum.Result.html#method.ok ) method that adapts a `Result<T,E>` into an `Option<T>`.
It's possible to get around this adapter by writing `Result<T,E>.map_or(None, Some)`.
This lint is implemented as a new variant of the existing [`option_map_none` lint](https://github.com/rust-lang/rust-clippy/pull/2128 )
2020-04-08 15:50:20 +02:00
Philipp Krones
5ea4771433
Rollup merge of #5412 - dtolnay:tostring, r=flip1995
...
Downgrade inefficient_to_string to pedantic
From the [documentation](https://rust-lang.github.io/rust-clippy/master/index.html#inefficient_to_string ):
> ```diff
> - ["foo", "bar"].iter().map(|s| s.to_string());
>
> + ["foo", "bar"].iter().map(|&s| s.to_string());
> ```
I feel like saving 10 nanoseconds from the formatting machinery isn't worth asking the programmer to insert extra `&` / `*` noise in the *vast* majority of cases. This is a pedantic lint.
changelog: Remove inefficient_to_string from default set of enabled lints
2020-04-08 15:50:19 +02:00
Linus Färnstrand
1647f53fb3
Use int assoc consts in MANUAL_SATURATING_ARITHMETIC
2020-04-08 00:43:27 +02:00
Eduard Burtescu
2ad4d6a057
rustup: update for the new Ty::walk interface.
2020-04-07 19:53:56 +00:00
xiongmao86
d7056f8ffb
Refine lint message.
2020-04-07 21:25:07 +08:00
xiongmao86
4f14826e09
Lint on opt.as_ref().map(|x| &**x).
2020-04-06 22:53:59 +08:00
Nick Torres
5d54fbb791
result_map_or_into_option: fix syntax error in example
2020-04-04 17:20:23 -07:00
Nick Torres
325d0b69d2
result_map_or_into: fix dogfood_clippy error => {h,l}int
2020-04-04 15:02:38 -07:00
Nick Torres
2533f56a0e
result_map_or_into_option: fix cargo dev fmt --check
errors
2020-04-04 14:33:43 -07:00
Nick Torres
acc3bc1ba2
result_map_or_into_option: move arg checks into tuple assignment
2020-04-04 14:24:22 -07:00
Nick Torres
d0738bd673
result_map_or_into_option: destructure lint tuple or return early
2020-04-04 14:16:23 -07:00
Nick Torres
3a29aedf8d
result_map_or_into_option: add good and bad examples
2020-04-04 14:16:18 -07:00
Nick Torres
91759a7582
result_map_or_into_option: explicitly note absence of known problems
2020-04-04 14:16:11 -07:00
David Tolnay
560c8c9c70
Downgrade new_ret_no_self to pedantic
2020-04-04 12:58:18 -07:00
Nick Torres
91d8a804d3
result_map_or_into_option: add lint to catch manually adpating Result -> Option
...
Result<T, E> has an `ok()` method that adapts a Result<T,E> into an Option<T>.
It's possible to get around this adapter by writing Result<T,E>.map_or(None, Some).
This lint is implemented as a new variant of the existing
[`option_map_none` lint](https://github.com/rust-lang/rust-clippy/pull/2128 )
2020-04-04 03:17:13 -07:00
David Tolnay
e26ae7a0ff
Downgrade inefficient_to_string to pedantic
2020-04-02 20:00:12 -07:00
Matthias Krüger
aff57e0f43
rustup https://github.com/rust-lang/rust/pull/70536
2020-03-30 11:17:58 +02:00
Philipp Hansch
cec1e8f74e
Remove dependency on matches
crate
...
The std equivalent works exactly the same.
2020-03-25 07:50:08 +01:00
Matthias Krüger
a97f60b8e3
rustup https://github.com/rust-lang/rust/pull/69738
2020-03-16 18:38:30 +01:00
bors
24f6d643fe
Auto merge of #5322 - phansch:or_patterns, r=matthiaskrgr
...
Make use of `or_patterns` feature
changelog: none
2020-03-16 12:41:04 +00:00
Matthias Krüger
ba0884bee3
rustup https://github.com/rust-lang/rust/pull/68944
2020-03-16 11:36:17 +01:00
Philipp Hansch
548c417ec4
Make use of or_patterns
feature
2020-03-16 07:25:09 +01:00
Yuki Okushi
3e3776666e
Rustup to rust-lang/rust#69674
2020-03-13 04:56:55 +09:00
Yuki Okushi
3d44ad2e32
Use try_eval_usize
over eval_usize
2020-03-03 21:40:24 +09:00
Yuki Okushi
4253aa7137
Rustup to rust-lang/rust#69592
2020-03-01 12:23:33 +09:00
flip1995
8472ecda0f
Fix fallout
2020-02-21 11:14:18 +01:00
Yuki Okushi
f56e8b7eb4
Rename FunctionRetTy
to FnRetTy
2020-02-17 19:07:08 +09:00
Matthew Jasper
787398aa53
Avoid using regions from TypeckTables
...
These regions will all be `ReErased` soon.
2020-02-15 16:24:49 +00:00
Lily Chung
385fd7cd0a
change in the right place, run update_lints
2020-02-12 17:03:49 -08:00
Areredify
66ad544175
improve 'iter_nth_zero' documentation
2020-02-03 15:44:55 +03:00
Ludwig Stecher
1f600f3f9a
Un-ignore most code blocks to render correctly on website, correct mistakes
2020-01-30 23:44:37 +01:00
Ludwig Stecher
58da5ba6db
Fix code formatting for more lints
2020-01-30 22:12:00 +01:00
Ludwig Stecher
f0dc98160b
Fix syntax highlighting of code fence
...
The documentation for RESULT_EXPECT_USED includes this code:
let res: Result<usize, ()> = Ok(1);
res?;
# Ok::<(), ()>(())
Because the code fence didn't start with `rust`, the code wasn't highlighted and the line starting with `#` was displayed on the website. This is now fixed.
2020-01-30 21:55:30 +01:00
xiongmao86
ac9f019fbf
Reformat code.
2020-01-30 00:23:47 +08:00
Yuki Okushi
f5e86d6894
Rename span_note_and_lint
to span_lint_and_note
2020-01-27 11:26:42 +09:00
Yuki Okushi
f60f12f71f
Rename span_help_and_lint
to span_lint_and_help
2020-01-27 11:17:58 +09:00
Yuki Okushi
4b133f2867
Apply review comments
2020-01-26 07:01:16 +09:00
Yuki Okushi
2dc73c45d5
Clean up methods/mod.rs
2020-01-24 17:04:37 +09:00
Areredify
796958c7e2
add option_as_ref_deref
lint
2020-01-23 16:12:16 +03:00
bors
eca0d8e5d0
Auto merge of #5067 - JohnTitor:lint-skip-while-next, r=flip1995
...
Add `skip_while_next` lint
Fixes #4036
changelog: Add `skip_while_next` lint
2020-01-20 17:28:38 +00:00
Yuki Okushi
bec5b69e45
Apply review comment
2020-01-20 21:07:31 +09:00
Yuki Okushi
f8034e0bc6
Improve suspicious_map
documentation
2020-01-20 15:05:40 +09:00
Yuki Okushi
95c369fa91
Add skip_while_next
lint
2020-01-20 10:56:02 +09:00
Yuki Okushi
e72f0e61c6
Rustup to rust-lang/rust#68204
2020-01-18 14:39:18 +09:00
bors
c24a42289b
Auto merge of #4543 - xiongmao86:issue4503, r=flip1995
...
Fix issue4503
Fixes #4503 .
changelog: Add a lint checking user are using FileType.is_file() method and suggest using !FileType.is_dir().
- [x] Followed [lint naming conventions][lint_naming]
- [x] Added passing UI tests (including committed `.stderr` file)
- [x] `cargo test` passes locally
- [x] Executed `./util/dev update_lints`
- [x] Added lint documentation
- [x] Run `./util/dev fmt`
2020-01-13 22:09:39 +00:00
Yuki Okushi
ce1c6b285d
Rustup to rust-lang/rust#68045
2020-01-13 21:55:57 +09:00
xiongmao86
2b477f361e
Update lints again.
2020-01-12 19:54:17 +08:00
xiongmao86
77c48ca341
Fix grammar error.
2020-01-12 19:54:17 +08:00
Rui
1018b78f41
Update clippy_lints/src/methods/mod.rs
...
Co-Authored-By: Philipp Krones <hello@philkrones.com>
2020-01-12 19:54:17 +08:00
xiongmao86
8d3cc6b8a9
Change lint message.
2020-01-12 19:54:17 +08:00
Rui
a73822d3b9
Fix documents and messages.
...
Update clippy_lints/src/methods/mod.rs
2020-01-12 19:54:17 +08:00
xiongmao86
8d333a3cbb
Extend spans to include !.
2020-01-12 19:54:17 +08:00
xiongmao86
3c59eaf91c
Add lint logic.
2020-01-12 19:54:17 +08:00
xiongmao86
96334d0d7c
Declare lint.
2020-01-12 19:54:17 +08:00
Yuki Okushi
39947992b5
Rustup to rust-lang/rust#67806
2020-01-11 21:50:00 +09:00
Yuki Okushi
e58cfac458
Rustup to rust-lang/rust#67979
2020-01-09 16:43:51 +09:00
Yuki Okushi
5ac08b0cc9
Normalize lint messages
2020-01-07 18:26:55 +09:00
Yuki Okushi
2f2eaf8b7e
Rustup to rust-lang/rust#67886
2020-01-07 01:46:33 +09:00
Brad Sherman
ab5ff0352e
Add lint for iter.nth(0)
...
- Encourage iter.next() rather than iter.nth(0), which is less readable
2020-01-04 11:20:11 -06:00
Philipp Hansch
c5178e82b4
Rustup to https://github.com/rust-lang/rust/pull/67853
...
Specifically caused by https://github.com/rust-lang/rust/pull/67786
2020-01-04 11:30:03 +01:00
Yuki Okushi
1102b87e3a
Remove use of try!
from documentation
2020-01-04 13:47:01 +09:00
Yuki Okushi
9086b17e14
Rustup to rust-lang/rust#67707
2019-12-31 09:17:56 +09:00
bors
cecaca3382
Auto merge of #4634 - m-ober:feature/2320-map-or, r=llogiq
...
Add real suggestion to option_map_unwrap_or
changelog: Add real suggestion to `option_map_unwrap_or`
Fixes #2320
2019-12-30 15:50:06 +00:00
Yuki Okushi
a4c201e6b4
Rustup to rust-lang/rust#66942
2019-12-30 13:02:10 +09:00
Micha Ober
c5046fdce5
Add real suggestion to option_map_unwrap_or
2019-12-28 23:24:45 +01:00
Yuki Okushi
e2636729ec
Rustup to rust-lang/rust#66936
2019-12-27 16:13:53 +09:00
flip1995
9632e27487
Add <'_> where necessary
2019-12-22 15:42:41 +01:00
Lzu Tao
d1ca5f1d7c
rustup "Merge ast::Mutability
and mir::Mutability
"
2019-12-21 18:38:45 +00:00
bors
b4ad56e5c4
Auto merge of #4920 - lily-commure:fix-unnecessary-filter-map-docs, r=phansch
...
Fix documentation example for unnecessary_filter_map.
Fixes #4919 .
changelog: none
2019-12-20 07:27:24 +00:00
bors
a86463c99f
Auto merge of #4913 - mikerite:step-by-zero-20191218, r=phansch
...
Move `iterator_step_by_zero` and correct the documentation
Move `iterator_step_by_zero` and correct the documentation.
changelog: Corrected `iterator_step_by_zero` documentation
2019-12-20 07:10:11 +00:00
Lily Chung
6e8c2bf8e6
Fix documentation example for unnecessary_filter_map.
2019-12-19 15:48:17 -08:00
Michael Wright
1559f8bf34
Fix expect_fun_call
false negative on references
...
Closes #4912
2019-12-19 06:57:56 +02:00
mikerite
710e06dd29
Fix iterator_step_by_zero
description in declaration
...
Co-Authored-By: Phil Hansch <dev@phansch.net>
2019-12-19 06:51:26 +02:00
Michael Wright
38d0b2199a
Correct iterator_step_by_zero
documentation
2019-12-18 18:59:59 +02:00
Michael Wright
e097fca4df
Update iterator_step_by_zero
...
Move `iterator_step_by_zero` into `methods` since it applies to all
iterators and not just ranges. Simplify the code while doing so.
2019-12-18 18:59:43 +02:00
Matthias Krüger
98e433d70d
Rustup to rust-lang/rust#66878
2019-12-04 01:34:01 +01:00
Phil Hansch
a05f3cb9a1
Rollup merge of #4847 - rust-lang:offest, r=phansch
...
fixing a typo
changelog: none
2019-11-28 10:19:06 +01:00
Lzu Tao
d0e0ffa99f
make use of Result::map_or
2019-11-28 10:52:20 +07:00
Manish Goregaokar
341e266508
Add BorrowKind::Ref
2019-11-27 14:39:28 -08:00
Andre Bogus
47ef5394de
fixing a typo
2019-11-25 14:06:34 +01:00
flip1995
d2d62de841
Rustup to rust-lang/rust#64856
2019-11-25 13:56:24 +01:00
flip1995
d43c424145
Rustup to rust-lang/rust#66671
2019-11-25 13:18:38 +01:00
bors
cc35165f52
Auto merge of #4840 - flip1995:rollup-jqk3a3i, r=flip1995
...
Rollup of 5 pull requests
Successful merges:
- #4730 (Fix check_infinite_loop (while_immutable_condition) by checking for break or return inside loop body)
- #4766 (Fix false positive in derive_hash_xor_eq)
- #4811 (Literal Representation Restructure)
- #4820 (doc: fix the comment above the lint function)
- #4830 (use more efficient code to generate repeated string)
Failed merges:
r? @ghost
changelog: none
2019-11-23 17:40:57 +00:00
Philipp Krones
ae69bc4980
Rollup merge of #4820 - guanqun:comment-fix, r=flip1995
...
doc: fix the comment above the lint function
it's a simple comment fix.
---
changelog: none
2019-11-23 18:16:01 +01:00
Andre Bogus
c21b198576
New lint: zst_offset
2019-11-15 22:39:27 +01:00
Guanqun Lu
f2d8197110
doc: fix the comment above the lint function
2019-11-16 01:55:06 +08:00
Manish Goregaokar
e9a3e54910
MutImmutable -> Immutable, MutMutable -> Mutable, CaptureClause -> CaptureBy
2019-11-11 10:58:39 -08:00
flip1995
08fd397c2c
Deprecate into_iter_on_array
lint
...
This lint was uplifted/reimplemented by rustc.
Rustup to rust-lang/rust#66017
2019-11-07 14:04:29 +01:00
Lzu Tao
51632530d7
rustup rust-lang/rust#65776
2019-11-06 17:46:45 +07:00
Lzu Tao
4c7387e965
rustup https://github.com/rust-lang/rust/pull/65535
2019-10-19 12:27:21 +07:00
Heinz N. Gies
7f454d8d06
Split out tests
2019-10-18 07:40:48 +02:00
Heinz N. Gies
a7ad78f3eb
Add expect
...
Co-Authored-By: Philipp Krones <hello@philkrones.com>
2019-10-18 07:37:58 +02:00
Michael Zhang
2106a23966
Update help text in inefficient_to_string
...
Co-Authored-By: Manish Goregaokar <manishsmail@gmail.com>
2019-10-17 19:13:32 -04:00
HMPerson1
76b44f34b9
Add inefficient_to_string
lint
2019-10-16 15:54:20 -04:00
Andre Bogus
cc622608db
new lints around #[must_use]
fns
...
`must_use_unit` lints unit-returning functions with a `#[must_use]`
attribute, suggesting to remove it.
`double_must_use` lints functions with a plain `#[must_use]`
attribute, but which return a type which is already `#[must_use]`,
so the attribute has no benefit.
`must_use_candidate` is a pedantic lint that lints functions and
methods that return some non-unit type that is not already
`#[must_use]` and suggests to add the annotation.
2019-10-14 12:09:04 +02:00
bors
b690cdb1e7
Auto merge of #4611 - rust-lang:doc-visibility, r=flip1995
...
account for doc visibility
This fixes #4608 .
Also I noticed that the lint failed to look at trait and impl items. There's a small bit of fallout in the code, too, but not enough to warrant its own commit.
changelog: check docs of trait items and impl items, also make `missing_safety_doc` account for visibility
2019-10-08 07:11:26 +00:00
flip1995
3aa531c194
Run util/dev fmt
2019-10-05 12:42:09 +02:00
flip1995
3b23092b69
Get rid of rvalue_promotable_map method call
2019-10-05 12:38:38 +02:00
Andre Bogus
e3f143ff0a
account for doc visibility
2019-10-02 21:15:28 +02:00
flip1995
4bbd10a585
Rustup to rust-lang/rust#64813
2019-09-27 17:21:20 +02:00
Lzu Tao
a7b7e19f49
Rustup https://github.com/rust-lang/rust/pull/64513
2019-09-26 16:03:36 +07:00
Matthias Krüger
b72982759c
run rustfmt
2019-09-11 08:26:57 +02:00
bors
4ee8bc84cd
Auto merge of #4527 - rust-lang:more-vec-diag-items, r=oli-obk
...
Changed more `Vec` paths to diagnostic_items
In #4519 , I missed a few instances of path matching for `Vec`, so here they are.
r? @oli-obk
changelog: none
2019-09-09 16:56:51 +00:00
bors
c733376a5f
Auto merge of #4522 - mikerite:fix-4514, r=phansch
...
Fix `or_fun_call` bad suggestion
Closes #4514
changelog: Fix `or_fun_call` bad suggestion
2019-09-09 15:38:59 +00:00
Andre Bogus
507c03a859
Changed more Vec paths to diagnostic_items
2019-09-09 17:22:41 +02:00
Andre Bogus
e3c4ffd4aa
Use diagnostic item for
2019-09-09 05:43:39 +02:00
Michael Wright
9bdfd0683f
Fix or_fun_call
bad suggestion
...
Closes #4514
2019-09-08 11:03:45 +02:00
Jeremy Stucki
3fc1ec1ffd
Refactor option handling
2019-09-04 16:19:59 +02:00
bors
ffe57fad85
Auto merge of #4498 - sinkuu:checked_arithmetic_unwrap, r=flip1995
...
Add manual_saturating_arithmetic lint
changelog: add `manual_saturating_arithmetic` lint
Fixes #1557 . This lint detects manual saturating arithmetics like `x.checked_add(10u32).unwrap_or(u32::max_value())` and suggests replacing with `x.saturating_add(10u32)`.
2019-09-04 12:14:41 +00:00
Shotaro Yamada
c6fb9c8a2a
Hide variables in doc-test
2019-09-04 21:10:08 +09:00
Shotaro Yamada
45fde0f86f
Fix doctest and renaming src
2019-09-04 21:06:28 +09:00
Shotaro Yamada
4960f79476
Add manual_saturating_arithmetic lint
2019-09-04 18:38:25 +09:00
bors
8239b7616f
Auto merge of #4454 - BO41:search_is_some, r=flip1995
...
Dereference one less on search_is_some and make it auto-fixable
Fixes #4453
changelog: none
2019-09-04 07:53:44 +00:00
BO41
64cd9e4d60
Try to fix .fixed
2019-09-03 18:56:23 +02:00
Andre Bogus
b01f2d1126
lint against MaybeUninit::uninit().assume_init()
2019-09-03 17:37:38 +02:00
flip1995
3c11406c1f
Rustup to rust-lang/rust#60966
2019-08-30 10:11:27 +02:00
flip1995
dac81d867b
Use the spans returned by utils::method_calls
2019-08-29 17:34:03 +02:00
BO41
945d4cf69f
Dereference one less on search_is_some and make it auto-fixable
2019-08-29 17:34:02 +02:00
Yuki Okushi
2c282252a9
Replace Arg
with Param
2019-08-28 18:33:25 +09:00
bors
f760088820
Auto merge of #4430 - lzutao:defid_trait_alias, r=flip1995
...
Account for trait alias when looking for defid
I hit the crash on the `expect` call when running clippy on rustc libcore.
Hopefully this will fix it.
changelog: none
2019-08-26 12:46:00 +00:00
bors
ba6681300e
Auto merge of #4436 - BO41:written_as, r=phansch
...
Add some "could be written as" examples
fixes #4405
changelog: none
2019-08-26 11:11:57 +00:00
Lzu Tao
dac2509bac
Account for trait alias when looking for defid
2019-08-25 20:36:11 +07:00
BO41
31a6ab47e1
Fix lint doc
2019-08-24 13:57:25 +02:00
Jeremy Stucki
2da8288433
Refactor some minor things
2019-08-23 22:52:04 +02:00
Jeremy Stucki
907aebcf8b
Use more if-chains
2019-08-23 22:51:44 +02:00
Jeremy Stucki
4130dfba2e
Refactor 'lint_or_fun_call'
2019-08-23 22:31:22 +02:00
Jeremy Stucki
419c87fb35
Refactor 'check_unwrap_or_default'
2019-08-23 14:36:00 +02:00
Jeremy Stucki
1436fea271
Refactor 'check_impl_item'
2019-08-23 14:20:55 +02:00
BO41
eebb7cd839
Add examples to some complexity lints
2019-08-22 15:41:07 +02:00
BO41
43a2ba34e6
Add examples to some correctness lints
2019-08-22 15:41:07 +02:00
Michael Wright
59893bcab0
Fix temporary_cstring_as_ptr
false negative
...
Fixes #4375 .
Changes the check to test when `.unwrap().as_ptr()` is called on any
`Result<CString, _>` as suggested by @flip1995
(https://github.com/rust-lang/rust-clippy/issues/4375#issuecomment-520724123 ).
2019-08-21 07:35:04 +02:00
KRAAI, MATTHEW [VISUS]
204b2f3658
Remove in_macro_or_desugar
2019-08-19 09:30:32 -07:00
bors
5c71c1b838
Auto merge of #4411 - mikerite:fix-4384, r=flip1995
...
Fix `clone_on_copy` false positives
Closes #4384
changelog: Fix `clone_on_copy` false positives
2019-08-19 08:04:12 +00:00
Michael Wright
68a1af540c
Fix clone_on_copy
false positives
...
Closes #4384
2019-08-19 08:19:54 +02:00
Lzu Tao
7065239da5
Add option_and_then_some lint
2019-08-19 03:54:40 +00:00
Jeremy Stucki
9c39c02b75
Change lint type to 'complexity'
2019-08-18 16:49:11 +02:00
Jeremy Stucki
f4f31a4ff4
Implement lint 'suspicious_map'
2019-08-15 22:58:32 +02:00
Jeremy Stucki
fdf82eb1a8
Remove unused import
2019-08-14 20:24:05 +02:00
Jeremy Stucki
08f658bc72
Use different span
2019-08-14 19:35:06 +02:00
bors
63d2d066f9
Auto merge of #4369 - mikerite:fix-4293, r=flip1995
...
Fix `wrong_self_convention` issue
Resolves #4293
changelog: Fix `wrong_self_convention` issue
2019-08-14 10:59:36 +00:00
Jeremy Stucki
2bfcf89f82
Merge branch 'origin/master' into flat-map
2019-08-14 07:36:37 +02:00
Jeremy Stucki
d578c43c51
Use correct span
2019-08-13 21:50:42 +02:00
Jeremy Stucki
d51136d594
Use 'span_lint_and_sugg'
2019-08-12 21:42:57 +02:00
Jeremy Stucki
3a65e4e75a
Minor refactoring
2019-08-12 21:29:33 +02:00
Jeremy Stucki
09e9568c26
Change lint type from 'pedantic' → 'complexity'
2019-08-12 10:53:23 +02:00
Jeremy Stucki
df9063013e
Update rustdoc
2019-08-11 22:18:58 +02:00
Jeremy Stucki
5fd7d44f36
Refactor if_chain
...
Co-authored-by: Philipp Krones <hello@philkrones.com>
2019-08-11 21:02:01 +02:00
Jeremy Stucki
b651f19eb8
Rename 'flat_map' → 'flat_map_identity'
2019-08-11 20:34:25 +02:00
Jeremy Stucki
f0ce04f814
Handle calls with 'std::convert::identity'
2019-08-11 19:51:43 +02:00
Jeremy Stucki
05d9f884e1
Merge branch 'origin/master' into flat-map
2019-08-11 19:22:40 +02:00
Michael Wright
77278ccda9
Fix wrong_self_convention
issue
...
Resolves #4293
2019-08-10 06:01:15 +02:00
Michael Wright
170d4861c6
Simplify wrong_self_convention
code
...
Use actual types instead of hir types.
2019-08-10 06:00:27 +02:00
Michael Wright
ebd24985bf
Rename implitem to impl_item
...
`impl_item` is proper snake case and used everywhere else.
2019-08-10 05:58:52 +02:00
Lukas Markeffsky
d7b9a845aa
new_ret_no_self: walk associated types in impl Trait return types
2019-08-09 17:44:05 +02:00
bors
c55d38ed7a
Auto merge of #4362 - lzutao:expect-on-cstring_as_ptr, r=flip1995
...
Fix lint_cstring_as_ptr for expect
Closes #4312
changelog: none
2019-08-09 09:22:02 +00:00
Lzu Tao
c23a5c586f
Fix lint_cstring_as_ptr for expect
2019-08-09 12:39:33 +07:00
Lzu Tao
30cbdc7491
Fix lint_single_char_pattern on raw string literal
2019-08-09 10:55:30 +07:00
Lzu Tao
e4f8cd9672
Rustup https://github.com/rust-lang/rust/pull/59369
2019-08-06 19:20:41 +07:00
Philipp Krones
93c3da223f
Rollup merge of #4331 - phansch:doctests_restriction, r=flip1995
...
Doctests: Enable running doc tests for restriction lints
changelog: Enabled remaining doc tests for lint documentation page
master: 202 passed; 0 failed; 122 ignored; 0 measured; 0 filtered out
this PR: 231 passed; 0 failed; 123 ignored; 0 measured; 0 filtered out
Closes #4319 (assuming this is merged after #4329 and #4330 )
2019-08-05 10:50:06 +02:00
Philipp Hansch
b608e02e1c
Doctests: Enable running doc tests for restriction lints
2019-08-03 21:24:50 +02:00
Philipp Hansch
1dc9a5012e
Doctests: Enable running doc tests for pedantic lints
2019-08-03 20:36:38 +02:00
bors
5c1e30ab05
Auto merge of #4327 - phansch:doctests_perf, r=flip1995
...
Doctests: Enable running doc tests for perf lints
changelog: none
This should be possible to merge independently of #4325
cc #4319
2019-08-03 14:06:13 +00:00
Philipp Hansch
c0cdfd296e
Doctests: Enable running doc tests for perf lints
...
This should be possible to merge independently of #4325
cc #4319
2019-08-03 08:08:00 +02:00
Philipp Hansch
abfa8a952c
Doctests: Fix all complexity lint docs
...
cc #4319
2019-08-02 18:16:35 +02:00
Jakub Wieczorek
2a13e83f2b
Update all the code to pass the updated use_self
lint.
...
One struct required a temporary `#[allow(dead_code)]` annotation due to
a bug in the Rust compiler: https://github.com/rust-lang/rust/issues/63151 .
2019-07-31 08:50:43 +00:00
Jeremy Stucki
c7da4c26fb
Implement flat_map lint
2019-07-08 17:11:54 +02:00
Lzu Tao
7293defb34
Rename hir::map::local_def_id_from_hir_id to local_def_id
2019-07-06 10:52:51 +07:00
Manish Goregaokar
c47a7e4ef2
get_parent_node_by_hir_id -> get_parent_node
2019-06-25 14:33:51 -07:00
bors
c5d1ecd474
Auto merge of #4220 - d-dorazio:4182-needless-return-void-functions, r=flip1995
...
make needless_return work with void functions
fixes https://github.com/rust-lang/rust-clippy/issues/4181 .
changelog: make needless_return work with void functions.
I don't think the failure is related to my changes, but I'm not sure 🤔
2019-06-22 09:38:53 +00:00
Lzu Tao
6aea41e050
Fix fallout cause NodeId pruning
2019-06-22 13:41:16 +07:00
Daniele D'Orazio
e1a78ae528
update tests and fix lints in clippy
2019-06-21 14:17:59 +02:00
Lzu Tao
4fa498a3eb
Fix warnings about unnecessary lifetime bounds
...
Rustup https://github.com/rust-lang/rust/pull/61172
2019-06-20 01:36:23 +07:00
Lzu Tao
5e887b2a6a
Fix lifetime mismatch between LateContext and Ty
2019-06-19 17:21:53 +07:00
Matthias Krüger
4d984dc6e6
rustup https://github.com/rust-lang/rust/pull/61836/
2019-06-18 11:15:47 +02:00
mikerite
3b7d6eeb4f
Fix comment grammar
...
Co-Authored-By: Philipp Krones <hello@philkrones.com>
2019-06-04 08:27:31 +02:00
Michael Wright
98585a0324
Fix .map(..).unwrap_or_else(..) bad suggestion
...
Closes #4144
2019-06-02 08:50:20 +02:00
Seo Sanghyeon
2c53a3f970
Fix typo in comment
2019-05-27 12:32:04 +09:00
Oliver Scherer
f49ef0ec04
Dogfood
2019-05-18 01:42:15 +02:00
Oliver Scherer
462df72100
Dogfood and rustfmt
2019-05-18 00:58:25 +02:00
Oliver Scherer
f7f85a0dca
Prevent symbocalypse
2019-05-17 23:53:54 +02:00
bors
501830bf01
Auto merge of #4084 - mikerite:fix-4019, r=oli-obk
...
Fix 4019
Fixes #4019
2019-05-14 11:26:16 +00:00
Oliver Scherer
dfbc74b08b
Rustfmt all the things
2019-05-14 10:33:48 +02:00
Oliver Scherer
b2dbda4d48
Use symbols instead of strings
2019-05-14 10:33:42 +02:00
Michael Wright
2efd8c6e05
Fix comments; minor refactoring
2019-05-12 10:32:19 +02:00
Michael Wright
e6e3f24e0c
Fix #4019
2019-05-12 10:18:38 +02:00
Manish Goregaokar
69b1da4d82
Remove some unnecessary If arms
2019-05-10 23:40:42 -07:00
Matthias Krüger
d618637c05
Rustup to rustc 1.36.0-nightly (13fde05b1 2019-05-03)
2019-05-03 22:28:34 -07:00
Jean Mertz
ff244b6c43
Fix link in into_iter_on_array documentation
...
The non-inline variant wasn't being rendered correctly.
see: https://rust-lang.github.io/rust-clippy/master/index.html#into_iter_on_array
2019-05-03 17:38:13 +02:00
bors
8151a17422
Auto merge of #4049 - airt:fix-4033-search_is_some, r=flip1995
...
Fix #4033 search_is_some
Fixes #4033 .
Suggest `any(|x| ..)` instead of `any(|&x| ..)` for `find(|&x| ..).is_some()` (Lint [search_is_some](https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some ))
FnDecl of `find`:
```rust
fn find<P>(&mut self, mut p: P) -> Option<Self::Item> where
P: FnMut(&Self::Item) -> bool
```
FnDecl of `any`:
```rust
fn any<F>(&mut self, mut f: F) -> bool where
F: FnMut(Self::Item) -> bool
```
If match on `|&_|` in closure of `find`, only use `|_|` in the suggestion.
PS. It's the first time that I have used the `hir` API, please correct me if there is any mistake 😺
2019-05-02 08:45:02 +00:00
airt
d063516c85
check closure arguments before use it
2019-05-01 04:41:00 +08:00
airt
5d6a100f81
format code
2019-05-01 04:03:51 +08:00
André Luis Leal Cardoso Junior
b411391f8e
Add lints for find_map
2019-04-30 16:45:28 -03:00
airt
c3fde34fd5
fix suggestion for search_is_some
2019-05-01 03:11:58 +08:00
airt
bd0b75f6c3
fix suggestion for search_is_some naively
2019-05-01 01:08:16 +08:00
Manish Goregaokar
7e2043de2f
Ignore all enum and struct constructors in lints about *or(call())
2019-04-23 08:01:42 -07:00
Felix Rabe
b4f2200d5c
Typo
2019-04-18 15:08:14 +02:00
Matthew Kraai
753c39672e
Use lint pass macros
...
Fixes #3917 .
2019-04-17 09:35:22 -07:00
flip1995
840eac2c05
Use {get,match}_def_path from LateContext
2019-04-17 12:53:29 +02:00
Manish Goregaokar
1b2f2be085
Remove now-unnecessary calls to node_to_hir_id
2019-04-14 13:11:31 -07:00
Klemen Košir
560fd163d6
Escape a single quote in single_char_pattern hint
2019-04-08 21:55:50 +09:00
Matthias Krüger
920e47ceb5
NFC: fix typos
2019-04-04 11:15:30 +02:00
Matthias Krüger
e17dd4efa9
rustup https://github.com/rust-lang/rust/pull/59096/
2019-03-23 23:37:38 +01:00
Mateusz Mikuła
9b7ff501a6
Replace most of ty:Ty with Ty
2019-03-18 12:54:10 +01:00
Alexander Regueiro
d43966a176
Various cosmetic improvements.
2019-03-10 18:06:28 +00:00
Manish Goregaokar
038ec7f5d8
Move get_unwrap to restriction
...
fixes #3862
2019-03-09 13:48:06 -08:00
Félix Fischer
ddc718087f
Renamed: Cyclomatic Complexity -> Cognitive Complexity
...
* Ran automatic naming update
* Formalized rename of `cyclomatic_complexity` to `cognitive_complexity`
** Added the rename to `lib.rs`
** Added rename test
* Added warning for deprecated key `cyclomatic_complexity_threshold` and tests for it
* Added deprecation status for Clippy's builtin attribute
* Updated tests for new builtin attribute renaming
2019-03-06 10:07:38 -03:00
Andy Russell
a9de64a151
fix or ignore failing doc tests
2019-03-05 18:45:08 -05:00
Andy Russell
fe96ffeac9
move lint documentation into macro invocations
2019-03-05 18:45:08 -05:00
ljedrz
f3363b9cf2
align with rust-lang/rust/#58836
2019-03-01 19:10:14 +01:00
ljedrz
f2587703cc
enable rust-lang/rust#58754
2019-03-01 19:10:14 +01:00
Wilco Kusee
eb70a72459
Fix false negative
2019-02-26 17:29:36 +01:00
Wilco Kusee
fec6e55d1d
Attempt to fix false negative
2019-02-26 17:27:41 +01:00
Wilco Kusee
4cf720abbe
Move lint_map_unwrap_or to its own file
2019-02-26 17:27:41 +01:00
Wilco Kusee
54ab22f6db
Only suggest map_or for copy types
2019-02-26 17:27:40 +01:00
ljedrz
8dac8a6ba4
HirIdify some lints
2019-02-24 20:49:43 +01:00
bors
a5c16e5892
Auto merge of #3789 - bzzzzzz:needless_range_loop_bugfix, r=oli-obk
...
Make needless_range_loop not applicable to structures without iter method
Fixes https://github.com/rust-lang/rust-clippy/issues/3788
Now we will start lint indexed structure only if it has known iter or iter_mut method implemented.
2019-02-21 09:36:13 +00:00
bzzzz
7767b3a081
Fixed formatting and typo
2019-02-20 10:12:24 -08:00
bzzzz
f9c6682827
Make needless_range_loop not applicable to structures without iter method
2019-02-20 00:10:25 -08:00
Michael Wright
9185c8d996
Format
2019-02-18 08:32:53 +02:00
Michael Wright
6e7a813ed2
Improve iter_cloned_collect
suggestions
...
Fixes #3704
2019-02-18 07:30:50 +02:00
Grzegorz
16881390e1
removing redundant closures in the whole project
2019-02-10 13:35:44 +01:00
Araam Borhanian
1169066a0b
Adding lint for too many lines.
2019-02-01 13:21:19 -05:00
Matthias Krüger
3a96d6b603
rustup https://github.com/rust-lang/rust/pull/57907/
...
for file in `fd \.rs$` ; do sed -i s/span_suggestion_with_applicability/span_suggestion/g $file ; done
for file in `fd \.rs$` ; do sed -i s/span_suggestion_short_with_applicability/span_suggestion_short/g $file ; done
for file in `fd \.rs$` ; do sed -i s/span_suggestions_with_applicability/span_suggestions/g $file ; done
2019-01-27 13:33:56 +01:00
Matthias Krüger
e9e0a7e3bd
rustup https://github.com/rust-lang/rust/pull/57726
2019-01-27 01:42:34 +01:00
Michael Wright
18cacbabb4
Incorporate review suggestions
2019-01-26 11:55:54 +02:00
Michael Wright
5284b95a06
Fix expect_fun_call
lint suggestions
...
This commit corrects some bad suggestions produced by the
`expect_fun_call` lint and enables `rust-fix` checking on the tests.
Addresses #3630
2019-01-24 06:58:53 +02:00
Michael Wright
8747691bea
Run rustfmt
2019-01-20 12:49:45 +02:00
Michael Wright
f51f0178dd
Fixed breakage due to rust-lang/rust#57489
2019-01-20 12:21:30 +02:00
Shotaro Yamada
2ee713dc7b
Catch up with format_args
change
...
Catches up with a change in rust-lang/rust#57537
Happened to fix a bug in `expect_fun_call`, that is the lint ignores more than
one arguments to `format`.
2019-01-19 21:18:31 +09:00
Philipp Hansch
38d4ac7cea
Remove all copyright license headers
...
Discussion previously happened in https://github.com/rust-lang/rust/pull/43498
2019-01-08 21:46:39 +01:00
Michael Wright
d2ea6355a8
Update unwrap_get
code review suggestions
2019-01-07 06:22:39 +02:00
Michael Wright
4add1e23f9
Improve get_unwrap
suggestion
...
Handle case where a reference is immediately dereferenced.
Fixes 3625
2019-01-06 11:46:03 +02:00
Konrad Borowski
3f62fc3a7e
Remove crate:: prefixes from crate paths
...
This is somewhat misleading, as those are actually external crates,
and don't need a crate:: prefix.
2018-12-29 16:05:49 +01:00
Wilco Kusee
24ef8db402
Do not mark as_ref as useless if it's followed by a method call
2018-12-17 21:33:50 +01:00
flip1995
d866f31678
rustup rust-lang/rust#52994
...
s/trim_left/trim_start/
s/trim_right/trim_end/
2018-12-14 12:35:44 +01:00
Matthias Krüger
273dc82872
run rustfmt
2018-12-09 12:03:10 +01:00
Philipp Hansch
fe3519e0dd
Swap if branches
2018-12-08 12:09:32 +01:00
Matthias Krüger
f13d23de41
rustup https://github.com/rust-lang/rust/pull/56502 ( .hir -> .hir() )
2018-12-08 12:05:09 +01:00
Philipp Hansch
26602ddff4
Merge pull request #3336 from HMPerson1/clone_on_copy_deref
...
Fix `clone_on_copy` not detecting derefs sometimes
2018-12-08 09:59:02 +01:00
flip1995
20a07f6d80
Fix TyKind::<kind> usage in codebase
2018-12-05 12:47:10 +01:00
flip1995
63fa5d24e1
Fix some formatting issues
2018-11-27 21:49:09 +01:00
flip1995
1751d2496d
Run rustfmt on clippy_lints
2018-11-27 21:14:15 +01:00
flip1995
4e74eef6e9
Add applicability level to (nearly) every span_lint_and_sugg function
2018-11-27 15:29:23 +01:00
flip1995
3740da203b
Fix bugs and improve documentation
...
Some bugs and some documentation is unrelated to the Applicability change, but
these bugs were serious and the documentation was kind of required to
understand what's going on.
2018-11-27 15:29:23 +01:00
flip1995
9096269610
Add Applicability::Unspecified to span_lint_and_sugg functions
2018-11-27 15:29:23 +01:00
kennytm
5563bd6cc3
Addressed comments.
2018-11-02 22:53:57 +08:00
kennytm
2b2acf1002
Fix dogfood error.
2018-11-02 22:53:57 +08:00
kennytm
2d1c9313b0
Added lints into_iter_on_ref
and into_iter_on_array
. Fix #1565 .
2018-11-02 22:53:56 +08:00
Matthias Krüger
df7cff31dc
clippy: fix pedantic warnings and run clippy::pedantic lints on the codebase.
...
Turn on pedantic lints in dogfood and base tests.
needless_bool: fix clippy::items-after-statements
redundant_pattern_matching: fix clippy::similar-names
mods.rs: fix clippy::explicit-iter-loop
returns.rs: allow clippy::cast-possible-wrap
Fixes #3172
2018-11-02 12:16:43 +01:00
bors[bot]
7c86a9c05c
Merge #3387
...
3387: Replace big if/else expression with match r=flip1995 a=mikerite
Co-authored-by: Michael Wright <mikerite@lavabit.com>
2018-11-02 07:58:00 +00:00
Michael Wright
0a41dfd946
Use slice patterns instead of padding
2018-11-01 07:06:47 +02:00
bors[bot]
73458aebe3
Merge #3368
...
3368: added downsides to "known problems" for get_unwrap lint r=flip1995 a=humean
As a beginner I found this lint to be confusing because I was not sure how the `Option` type disappeared as conceptually I know that my `.get()` and Index could fail. Initially I thought maybe the compiler or clippy was smart enough to understand that it was impossible for my `.get()` to fail in this particular case, but it was explained to me that using the Index syntax is just shorthand for directly unwrapping the value:
https://doc.rust-lang.org/src/std/collections/hash/map.rs.html#1547
For beginners or users trying to iterate quickly it seems common to litter your code with `unwrap` or `except` as placeholders for where some explicit error handling might need to take place. I think it should be warned that using Index is merely more concise, but doesn't at all reduce the risk of panics and might in fact cause you to miss handling them in a future refactor.
Co-authored-by: Michael Rutter <michael.john.rutter@gmail.com>
Co-authored-by: Michael Rutter <humean@users.noreply.github.com>
2018-10-31 10:21:51 +00:00
Michael Wright
4e054ad320
Replace big if/else expression with match
2018-10-31 06:29:38 +02:00
Michael Rutter
232a483331
more consistent use of terminology; trait > syntax
2018-10-28 12:31:02 +00:00
Michael Rutter
061a48321c
added downsides to "known problems" for get_unwrap lint
2018-10-28 08:12:47 +00:00
Philipp Hansch
840e50e97f
Don't expand macro in or_fun_call suggestion
2018-10-27 15:47:56 +02:00
Matthias Krüger
b8a9099011
Revert "new_ret_no_self: add sample from #3313 to Known Problems section."
...
This reverts commit fd2f6dd382
.
Issue #3313 has been fixed.
2018-10-25 13:39:02 +02:00
Josh Mcguigan
079f9f45b5
new_ret_no_self walk return type to check for self
2018-10-19 17:54:25 -07:00
HMPerson1
2a9dec681f
Fix suggestion for multiple derefs
2018-10-19 14:51:25 -04:00
Josh Mcguigan
097df8f223
new_ret_no_self correct false positive on raw pointer return types
2018-10-19 05:20:33 -07:00
Josh Mcguigan
6e75050be0
new_ret_no_self correct linting of tuple return types
2018-10-19 04:55:06 -07:00