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