ThibsG
90a72f506c
Handle args taken by ref also for MethodCall
2021-11-20 09:40:11 +01:00
ThibsG
7a55407cc3
Fix suggestions when call functions involved taking by ref
2021-11-20 09:40:11 +01:00
ThibsG
6d1ccbf466
Correct suggestion when dereferencing enough, calling a function
2021-11-20 09:40:11 +01:00
ThibsG
ac45a83ad5
Handle multiple reference levels into binding type and add more tests
2021-11-20 09:40:11 +01:00
ThibsG
788c9ccc93
Applying refactoring for simplified code
2021-11-20 09:40:11 +01:00
ThibsG
91dd9c46de
Handle other projection kinds
2021-11-20 09:40:11 +01:00
ThibsG
97783a8cb9
Return a struct and add applicability
2021-11-20 09:40:11 +01:00
ThibsG
d0dd797709
Build end of suggestion only once at the end of the process
2021-11-20 09:40:11 +01:00
ThibsG
9ab4b673eb
Simplifying next_pos
init
2021-11-20 09:40:11 +01:00
ThibsG
e24aba2c1a
Use applicability for snippets
2021-11-20 09:40:11 +01:00
ThibsG
6dca4f261d
Add some doc for search_is_some
lint
2021-11-20 09:40:11 +01:00
ThibsG
b38f173aa3
Build suggestion within visitor + add more tests
2021-11-20 09:40:10 +01:00
ThibsG
5ed93af9c4
Use ExprUseVisitor
and multipart suggestion to avoid iffy String
replacement
2021-11-20 09:40:10 +01:00
ThibsG
f4c75cde5e
Fix any()
not taking reference in search_is_some
lint
2021-11-20 09:40:10 +01:00
bors
6ac42fe6fa
Auto merge of #7971 - togami2864:fix/option-map-or-none, r=llogiq
...
fix suggestion in option_map_or_none
fix : #7960
changelog: change suggestion in the lint rule `option_map_or_none`
2021-11-17 16:01:55 +00:00
togami2864
006c442657
check whether stmts is empty or not in block
2021-11-18 00:36:11 +09:00
bors
46687f1313
Auto merge of #7896 - surechen:fix_manual_split_once, r=camsteffen
...
Fix for #7889 and add new lint needless_splitn
fixes : #7889
1. Fix the problem of manual_split_once changing the original behavior.
2. Add a new lint needless_splitn.
changelog: Fix the problem of manual_split_once changing the original behavior and add a new lint needless_splitn.
2021-11-17 01:46:58 +00:00
surechen
c051656c83
fixes : #7889
...
1. Fix the problem of manual_split_once changing the original behavior.
2. Add a new lint needless_splitn.
changelog: Fix the problem of manual_split_once changing the original behavior and add a new lint needless_splitn.
2021-11-17 08:38:45 +08:00
togami2864
7605bac2cb
resolve CI
2021-11-16 23:07:19 +09:00
Jason Newcomb
2938ffd0d9
Improve heuristics for determining whether eager of lazy evaluation is preferred
2021-11-15 20:54:13 -05:00
togami2864
0a30fdcd3c
move the let statement out of the macro
2021-11-16 03:02:08 +09:00
togami2864
300282c09a
fix fmt
2021-11-16 02:53:35 +09:00
togami2864
cd5781648a
add comment
2021-11-16 02:30:54 +09:00
togami2864
02e0726149
fix a bug that the closure arguments are not displayed
2021-11-16 02:29:02 +09:00
togami2864
bbffe825ed
add reduce_unit_expression
2021-11-16 02:06:31 +09:00
togami2864
2ed4a8a3e6
fix suggestion in option_map_or_none
2021-11-13 22:38:28 +09:00
xFrednet
d647696c1f
Added clippy::version
attribute to all normal lints
...
So, some context for this, well, more a story. I'm not used to scripting, I've never really scripted anything, even if it's a valuable skill. I just never really needed it. Now, `@flip1995` correctly suggested using a script for this in `rust-clippy#7813`...
And I decided to write a script using nushell because why not? This was a mistake... I spend way more time on this than I would like to admit. It has definitely been more than 4 hours. It shouldn't take that long, but me being new to scripting and nushell just wasn't a good mixture... Anyway, here is the script that creates another script which adds the versions. Fun...
Just execute this on the `gh-pages` branch and the resulting `replacer.sh` in `clippy_lints` and it should all work.
```nu
mv v0.0.212 rust-1.00.0;
mv beta rust-1.57.0;
mv master rust-1.58.0;
let paths = (open ./rust-1.58.0/lints.json | select id id_span | flatten | select id path);
let versions = (
ls | where name =~ "rust-" | select name | format {name}/lints.json |
each { open $it | select id | insert version $it | str substring "5,11" version} |
group-by id | rotate counter-clockwise id version |
update version {get version | first 1} | flatten | select id version);
$paths | each { |row|
let version = ($versions | where id == ($row.id) | format {version})
let idu = ($row.id | str upcase)
$"sed -i '0,/($idu),/{s/pub ($idu),/#[clippy::version = "($version)"]\n pub ($idu),/}' ($row.path)"
} | str collect ";" | str find-replace --all '1.00.0' 'pre 1.29.0' | save "replacer.sh";
```
And this still has some problems, but at this point I just want to be done -.-
2021-11-10 19:48:31 +01:00
Cameron Steffen
14d54f0f6e
Use Span::from_expansion instead of in_macro
2021-11-05 08:50:17 -05:00
flip1995
e674d0a599
Merge commit 'e18101137866b79045fee0ef996e696e68c920b4' into clippyup
2021-11-04 12:52:36 +00:00
Cameron Steffen
20fb7f2916
Update rustfmt
2021-10-24 12:52:38 -05:00
flip1995
7631fc5d82
Merge commit '91496c2ac6abf6454c413bb23e8becf6b6dc20ea' into clippyup
2021-10-21 13:11:36 +02:00
bors
3d9c4a655b
Auto merge of #7682 - Qwaz:uninit_vec, r=xFrednet
...
Implement uninit_vec lint
changelog: add the new lint [`uninit_vec`]
Fix #7681
2021-10-12 21:04:13 +00:00
Lukas Wirth
5adf17cb43
Bring manual_split_once
docs in line with other lint docs
2021-10-12 09:42:42 +02:00
Yechan Bae
759200b699
Handle PR feedbacks first round
2021-10-09 05:38:19 -04:00
Yechan Bae
452181c69d
Implement uninit_vec lint
2021-10-09 05:38:19 -04:00
flip1995
5cf4984872
Merge commit 'b7f3f7f6082679da2da9a0b3faf1b5adef3afd3b' into clippyup
2021-10-07 11:21:30 +02:00
flip1995
1f955158dd
Merge remote-tracking branch 'upstream/master' into rustup
2021-10-07 11:11:23 +02:00
Matthias Kaak
320ecb1f0b
Mentioned inspect
in lint description of suspicious_map
2021-10-05 19:40:15 +00:00
Matthias Kaak
7c82e78f30
improved help message for suspicious_map
2021-10-05 19:09:08 +00:00
hkalbasi
388a3d0983
Implement equatable if let lint
2021-10-04 22:16:42 +03:30
Cameron Steffen
e165c12932
Make diangostic item names consistent
2021-10-02 19:38:19 -05:00
flip1995
23d5457e6d
Merge commit 'cb7915b00c235e9b5861564f3be78dba330980ee' into clippyup
2021-09-28 18:03:12 +01:00
flip1995
707494eca9
Merge remote-tracking branch 'upstream/master' into rustup
2021-09-28 10:52:31 +01:00
Manish Goregaokar
067bfe3618
Rollup merge of #89216 - r00ster91:bigo, r=dtolnay
...
Consistent big O notation
This makes the big O time complexity notation in places with markdown support more consistent.
Inspired by #89210
2021-09-25 18:22:20 -07:00
r00ster91
7355376d5b
consistent big O notation
2021-09-24 12:44:28 +02:00
lengyijun
b68325ecf6
add #4546 test
2021-09-22 16:04:04 +08:00
jackh726
2a9a9ca829
Fix clippy
2021-09-16 00:12:56 -04:00
Camille GILLOT
ce1da849b0
Rebase fallout.
2021-09-11 17:52:39 +02:00
Jason Newcomb
4c1b6a28e4
Fix result order for manual_split_once
when rsplitn
is used
2021-09-10 13:05:09 -04:00
flip1995
091ed44b50
Merge commit '27afd6ade4bb1123a8bf82001629b69d23d62aff' into clippyup
2021-09-08 16:31:47 +02:00
flip1995
4962608ca6
Merge remote-tracking branch 'upstream/master' into rustup
2021-09-08 10:51:27 +02:00
xFrednet
62b46125cb
Avoid slice indexing in Clippy (down with the ICEs)
2021-09-05 14:50:13 +02:00
flip1995
61bb96738c
Merge remote-tracking branch 'upstream/master' into rustup2
2021-09-02 12:38:17 +01:00
Eduard-Mihai Burtescu
8f7c249980
rustc_target: move LayoutOf
to ty::layout
.
2021-09-02 01:17:14 +03:00
lcnr
b1786f62ed
add tcx
to fn walk
2021-08-26 11:00:30 +02:00
Jason Newcomb
aab3267412
Update docs for manual_split_once
2021-08-16 09:35:03 -04:00
Jason Newcomb
a7f376fbd3
Add lint manual_split_once
2021-08-16 09:34:58 -04:00
Caio
b97d4c062b
Introduce hir::ExprKind::Let - Take 2
2021-08-15 16:18:26 -03:00
dswij
91b598a8e4
Fix false positive on filter_next
2021-08-13 14:56:37 +08:00
flip1995
1ad5464200
Merge commit '7bfc26ec8e7a454786668e7e52ffe527fc649735' into clippyup
2021-08-12 11:16:25 +02:00
flip1995
d02016d686
Merge remote-tracking branch 'upstream/master' into rustup
2021-08-12 10:58:44 +02:00
bors
e62a6cad1e
Auto merge of #7516 - lf-:unwrap-or-default, r=xFrednet
...
Add `unwrap_or_else_default` lint
---
*Please write a short comment explaining your change (or "none" for internal only changes)*
changelog: Add a new [`unwrap_or_else_default`] style lint. This will catch `unwrap_or_else(Default::default)` on Result and Option and suggest `unwrap_or_default()` instead.
2021-08-12 08:02:44 +00:00
Jade
c78cc7ac1f
Add is_trait_item, refactor or_fun_call and unwrap_or_else_default
2021-08-10 14:40:26 -07:00
Jade
11ef04728c
Add unwrap_or_else_default lint
...
This will catch `unwrap_or_else(Default::default)` on Result and Option
and suggest `unwrap_or_default()` instead.
2021-08-10 14:40:26 -07:00
bors
14d2aa1582
Auto merge of #7542 - LeSeulArtichaut:cleanups, r=flip1995
...
Cleanup usage of `span_to_snippet` and `LintContext::sess`
- avoid using `SourceMap::span_to_snippet` directly and use `clippy_utils::source::snippet_opt` instead
- don't use `LintContext::sess()` on `EarlyContext`s which have a `sess` field directly available, saving the import of `LintContext`
changelog: none
2021-08-09 13:48:47 +00:00
LeSeulArtichaut
64ff2b05b9
Replace span_to_snippet
calls with snippet_opt
from clippy_utils
2021-08-07 01:59:05 +02:00
valentine-mario
8a4ffb881d
fixed bug that had to deal with mut and non mut suggestion
2021-08-05 16:15:44 +01:00
Dharma Saputra Wijaya
69d439065e
Handle Result
on map_flatten
lint
...
Adds a check on `.map(..).flatten()` on `Result` type that follows the
behaviour on `Option` type.
2021-08-01 17:47:54 +08:00
Vadim Petrochenkov
a1f790c8a9
Fix clippy
2021-07-31 19:31:30 +03:00
flip1995
2b20f49841
Merge commit '0cce3f643bfcbb92d5a1bb71858c9cbaff749d6b' into clippyup
2021-07-29 12:16:06 +02:00
flip1995
54e539121d
Rename two lints to comply with our lint naming convention
...
self_named_constructor -> self_named_constructors
append_instead_of_extend -> extend_with_drain
2021-07-29 12:10:18 +02:00
xFrednet
12c61612f7
Update lint documentation to use markdown headlines
2021-07-28 14:31:59 +02:00
flip1995
1d084b13a5
Merge commit '54a20a02ecd0e1352a871aa0990bcc8b8b03173e' into clippyup
2021-07-15 10:44:10 +02:00
xFrednet
6030428fd2
Use diagnostic items for Into
, IntoIterator
, LinkedList
, ptr::null
, prt::null_mut
2021-07-14 22:50:59 +02:00
xFrednet
2ac21889bc
Use diagnostic items for BinaryHeap
, BTreeMap
, BTreeSet
, HashMap
, HashSet
, Borrow
, Default
2021-07-14 22:02:59 +02:00
Cameron Steffen
e6ab222b81
Refactor format macro parsing
2021-07-13 08:57:16 -05:00
flip1995
ebe52869a3
Merge commit '61eb38aeda6cb54b93b872bf503d70084c4d621c' into clippyup
2021-07-01 18:17:38 +02:00
flip1995
a82a744155
Merge remote-tracking branch 'upstream/master' into rustup
2021-07-01 17:41:24 +02:00
Cameron Steffen
f02632cee6
Move some lints to suspicious
2021-06-25 08:53:29 -05:00
Joe Ranweiler
10122e4a48
Remove shadowed receiver in check invocation
2021-06-22 18:45:12 -07:00
Dirkjan Ochtman
a40fd6da7e
Move from-iter-instead-of-collect to pedantic
...
Since FromIterator will become part of the prelude, this lint being
warn by default is incongruous with the libs team position on the topic.
2021-06-18 22:23:25 +02:00
valentine-mario
44608b1857
added lint to check for full range of vector and suggest append
2021-06-10 09:12:06 +01:00
xFrednet
5336f88403
Move map_identity
into the methods
module
2021-06-08 19:56:59 +02:00
xFrednet
9e54ce865c
Reuse is_expr_identity_function
for filter_map_identity
2021-06-07 23:31:17 +02:00
xFrednet
bb3b58cfcc
Reuse is_expr_identity_function
for flat_map_identity
2021-06-07 23:20:11 +02:00
flip1995
6c27482115
Merge commit '3ae8faff4d46ad92f194c2a4b941c3152a701b31' into clippyup
2021-06-03 08:41:37 +02:00
Jason Newcomb
cfddf0927b
Fix type checks for manual_str_repeat
2021-05-31 09:37:13 -04:00
Jason Newcomb
97311f0906
Add lint manual_str_repeat
2021-05-30 23:26:48 -04:00
Jason Newcomb
5fa08eaf53
Evaluate constant expressions in suspicious_splitn
2021-05-30 13:25:24 -04:00
Jason Newcomb
898b6a0e07
Add lint suspicious_splitn
2021-05-30 09:49:55 -04:00
Cameron Steffen
d39a11cbe1
Remove clippy_utils::consts re-export
2021-05-27 08:52:10 -05:00
Cameron Steffen
d7f47f280e
Use break api config for wrong_pub_self_convention
2021-05-26 16:53:13 -05:00
mbartlett21
cadad20da1
Add semicolons up to needless_for_each.rs
2021-05-25 00:54:50 +00:00
Yotam Ofek
ae0d4da764
Fix invalid syntax in from_iter_instead_of_collect
suggestion with "as Trait"
2021-05-22 21:47:11 +03:00
flip1995
97705b7ea6
Merge commit '9e3cd88718cd1912a515d26dbd9c4019fd5a9577' into clippyup
2021-05-20 13:07:57 +02:00
ThibsG
cd241b33cb
Trigger wrong_self_convention
only if it has implicit self
2021-05-13 10:24:29 +02:00
Mateusz Gacek
ab3094b3db
wrong_self_convention: For to_*
variant don't lint in trait impl taking self
when non-Copy
type
...
It relaxes rules for `to_*` variant, so it doesn't lint in trait definitions
and implementations anymore.
Although, non-`Copy` type implementing trait's `to_*` method taking
`self` feels not good (consumes ownership, so should be rather named `into_`), it would be better if this case was a pedantic lint (allow-by-default) instead.
2021-05-06 10:49:31 -07:00
flip1995
d605882023
Merge commit 'b71f3405606d49b9735606b479c3415a0ca9810f' into clippyup
2021-05-06 12:20:44 +02:00
Cameron Steffen
d66d37303c
Fix unnecessary_filter_map false positive
2021-05-05 16:44:00 -05:00
Marcel Hellwig
19e7448c7f
move PATTERN_METHODS table directly into file
...
also removed rustfmt::skip
2021-05-03 16:25:05 +02:00
Marcel Hellwig
c080899848
add strip_{prefix,suffix} to PATTERN_METHODS
...
this will warn, if a single_char_pattern is used in one of the above
methods
2021-05-03 16:18:41 +02:00
flip1995
ae72f1adb9
Merge commit '7c7683c8efe447b251d6c5ca6cce51233060f6e8' into clippyup
2021-04-27 16:55:11 +02:00
bors
9af07e65aa
Auto merge of #7138 - mgacek8:issue6808_iter_cloned_collect_FN_with_large_array, r=Manishearth
...
Fix FN in `iter_cloned_collect` with a large array
fixes #6808
changelog: Fix FN in `iter_cloned_collect` with a large array
I spotted that [is_iterable_array](a362a4d1d0/clippy_lints/src/loops/explicit_iter_loop.rs (L67-L75)
) function that `explicit_iter_loop` lint is using only works for array sizes <= 32.
There is this comment:
> IntoIterator is currently only implemented for array sizes <= 32 in rustc
I'm a bit confused, because I read that [IntoIterator for arrays](https://doc.rust-lang.org/src/core/array/mod.rs.html#194-201 ) with const generic `N` is stable since = "1.0.0". Although Const Generics MVP were stabilized in Rust 1.51.
Should I set MSRV for the current change? I will try to test with older compilers soon.
2021-04-27 13:44:51 +00:00
Cameron Steffen
340b570ea0
Refactor MSRV aliases
2021-04-26 16:07:48 -05:00
Mateusz Gacek
d7627dcfc8
Fix FN in iter_cloned_collect
with a large array
2021-04-26 13:03:51 -07:00
Cameron Steffen
3f5be5e235
Fix cloned_instead_of_copied MSRV
2021-04-25 09:54:04 -05:00
flip1995
02bf692169
Merge commit '98e2b9f25b6db4b2680a3d388456d9f95cb28344' into clippyup
2021-04-22 11:31:13 +02:00
Cameron Steffen
5af078ac1b
Add flat_map_option lint
2021-04-16 15:23:49 -05:00
Cameron Steffen
0462666c70
Add cloned_instead_of_copied lint
2021-04-16 11:39:31 -05:00
Jason Newcomb
f6c5d8d599
Remove all usages of match_path
, match_qpath
and match_path_ast
except the author
lint.
...
Add note to fix `MATCH_TYPE_ON_DIAG_ITEM`
Add false negative test for `uninit_assumed_init`
2021-04-15 19:27:25 -04:00
Cameron Steffen
76bd5d232c
Refactor diagnostic item methods
2021-04-13 14:10:40 -05:00
bors
411c0df1d0
Auto merge of #7064 - ThibsG:WrongSelfFix, r=giraffate
...
Fix FP in `wrong_self_convention` lint
Previously, this lint didn't check into impl block when it was implementing a trait.
Recent improvements (#6924 ) have moved this check and some impl blocks are now checked but they shouldn't, such as in #7032 .
Fixes #7032
changelog: Fix FP when not taking `self` in impl block for `wrong_self_convention` lint
2021-04-12 14:16:17 +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
ThibsG
3ce6f0d022
Fix FP in wrong_self_convention
lint
2021-04-11 13:29:08 +02:00
Cameron Steffen
a45faf66f3
Deprecate filter_map
2021-04-10 16:59:59 -05:00
flip1995
f6d1f368db
Merge commit 'b40ea209e7f14c8193ddfc98143967b6a2f4f5c9' into clippyup
2021-04-08 17:50:13 +02:00
Cameron Steffen
7468542328
Introduce is_lang_ctor
2021-04-06 15:05:00 -05:00
Cameron Steffen
47f0c15f67
Symbol optimizations
2021-04-06 13:00:36 -05:00
Jason Newcomb
12fce55766
Fix all occurences of needless_borrow
internally
2021-04-06 10:43:47 -04: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
bors
9ce23730e2
Auto merge of #7016 - camsteffen:bind-map-paths, r=Manishearth
...
Remove paths from bind_instead_of_map
changelog: none
2021-04-02 15:10:24 +00:00
Cameron Steffen
08a8ad3a36
Remove paths from bind_instead_of_map
2021-04-01 15:41:25 -05: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
Cameron Steffen
827d6aaad4
Eat dogfood
2021-03-31 14:06:27 -05:00
Cameron Steffen
21083875d2
Destructure args in methods module
2021-03-31 13:25:55 -05: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
Eric Loren
56fbbf7b8f
Suggest flatten
instead of is_some
-> unwrap
2021-03-31 11:35:24 -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
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
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
Jason Newcomb
6e88900f9e
Rename contains_adt
to contains_adt_constructor
2021-03-24 16:23:02 -04:00
Jason Newcomb
99b8a67198
Fix false positive with new_ret_no_self
when returning Self
with different generic arguments
2021-03-24 16:22:28 -04:00
Takayuki Maeda
2f8d71b9dc
merge imports
2021-03-25 00:17:43 +09:00
bors
919a1a40fe
Auto merge of #6957 - camsteffen:eq-ty-kind, r=flip1995
...
Factor out `SpanlessEq::eq_ty_kind`
changelog: none
2021-03-23 16:25:28 +00:00
Cameron Steffen
9132dbdf31
Factor out eq_ty_kind
2021-03-23 10:49:12 -05:00
bors
b80903b727
Auto merge of #6950 - Sciencentistguy:master, r=phansch
...
Ignore str::len() in or_fun_call lint.
changelog: Changed `or_fun_call` to ignore `str::len`, in the same way it ignores `slice::len` and `array::len`
Closes #6943
2021-03-22 20:29:13 +00:00
bors
029777f029
Auto merge of #6896 - TaKO8Ki:refactor-lints-in-methods-module, r=phansch
...
Refactor lints in methods module
This PR refactors methods lints other than the lints I refactored in https://github.com/rust-lang/rust-clippy/pull/6826 and moves some functions to methods/utils.rs.
Basically, I follow the instruction described in #6680 .
**For ease of review, I refactored step by step, keeping each commit small.**
closes https://github.com/rust-lang/rust-clippy/issues/6886
cc: `@phansch,` `@flip1995,` `@Y-Nak`
changelog: Move lints in methods module to their own modules and some function to methods/utils.rs.
2021-03-22 19:36:22 +00:00
Jamie Quigley
45e775697e
Ignore str::len() in or_fun_call lint.
2021-03-22 19:34:20 +00:00
Mateusz Gacek
2ffee89b75
search_is_some: check also when search is none
2021-03-21 21:23:36 +01:00
bors
1d3c539fbb
Auto merge of #6924 - mgacek8:issue6727_copy_types, r=llogiq
...
wrong_self_convention: `to_` convention respects `Copy` types
fixes #6727
changelog: wrong_self_convention: `to_` convention respects `Copy` types
2021-03-20 06:59:13 +00:00
Mateusz Gacek
1f2d01641d
wrong_self_convention: Enhance lint message
2021-03-19 20:29:55 +01:00
bors
36aee1c526
Auto merge of #6928 - mgacek8:issue6675_or_fun_call_unsafe_blocks, r=phansch
...
or_fun_call: trigger on unsafe blocks
fixes #6675
changelog: or_fun_call: trigger on unsafe blocks
2021-03-18 15:55:06 +00:00
Mateusz Gacek
b1f89ee02f
or_fun_call: trigger on unsafe blocks
2021-03-18 08:44:15 +01:00
Mateusz Gacek
ea15fb2177
wrong_self_convention: to_
respects Copy
types
...
More details here:
https://rust-lang.github.io/api-guidelines/naming.html#ad-hoc-conversions-follow-as_-to_-into_-conventions-c-conv
2021-03-17 22:00:46 +01:00
Takayuki Maeda
b6a2757561
replace crate::methods::utils with super::utils
2021-03-18 01:23:37 +09:00
Takayuki Maeda
0edd5f881d
remove the use of paths
2021-03-18 01:06:24 +09:00
Takayuki Maeda
602bcf3e4f
move get_hint_if_single_char_arg to methods/utils.rs
2021-03-18 00:59:45 +09:00
Takayuki Maeda
27963c8dce
move chars_last_cmp_with_unwrap to its own module
2021-03-18 00:59:45 +09:00
Takayuki Maeda
4d1f2bc565
extract conditions for single_char_pattern into its own module
2021-03-18 00:59:44 +09:00
Takayuki Maeda
7a7fcc0eda
extract condition for into_iter_on_ref to its own module
2021-03-18 00:59:43 +09:00
Takayuki Maeda
d380769952
extract conditions for from_iter_instead_of_collect
into its own module
2021-03-18 00:58:35 +09:00
Takayuki Maeda
62490c41af
extract conditions into modules
2021-03-18 00:51:49 +09:00
Takayuki Maeda
3d9b45df0f
move single_char_add_str to its own module
2021-03-18 00:51:18 +09:00
Takayuki Maeda
4843084946
use clippy_utils::ty::is_type_diagnostic_item
2021-03-18 00:51:18 +09:00
Takayuki Maeda
f0f7871920
fmt
2021-03-18 00:51:18 +09:00
Takayuki Maeda
b6597eec0b
remove unused arguments
2021-03-18 00:51:18 +09:00
Takayuki Maeda
0c81311bf0
extract a condition into a function.
2021-03-18 00:51:18 +09:00
Takayuki Maeda
f0a101d81d
remove a needless variable
2021-03-18 00:51:18 +09:00
Takayuki Maeda
1bec8b6065
use derefs_to_slice in methods/utils.rs
2021-03-18 00:51:16 +09:00
Takayuki Maeda
e578a536c7
move derefs_to_slice to methods/utils.rs
2021-03-18 00:49:50 +09:00
Takayuki Maeda
c07c046b31
refactor string_extend_chars: return when obj type is not string
2021-03-18 00:49:50 +09:00
Takayuki Maeda
058d8c878a
move chars_cmp_with_unwrap, chars_last_cmp and chars_next_cmp_with_unwrap to their own modules
2021-03-18 00:49:48 +09:00
Takayuki Maeda
94fb2b58a3
move chars_cmp and chars_next_cmp to its own modules
2021-03-18 00:49:03 +09:00
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