Cameron Steffen
5f887d09b8
Add if_chain lints
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
bors
c1021b806c
Auto merge of #6706 - Y-Nak:excessive-for-each, r=camsteffen
...
New Lint: needless_for_each
resolves : #6543
changelog: Added pedantic lint: `needless_for_each`
2021-03-31 15:59:55 +00:00
Eric Loren
56fbbf7b8f
Suggest flatten
instead of is_some
-> unwrap
2021-03-31 11:35:24 -04:00
Yoshitomo Nakanishi
e61f9782c8
Tweak a suggestion message of needless_for_each
2021-04-01 00:08:59 +09:00
Yoshitomo Nakanishi
bf1e3f7a9f
Skip needless_for_each if an input stmt is local
2021-04-01 00:05:42 +09:00
Yoshitomo Nakanishi
f2cc995bcf
Remove method_calls
2021-04-01 00:05:42 +09:00
Yoshitomo Nakanishi
527fbbef48
Refactor excessive_for_each
2021-04-01 00:05:42 +09:00
Yoshitomo Nakanishi
5543c34699
Use ".." as default value of snippet in excessive_for_each
2021-04-01 00:05:42 +09:00
Yoshitomo Nakanishi
3843171299
Improve the document of excessive_for_each
2021-04-01 00:05:42 +09:00
Yoshitomo Nakanishi
25d8b94cec
Add comments to clarify why RetCollector is needed
2021-04-01 00:05:42 +09:00
Yoshitomo Nakanishi
ccd7a60023
Refactor: Remove duplicated codes from excessive_for_each
2021-04-01 00:05:42 +09:00
Yoshitomo Nakanishi
90cbbb2da3
Avoid to suggest using label
2021-04-01 00:05:42 +09:00
Yoshitomo Nakanishi
5bb0f16552
Trigger the lint iff exposure's body is ExprKind::Block.
2021-04-01 00:05:42 +09:00
Yoshitomo Nakanishi
54a04711ed
Change a category of excessive_for_each: Style -> Restriction
2021-04-01 00:05:42 +09:00
Yoshitomo Nakanishi
30952530c5
Fix codes that fails dogfood
2021-04-01 00:05:42 +09:00
Yoshitomo Nakanishi
5029dc805f
New Lint: excessive_for_each
2021-04-01 00:05:42 +09:00
bors
3e42c35b72
Auto merge of #6981 - matthiaskrgr:6803_take_2, r=flip1995
...
disable upper_case_acronyms for pub items - enum edition
Fixes https://github.com/rust-lang/rust-clippy/issues/6803 (again... 😅 )
My previous fix did not work for enums because enum variants were checked separately in the `check_variant` function but it looks like we can't use that because we can't tell if the enum the variants belong to is declared as public or not (it always said `Inherited` for me)
I went and special-cased enums and iterated over all the variants "manually", but only, if the enums is not public.
---
changelog: fix upper_case_acronyms still firing on public enums (#6803 )
2021-03-31 15:02:40 +00:00
bors
2e33bf6347
Auto merge of #6938 - Y-Nak:refactor-types, r=flip1995
...
Refactor types
r? `@flip1995`
This is the last PR to close #6724 🎉
Also, this fixes #6936 .
changelog: `vec_box`: Fix FN in `const` or `static`
changelog: `linkedlist`: Fix FN in `const` or `static`
changelog: `option_option`: Fix FN in `const` or `static`
2021-03-31 14:35:48 +00:00
Jack Huey
b438e30fa6
Track bound vars
2021-03-31 10:15:27 -04:00
Michael Wright
8abab5561c
Fix hidden variant suggestion on single variant
...
Fixes #6984
2021-03-31 07:36:09 +02:00
bors
0b76719638
Auto merge of #7007 - Y-Nak:result_unit_err, r=giraffate
...
result_unit_err: Fix typo
changelog: result_unit_err: fix typo in a diagnostic message
r? `@giraffate`
fixes https://github.com/rust-lang/rust-clippy/pull/6990#discussion_r603292920 .
2021-03-31 04:01:15 +00:00
Yoshitomo Nakanishi
45164de59f
result_unit_err: Fix typo
2021-03-31 11:18:48 +09:00
bors
4be72b0936
Auto merge of #7001 - ebobrow:non-octal-file-permissions, r=Manishearth
...
Add non_octal_unix_permissions lint
fixes #6934
changelog: add new lint that checks for non-octal values used to set unix file permissions
2021-03-30 23:23:50 +00:00
Elliot Bobrow
7fcd155712
Add non_octal_unix_permissions lint
2021-03-30 16:04:16 -07:00
Camille GILLOT
d121b34e99
Remove hir::CrateItem.
2021-03-30 20:31:06 +02:00
Jason Newcomb
cc7f1daab2
Don't lint manual_map
in const functions
2021-03-30 10:56:08 -04:00
bors
44bf60f62d
Auto merge of #7004 - Jarcho:manual_map_if_then_else, r=camsteffen
...
Fix `manual_map` at the end of an if chain
changelog: Fix `manual_map` suggestion at the end of an if chain
2021-03-30 14:03:54 +00:00
Jason Newcomb
fa689f865e
Fix manual_map
at the end of an if chain
2021-03-30 09:58:23 -04:00
Mateusz Gacek
6966c78be7
wrong_self_convention: fix FP inside trait impl for to_*
method
...
When the `to_*` method takes `&self` and it is a trait implementation,
we don't trigger the lint.
2021-03-29 23:46:03 -07:00
bors
0552852d9a
Auto merge of #7000 - Jarcho:clone_on_copy_fp, r=llogiq
...
Improve `clone_on_copy`
This also removes the `clone_on_copy_mut` test as the same thing is covered in the `clone_on_copy` test.
changelog: `copy_on_clone` lint on chained method calls taking self by value
changelog: `copy_on_clone` only lint when using the `Clone` trait
changelog: `copy_on_clone` correct suggestion when the cloned value is a macro call.
2021-03-30 05:25:28 +00:00
bors
1ddeaa6356
Auto merge of #6990 - Y-Nak:refactor-functions, r=giraffate
...
Organize functions into functions module
Ref: #6680
Rearrange lints in `functions`.
changelog: none
2021-03-30 03:59:45 +00:00
Yoshitomo Nakanishi
541c8b8f69
Improve documents in functions group
2021-03-30 11:45:54 +09:00
Jason Newcomb
d2657769a2
Improve clone_on_copy
...
Lint on `_.clone().method()` when method takes self by value
Set applicability correctly
Correct suggestion when the cloned value is a macro call. e.g. `m!(x).clone()`
Don't lint when not using the `Clone` trait
2021-03-29 16:10:37 -04:00
Yoshitomo Nakanishi
31afdfc12b
missing_panics_doc: Ignore usage of debug_assert family
2021-03-29 17:20:04 +09:00
bors
c07103b4a2
Auto merge of #6993 - Jarcho:expl_impl_clone, r=llogiq
...
Improve `expl_impl_clone_on_copy`
fixes : #1254
changelog: Check to see if the generic constraints are the same as if using derive for `expl_impl_clone_on_copy`
2021-03-28 23:30:56 +00:00
Jason Newcomb
879fa5c972
Improve expl_impl_clone_on_copy
...
Check to see if the generic constraints are the same as if using derive
2021-03-28 07:54:00 -04:00
ThibsG
6985d13a97
Take into account sub modules
2021-03-28 09:37:59 +02:00
ThibsG
1768efa333
Fix FP in single_component_path_imports
lint
2021-03-28 09:37:05 +02:00
Joshua Nelson
a57a8c3058
Remove (lots of) dead code
...
Found with https://github.com/est31/warnalyzer .
Dubious changes:
- Is anyone else using rustc_apfloat? I feel weird completely deleting
x87 support.
- Maybe some of the dead code in rustc_data_structures, in case someone
wants to use it in the future?
- Don't change rustc_serialize
I plan to scrap most of the json module in the near future (see
https://github.com/rust-lang/compiler-team/issues/418 ) and fixing the
tests needed more work than I expected.
TODO: check if any of the comments on the deleted code should be kept.
2021-03-27 22:16:33 -04:00
Matthias Krüger
e006c77d61
redundant_pattern_matching: look inside Refs
...
look inside refs and detect if let &None = ...
Fixes https://github.com/rust-lang/rust-clippy/issues/5396
changelog: redundant_pattern_matching: look inside Refs to fix FNs with "if let &None = .. "
2021-03-28 00:04:44 +01:00
Yoshitomo Nakanishi
add3e5094f
Move result_unit_err to its own module
2021-03-27 22:49:55 +09:00
Yoshitomo Nakanishi
c37916501d
Move lints related to must_use to their own module
2021-03-27 22:49:55 +09:00
Yoshitomo Nakanishi
9782fc4285
move not_unsafe_ptr_arg_deref to its own module
2021-03-27 22:49:55 +09:00
Yoshitomo Nakanishi
7c028de05f
Move too_many_lines to its own module
2021-03-27 22:49:55 +09:00
Yoshitomo Nakanishi
febf34e2b4
Move too_many_arguments to its own module
2021-03-27 22:49:55 +09:00
bors
8e56a2b27f
Auto merge of #6979 - flip1995:msrv_doc_fix, r=giraffate
...
Add missing lints to MSRV config doc
r? `@giraffate`
changelog: Add missing lints to MSRV config doc
2021-03-27 13:27:51 +00:00
bors
dcee00d64b
Auto merge of #6980 - Jarcho:len_without_is_empty_sig, r=llogiq
...
`len_without_is_empty` improvements
fixes : #6958
fixes : #6972
changelog: Check the return type of `len`. Only integral types, or an `Option` or `Result` wrapping one.
changelog: Ensure the return type of `is_empty` matches. e.g. `Option<usize>` -> `Option<bool>`
2021-03-27 13:10:43 +00:00
Jason Newcomb
12985afbca
len_without_is_empty
improvements
...
Check the return type of `len`. Only integral types, or an `Option` or `Result` wrapping one.
Ensure the return type of `is_empty` matches. e.g. `Option<usize>` -> `Option<bool>`
2021-03-27 09:04:44 -04:00
Matthias Krüger
ca7e95501c
upper_case_acronyms: add ui and ui-toml tests for private/public enums
2021-03-27 01:08:14 +01:00
Matthias Krüger
4e19d406a9
upper_case_acronyms: only lint enum variants if the enum is not public
2021-03-27 00:44:30 +01:00
Josh Stone
0dddfbf9bf
Use iter::zip in src/tools/clippy/
2021-03-26 09:33:38 -07:00
flip1995
5351bbfbf5
Add missing lints to MSRV config doc
2021-03-26 16:58:06 +01:00
bors
6f2a6fe84f
Auto merge of #6977 - flip1995:or_patterns_msrv, r=llogiq
...
Add MSRV options to `unnested_or_patterns`
changelog: [`unnested_or_patterns`] can now be configured with the `msrv` config/attribute.
Fixes #6953
2021-03-26 15:12:50 +00:00
flip1995
1a1adad81d
Add MSRV option to unnested_or_patterns lint
2021-03-26 14:36:09 +01:00
Yoshitomo Nakanishi
818f8320a3
Merge type_complexity pass into types pass
2021-03-26 20:22:07 +09:00
Yoshitomo Nakanishi
494bc8a30c
Fix FN that types lints don't work with const or static
2021-03-26 20:19:34 +09:00
Yoshitomo Nakanishi
dad39b6613
Move implicit_hasher to its own module
2021-03-26 20:18:37 +09:00
Yoshitomo Nakanishi
f231b59b9e
Move invalid_upcast_comparisons to its own module
2021-03-26 20:18:37 +09:00
Yoshitomo Nakanishi
caa49c85d6
Move absurd_extreme_comparisons to its own module
2021-03-26 20:18:37 +09:00
Jason Newcomb
0ff68bb151
Improve redundant_slicing
...
Fix bad suggestion when a reborrow might be required
Fix bad suggestion when the value being sliced is a macro call
Don't lint inside of a macro due to the previous context sensitive changes
2021-03-25 22:30:14 -04:00
flip1995
9f6b5de7de
Merge commit '0e87918536b9833bbc6c683d1f9d51ee2bf03ef1' into clippyup
2021-03-25 19:29:11 +01:00
flip1995
40e68e5956
Bump Clippy Version -> 0.1.53
2021-03-25 18:48:48 +01:00
flip1995
1f5f184105
Merge remote-tracking branch 'upstream/master' into rustup
2021-03-25 18:38:13 +01:00
bors
981ffa7c14
Auto merge of #6959 - ebobrow:iss-6927-fix, r=camsteffen
...
Check for `.to_string().into_bytes()` in string_lit_to_bytes
fixes #6927
changelog: Add a check for `into_bytes()` to string_lit_to_bytes lint
2021-03-25 03:01:35 +00:00
Elliot Bobrow
e9ebc27525
check for .to_string().into_bytes()
in string_lit_to_bytes
...
apply changes from review
2021-03-24 17:31:20 -07: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
Takayuki Maeda
3b8e85a5dc
fix false positive in manual_flatten
2021-03-25 00:15:21 +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
2bc180e888
Auto merge of #79278 - mark-i-m:stabilize-or-pattern, r=nikomatsakis
...
Stabilize or_patterns (RFC 2535, 2530, 2175)
closes #54883
This PR stabilizes the or_patterns feature in Rust 1.53.
This is blocked on the following (in order):
- [x] The crater run in https://github.com/rust-lang/rust/pull/78935#issuecomment-731564021
- [x] The resolution of the unresolved questions and a second crater run (https://github.com/rust-lang/rust/pull/78935#issuecomment-735412705 )
- It looks like we will need to pursue some sort of edition-based transition for `:pat`.
- [x] Nomination and discussion by T-lang
- [x] Implement new behavior for `:pat` based on consensus (https://github.com/rust-lang/rust/pull/80100 ).
- [ ] An FCP on stabilization
EDIT: Stabilization report is in https://github.com/rust-lang/rust/pull/79278#issuecomment-772815177
2021-03-22 19:48:27 +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
bors
aca95aac7b
Auto merge of #6942 - mgacek8:issue_6815_search_is_none, r=llogiq
...
search_is_some: add checking for `is_none()`
fixes : #6815
changelog: search_is_some: add checking for `is_none()`.
To be honest I don't know what is the process of renaming the lints. Appreciate any feedback if that needs to be handled differently. Thanks!
2021-03-22 12:58:47 +00:00
Mateusz Gacek
2ffee89b75
search_is_some: check also when search is none
2021-03-21 21:23:36 +01:00
ThibsG
3ddaabcbc9
Fix suggestion with generics for field_reassign_with_default
lint
2021-03-21 09:58:04 +01:00
bors
0bdaa77d95
Auto merge of #6941 - ThibsG:suggMatchSingleBinding, r=llogiq
...
Fix bad suggestion for `match_single_binding` lint
Fix a bad suggestion that needs curly braces when the target `match` is the body of an arm.
Fixes #6572
changelog: none
2021-03-20 17:35:21 +00:00
lcnr
731c98b16b
update const_eval_resolve
2021-03-20 17:22:24 +01:00
ThibsG
00a2d7ad7e
Fix bad suggestion that needs curly braces for match_single_binding
lint
2021-03-20 16:11:19 +01:00
ThibsG
296751f643
Fix bad suggestion for generics in new_without_default
lint
2021-03-20 10:24:10 +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
mark
d2f0b27f0a
clippy: stabilize or_patterns lint
2021-03-19 19:45:42 -05:00
Mateusz Gacek
1f2d01641d
wrong_self_convention: Enhance lint message
2021-03-19 20:29:55 +01:00
Matthias Krüger
b42ec5e04d
needless_question_mark: don't lint if Some(..) is inside a macro def and the ? is not.
...
The suggestion would fail to apply.
Fixes #6921
changelog: needless_question_mark: don't lint if Some(..) is inside a macro def and the ? is not.
2021-03-18 23:47:21 +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
bors
4d686196b9
Auto merge of #6863 - Jarcho:wild_enum_match, r=llogiq
...
`match_wildcard` improvements
fixes : #6604
fixes : #5733
fixes : #6862
#5733 is only fixed in the normal case, if different paths are used for the variants then the same problem will occur. It's cause by `def_path_str` returning an utterly useless result. I haven't dug into why yet.
For #6604 there should be some discussion before accepting this. It's easy enough to change the message rather than disable the lint for `Option` and `Result`.
changelog: Attempt to find a common path prefix for `match_wildcard_for_single_variants` and `wildcard_enum_match_arm`
changelog: Don't lint op `Option` and `Result` for `match_wildcard_for_single_variants` and `wildcard_enum_match_arm`
changelog: Consider `or` patterns and `Self` prefix for `match_wildcard_for_single_variants` and `wildcard_enum_match_arm`
2021-03-18 10:39:28 +00:00
Mateusz Gacek
b1f89ee02f
or_fun_call: trigger on unsafe blocks
2021-03-18 08:44:15 +01:00
Vadim Petrochenkov
2c4570c958
hir: Preserve used syntax in TyKind::TraitObject
2021-03-18 03:02:32 +03: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
bors
b62694b08f
Auto merge of #82122 - bstrie:dep4real, r=dtolnay
...
Deprecate `intrinsics::drop_in_place` and `collections::Bound`, which accidentally weren't deprecated
Fixes #82080 .
I've taken the liberty of updating the `since` values to 1.52, since an unobservable deprecation isn't much of a deprecation (even the detailed release notes never bothered to mention these deprecations).
As mentioned in the issue I'm *pretty* sure that using a type alias for `Bound` is semantically equivalent to the re-export; [the reference implies](https://doc.rust-lang.org/reference/items/type-aliases.html ) that type aliases only observably differ from types when used on unit structs or tuple structs, whereas `Bound` is an enum.
2021-03-17 19:39:03 +00:00
Jason Newcomb
f468d82283
Fix manual_map
suggestion for if let.. else ... if let.. else
chain
2021-03-17 12:57:42 -04:00
bors
56138ad789
Auto merge of #83188 - petrochenkov:field, r=lcnr
...
ast/hir: Rename field-related structures
I always forget what `ast::Field` and `ast::StructField` mean despite working with AST for long time, so this PR changes the naming to less confusing and more consistent.
- `StructField` -> `FieldDef` ("field definition")
- `Field` -> `ExprField` ("expression field", not "field expression")
- `FieldPat` -> `PatField` ("pattern field", not "field pattern")
Various visiting and other methods working with the fields are renamed correspondingly too.
The second commit reduces the size of `ExprKind` by boxing fields of `ExprKind::Struct` in preparation for https://github.com/rust-lang/rust/pull/80080 .
2021-03-17 16:49:46 +00:00
Jason Newcomb
d5a7941ead
Fix message for match_wildcard_for_single_variant
2021-03-17 12:42:18 -04: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
Jason Newcomb
0b7ab90eca
Improvements to match_wildcard_for_single_variants
and wildcard_enum_match_arm
lints
...
Don't lint on `Result` and `Option` types.
Considers `or` patterns.
Considers variants prefixed with `Self`
Suggestions will try to find a common prefix rather than just using the full path
2021-03-17 12:04:11 -04:00
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
565400d1f9
Add clippy_utils::paths imports
2021-03-17 09:31:20 -05:00
Cameron Steffen
0743e841f0
Don't re-export clippy_utils::*
2021-03-17 09:13:52 -05:00
bors
8af28840d2
Auto merge of #6805 - matthiaskrgr:uca_nopub_6803, r=flip1995
...
upper_case_acronyms: don't warn on public items
Fixes #6803
changelog: upper_case_acronyms: ignore public items
2021-03-17 10:53:02 +00:00
bors
d695bfc56f
Auto merge of #6821 - Jarcho:write_literal_suggestion, r=flip1995
...
Write literal suggestion
fixes : #6768
changelog: Add suggestion to `write_literal` and `print_literal` lints
changelog: Change `use_debug` to point only at the format string
2021-03-17 09:49:20 +00:00
bors
56161b2982
Auto merge of #6917 - MysteryJump:fix-manual-unwrap-or-const-fn, r=giraffate
...
Fix false-positive `manual_unwrap_or` inside const fn
Fixes #6898
changelog: Fix false-positive for manual_unwrap_or in const fn.
2021-03-17 04:34:15 +00:00
Jason Newcomb
d45873b4c1
Remove SmallVec
2021-03-16 12:27:21 -04:00
Jason Newcomb
a7fa2a6fa8
Add suggestion to write_literal
and print_literal
...
Don't lint on a mixture of raw and regular strings
Fix spans in format strings
2021-03-16 12:13:46 -04:00
Jason Newcomb
4c1047167d
More specific spans for use_debug
lint
2021-03-16 12:10:40 -04:00
Jason Newcomb
4450c21f51
Keep track of spans in format strings
2021-03-16 12:10:31 -04:00
Yukio Tanaka
02ceeb59d4
Use in_constant instead of is_const
2021-03-17 00:06:42 +09:00
flip1995
bdf2dceec1
Get rid of some unused dependecies
2021-03-16 14:51:57 +01:00
Yukio Tanaka
c5b3a719ed
Fix FP of manual_unwrap_or
in const fn
2021-03-16 19:46:40 +09:00
Vadim Petrochenkov
e72d28352c
ast: Reduce size of ExprKind
by boxing fields of ExprKind::Struct
2021-03-16 11:41:24 +03:00
Vadim Petrochenkov
35e8be7407
ast/hir: Rename field-related structures
...
StructField -> FieldDef ("field definition")
Field -> ExprField ("expression field", not "field expression")
FieldPat -> PatField ("pattern field", not "field pattern")
Also rename visiting and other methods working on them.
2021-03-16 11:41:24 +03:00
Yoshitomo Nakanishi
5a439f5a82
Remove unit_types::utils::is_unit
2021-03-16 11:28:53 +09:00
Yoshitomo Nakanishi
6211b49ac1
Move unit_arg to its own module
2021-03-16 11:28:53 +09:00
Yoshitomo Nakanishi
1bb221243b
Move unit_cmp to its own module
2021-03-16 11:27:42 +09:00
Yoshitomo Nakanishi
d17f54538f
Move let_unit_value to its own module
2021-03-16 11:27:02 +09:00
Yoshitomo Nakanishi
37bffb7797
Extract utility functions to utils.rs
2021-03-16 11:25:46 +09:00
Yoshitomo Nakanishi
ecbef77bd7
Extract lints of unit_types group from types group
2021-03-16 11:25:46 +09: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
Roxane
9d5daa6f45
Fix error after rebase
2021-03-15 13:16:18 -04:00
Roxane
7926664876
Add comments with examples and tests
2021-03-15 13:16:04 -04:00
Roxane
0ab2bcd182
Add fake_read() to clippy
2021-03-14 19:45:24 -04:00
Ben Boeckel
ecf0c76c36
Fix suspicious_map false positives
2021-03-14 16:31:55 -05:00
bors
52c25e9136
Auto merge of #6895 - iobtl:reformat_unnecessary_cast, r=llogiq
...
replace span_lint with span_lint_and_sugg along with error message
fixes : #6874
changelog: none
apologies if this may not be the most idiomatic way of doing it, any advice on changes (if any) would be greatly appreciated.
2021-03-14 15:01:01 +00:00
iobtl
1054eb0c85
use lint_unnecessary_cast for literals, suggest _
if not present
2021-03-14 08:09:08 +08:00
bors
781de34222
Auto merge of #6859 - magurotuna:if_then_some_else_none, r=giraffate
...
Implement new lint: if_then_some_else_none
Resolves #6760
changelog: Added a new lint: `if_then_some_else_none`
2021-03-13 15:54:54 +00:00
bors
92b9677864
Auto merge of #6820 - mgacek8:issue_6562_enhance_mem_replace_with_default_with_other_ctors, r=phansch
...
mem_replace_with_default: recognize some std library ctors
fixes #6562
changelog: mem_replace_with_default: recognize some common constructors equivalent to `Default::default()`
2021-03-13 15:43:00 +00:00
Jason Newcomb
2713ad4342
Properly lint macro arguments for explicit_deref_methods
2021-03-13 08:40:01 -05:00
Jason Newcomb
704f7a8e50
Keep track of whether deref
or deref_mut
was called
...
Remove more unnecessary code
2021-03-13 08:39:59 -05:00
Jason Newcomb
1666e43cc0
Remove unneeded code.
2021-03-13 08:39:56 -05:00
Jason Newcomb
a261bc5fad
Make explicit_deref_methods
check for multiple deref calls
...
Fix suggestion for `explicit_deref_methods`. Sometimes `&**` is needed, sometimes nothing is needed.
Allow `explicit_deref_methods` to trigger in a few new contexts.
`explicit_deref_methods` will now consider ufcs calls
2021-03-13 08:39:48 -05:00
iobtl
6d2236f503
replace span_lint with span_lint_and_sugg along with error message
2021-03-13 16:54:59 +08:00
bors
65d046c9ad
Auto merge of #6892 - matthiaskrgr:inc_struct_ctor, r=Y-Nak
...
inconsistent_struct_constructor: try to make message and lint description a bit clearer
changelog: inconsistent_struct_constructor: try to make message and lint description a bit clearer
r? `@ghost`
2021-03-13 04:52:40 +00:00
Mateusz Gacek
41be515062
mem_replace_with_default: use diagnostic items intead of paths
2021-03-12 13:03:07 -08:00
Mateusz Gacek
c86ba7f92d
mem_replace_with_default: recognize some std library ctors
2021-03-12 12:57:54 -08:00
Matthias Krüger
6bc5fe4a88
inconsistent_struct_constructor: try to make message and lint description a bit clearer
2021-03-12 20:41:43 +01:00
Yoshitomo Nakanishi
93ee80ac3e
Use sym::Iterator instead of paths::ITERATOR
2021-03-13 02:10:54 +09:00
flip1995
a189df12bd
Clippy: HACK! Fix bootstrap error
...
This will be removed in the next sync, once beta is at 1.52. Until then
this hack avoids to put `cfg(bootstrap)` into Clippy.
2021-03-12 15:32:35 +01:00
flip1995
f2f2a005b4
Merge commit '6ed6f1e6a1a8f414ba7e6d9b8222e7e5a1686e42' into clippyup
2021-03-12 15:30:50 +01:00
Yusuke Tanaka
11d2af7e96
Improve suggestion and make it work for macros
2021-03-12 20:46:46 +09: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
bors
8222d48cde
Auto merge of #6814 - hyd-dev:issue-6486, r=flip1995
...
Fix false positives on procedural macros of `missing_inline_in_public_items` lint
Fixes #6486 .
changelog: Fix false positives on procedural macros of `missing_inline_in_public_items` lint.
2021-03-10 16:40:33 +00:00
bors
a1e25a957e
Auto merge of #6794 - camsteffen:needless-borrowed-ref, r=flip1995
...
Improve needless_borrowed_ref docs
changelog: none
I think "borrowed ref" is a confusing description for this lint. Destructuring a reference is the opposite of borrowing. So I updated the wording throughout the docs. Unfortunately this nit applies to the name of the lint itself, but I won't bother changing that. One motivation for these changes is to clarify the difference between this lint and `needless_borrow` (they are actually quite different). Let me know if I need to clarify anything or if you disagree with any changes.
2021-03-10 16:27:18 +00:00
bstrie
7406c12885
Deprecate items that accidentally weren't deprecated
...
Fixes #82080
2021-03-09 19:09:20 -05:00
Camille GILLOT
6c668266c0
Remove hir::Expr::attrs.
2021-03-09 19:27:58 +01:00
Camille GILLOT
dc9560cfd2
Remove hir::Item::attrs.
2021-03-09 19:27:50 +01:00
Camille GILLOT
49835d8abf
Remove hir::ImplItem::attrs.
2021-03-09 19:23:08 +01:00
Camille GILLOT
dd2af148cc
Remove hir::TraitItem::attrs.
2021-03-09 19:23:08 +01:00
Camille GILLOT
c3a17dba6c
Remove hir::StructField::attrs.
2021-03-09 19:23:07 +01:00
Camille GILLOT
55f68ead6b
Remove hir::Variant::attrs.
2021-03-09 19:23:06 +01:00
Camille GILLOT
04496071e4
Remove hir::Arm::attrs.
2021-03-09 19:23:05 +01:00
Camille GILLOT
b32cffe493
Remove hir::Crate::attrs.
2021-03-09 19:22:55 +01:00
Camille GILLOT
acd6014b80
Remove hir::Local::attrs.
2021-03-09 19:09:35 +01:00
Camille GILLOT
3e721b1445
Remove hir::StmtKind::attrs.
2021-03-09 19:09:35 +01:00
Camille GILLOT
476c5283d5
Do not store attrs in FnKind.
2021-03-09 19:09:33 +01:00
Camille GILLOT
8d5e0f512f
Simplify clippy author.
2021-03-09 19:09:32 +01:00
flip1995
8e1ce480b9
Set Clippy authors to "The Rust Clippy Developers"
...
Clippy has grown enough, that putting specific people in the "authors"
field is warranted anymore.
2021-03-09 17:50:04 +01:00
Takayuki Nakata
e0f982bb3e
Improve doc on map_flatten
2021-03-10 00:02:24 +09:00
bors
627e910fe5
Auto merge of #6868 - Jarcho:lang_item, r=flip1995
...
Don't assume lang items will exist.
~~Should fix lintcheck warnings caused by #6823~~
See below
changelog: None
2021-03-09 14:28:49 +00:00
bors
3ed0bccb70
Auto merge of #6873 - Y-Nak:refactor-casts-lint, r=flip1995
...
Refactor casts lint
Ref: #6724
Changes:
1. Separate the `casts` group from the `types` group.
2. Reorganize the lints of the `casts` group into their own modules.
Notes:
1. I didn't `fix` #6874 in order to maintain this PR as small as possible.
---
changelog: none
2021-03-09 12:43:20 +00:00
Yoshitomo Nakanishi
9e631da454
Move ptr_as_ptr to its own module
2021-03-09 20:18:25 +09:00
Mara Bos
824662d78a
Rollup merge of #82048 - mark-i-m:or-pat-type-ascription, r=petrochenkov
...
or-patterns: disallow in `let` bindings
~~Blocked on https://github.com/rust-lang/rust/pull/81869~~
Disallows top-level or-patterns before type ascription. We want to reserve this syntactic space for possible future generalized type ascription.
r? ``@petrochenkov``
2021-03-09 09:05:20 +00:00
Yoshitomo Nakanishi
43c88c60c1
Move char_lit_as_u8 to its own module
2021-03-09 17:28:56 +09:00
Yoshitomo Nakanishi
f33bb3d900
Move cast_ref_to_mut to its own module
2021-03-09 17:24:29 +09:00
Yoshitomo Nakanishi
ebd1ec0e40
Move cast_ptr_alignment to its own module
2021-03-09 17:17:04 +09:00
Yoshitomo Nakanishi
9a24877e2c
Move fn_to_numeric_cast_with_truncation to its own module
2021-03-09 17:16:10 +09:00
Yoshitomo Nakanishi
458f6d19d0
Move fn_to_numeric_cast to its own module
2021-03-09 17:16:10 +09:00
Yoshitomo Nakanishi
0dce9921fd
Remove 'lint_numeric_casts'
2021-03-09 17:16:10 +09:00
Yoshitomo Nakanishi
9709993e41
Move unnecessary_cast to its own module
2021-03-09 17:16:07 +09:00
Yoshitomo Nakanishi
a383e034dc
Move cast_possible_wrap to its own module
2021-03-09 16:44:44 +09:00
Yoshitomo Nakanishi
0975031117
Move cast_sign_loss to its own module
2021-03-09 16:05:21 +09:00
Yoshitomo Nakanishi
0534bf4698
Move cast_possible_truncation to its own module
2021-03-09 16:05:20 +09:00
bors
727e5f133c
Auto merge of #6869 - DJMcNab:rust-analyzer-private, r=phansch
...
Opt-in to rustc_private for `rust-analyzer`
rust-analyzer/rust-analyzer#7891
changelog: none
This will also help priroda and any other package which depends on the `miri` library crate.
2021-03-09 06:46:55 +00:00
Yoshitomo Nakanishi
b12d7515b1
Move cast_lossless to its own module
2021-03-09 12:39:59 +09:00
Yoshitomo Nakanishi
c2cbcd3229
Move cast_precision_loss to its own module
2021-03-09 11:22:17 +09:00
Yoshitomo Nakanishi
360f065404
Move 'is_isize_or_usize' to clippy_utils
2021-03-09 11:08:45 +09:00
Yoshitomo Nakanishi
f098007caa
Separate lints of casts group from types group
2021-03-09 10:57:32 +09:00
bors
2cb5bbf80c
Auto merge of #6871 - camsteffen:redundant-closure-macro, r=Manishearth
...
Fix redundant closure with macros
changelog: Fix redundant_closure FPs with macros
Fixes #6732
Fixes #6850
Fixes #4354 (addresses the error message confusion)
2021-03-08 21:32:21 +00:00
Cameron Steffen
8c540dcd2d
Improve the redundant_closure message
2021-03-08 13:16:53 -06:00
mark
7e4f5ca38e
clippy: fix or-pattern in let binding
2021-03-08 13:16:00 -06:00
Cameron Steffen
bf98aa6fb8
Fix redundant closure with macros
2021-03-08 13:15:13 -06:00
Daniel McNab
c4e2cf9601
Opt-in to rustc_private for rust-analyzer
...
rust-analyzer/rust-analyzer#7891
2021-03-08 17:39:51 +00:00
Jason Newcomb
f2d917e3b1
Don't assume lang items will exist.
2021-03-08 11:08:52 -05:00
Yoshitomo Nakanishi
db59c35b7e
Fix some lints in types that fail dogfood
2021-03-09 00:52:25 +09:00
Yoshitomo Nakanishi
bb8208da2b
Import declared lints at the top of the file
2021-03-09 00:51:06 +09:00
Yoshitomo Nakanishi
2afa7df564
Remove unused is_local from borrowed_box
2021-03-09 00:50:22 +09:00
Yoshitomo Nakanishi
53d3ffe539
Move borrowed_box to its own module
2021-03-09 00:50:22 +09:00
Yoshitomo Nakanishi
cc3ab1c0ec
Move linked_list to its own module
2021-03-09 00:50:22 +09:00
Yoshitomo Nakanishi
b59c879fc9
Move option_option to its own module
2021-03-09 00:49:04 +09:00
Yoshitomo Nakanishi
fbd25e93a4
Add flags to detect lints are triggered
2021-03-09 00:49:04 +09:00
Yoshitomo Nakanishi
2c2fb3996f
Move vec_box to its own module
2021-03-09 00:47:30 +09:00
Yoshitomo Nakanishi
f110c5e6f5
Move rc_buffer to its own module
2021-03-09 00:46:28 +09:00
Yoshitomo Nakanishi
128f1f5e2e
Move redundant_allocation to its own module
2021-03-09 00:40:47 +09:00
Yoshitomo Nakanishi
df307c0ce7
Move box_vec to its own module
2021-03-09 00:36:46 +09:00
Yoshitomo Nakanishi
714a826439
Create types dir and move old module under it
2021-03-09 00:33:22 +09:00
Yusuke Tanaka
0327c2e041
Output help instead of suggestion in if_then_some_else_none
diagnose
2021-03-08 23:20:18 +09:00
Yusuke Tanaka
f2a85cb42a
Set 1.50 as msrv of if_then_some_else_none
2021-03-08 22:52:03 +09:00
Andrea Nall
9bdc273f03
relocate functions from clippy_lints::types
...
relocate `is_ty_param_lang_item` and `is_ty_param_diagnostic_item` to `clippy_utils`
2021-03-07 17:58:39 -06:00
Andrea Nall
3877a410be
migrate paths to newly-added diagnostic items
...
This gets rid of the following paths:
* OS_STRING
* TO_OWNED
* TO_STRING
Also removes some usages of:
* PATH_BUF
And the now completely unused `clippy_lints::types::is_ty_param_path`
2021-03-07 17:53:12 -06:00
Jason Newcomb
47145dec36
len_without_is_empty
will now consider multiple impl blocks
...
`len_without_is_empty` will now consider `#[allow]` on both the `len` method, and the type definition
2021-03-07 09:40:18 -05:00
bors
5945e85f34
Auto merge of #6823 - Jarcho:diagnostic_items, r=phansch
...
Use diagnostic or language items instead of paths
I think that gets everything except ones used in a list of paths to check.
changelog: none
2021-03-07 12:04:42 +00:00
Jason Newcomb
e4ffff9e72
Use LanguageItems::require
2021-03-06 13:03:13 -05:00
Yusuke Tanaka
a672d335a2
Implement new lint: if_then_some_else_none
2021-03-07 02:08:46 +09:00
Mateusz Gacek
a0b7f9b3a0
useless_format: fix examples in the description
...
"Good" example was something not acceptable by the useless_format lint.
2021-03-05 12:11:31 -08:00
Cameron Steffen
5abd8c5995
Use typeck_body
2021-03-05 10:36:20 -06:00
Cameron Steffen
ae8ec07d2e
Avoid mir in missing_errors_doc
2021-03-05 10:36:20 -06:00
Cameron Steffen
45454f0738
Avoid mir in implicit_return
2021-03-05 10:36:16 -06:00
flip1995
1d71d9a106
Fix dogfood errors in clippy_lints
2021-03-05 11:10:29 +01:00
Oli Scherer
5b2e7e91c3
Shrink the size of Rvalue by 16 bytes
2021-03-05 09:33:01 +00:00
bors
6680710961
Auto merge of #6833 - daxpedda:use-self, r=Manishearth
...
Fix false-positive in `use_self`
Fixes #6818 .
changelog: Fix false positives for use_self in macros.
2021-03-04 17:35:06 +00:00
bors
ff51964102
Auto merge of #6825 - djc:naive-bytecount-pedantic, r=Manishearth
...
Move naive_bytecount to pedantic
As discussed on Zulip, current best practice is to avoid recommending
external crates. This lint is from before that was enforced. Move it
to the pedantic group to avoid enabling it by default.
https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/naive_bytecount.20suggesting.20extra.20dependency
changelog: move [`naive_bytecount`] to pedantic
2021-03-03 21:26:24 +00:00
daxpedda
5656510eed
Fix false-positive in use_self
2021-03-03 17:32:49 +01:00
bors
43d19f63f7
Auto merge of #6824 - Y-Nak:refactor_loops_module, r=flip1995
...
Refactor: organize loops file into loops module (Delegated)
`@flip1995` `@nahuakang`
closes #6693
r? `@flip1995`
As we talked about in the PM of Zulip, this PR is a delegated PR from `@nahuakang.`
Changes from the last commit of #6693 :
1. Unify the name of the main entries of all modules to check, that was pointed out [here](https://github.com/rust-lang/rust-clippy/pull/6693#discussion_r582897713 )
2. Simplify ` check_for_loop_arg`, that was pointed out [here](https://github.com/rust-lang/rust-clippy/pull/6693#discussion_r582914044 ) and [here](https://github.com/rust-lang/rust-clippy/pull/6693#discussion_r582929910 )
3. Resolve conflicts
changelog: Refactor `loops.rs` file into `loops` module.
2021-03-03 10:34:22 +00:00
bors
ece3543c9f
Auto merge of #6801 - Jarcho:manual_match_fix, r=phansch
...
Fix `manual_map` false positives
fixes : #6795
fixes : #6797
fixes : #6811
fixes : #6819
changelog: Fix false positives for `manual_map` when `return`, `break`, `continue`, `yield`, `await`, and partially moved values are used.
changelog: Don't expand macros in suggestions for `manual_map`
2021-03-02 15:36:00 +00:00
Dirkjan Ochtman
9e4a064f08
Move naive_bytecount to pedantic
...
As discussed on Zulip, current best practice is to avoid recommending
external crates. This lint is from before that was enforced. Move it
to the pedantic group to avoid enabling it by default.
https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/naive_bytecount.20suggesting.20extra.20dependency
2021-03-02 14:34:47 +01:00
Yoshitomo Nakanishi
19c886b407
Remove "for_loop_arg.rs"
2021-03-02 21:09:10 +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
Yusuke Tanaka
bf000985f5
Make check_cast private
2021-03-02 10:40:25 +01:00
Yusuke Tanaka
8a8f7b4cf5
Refactor calls to lint check functions
2021-03-02 10:40:25 +01:00
Yusuke Tanaka
89ef26a681
Cleanup imports
2021-03-02 10:40:25 +01:00
Yusuke Tanaka
25c221ec92
Move transmutes_expressible_as_ptr_casts to its own module
2021-03-02 10:40:24 +01:00
Yusuke Tanaka
c57a8260f2
Move unsound_collection_transmute to its own module
2021-03-02 10:40:24 +01:00
Yusuke Tanaka
e7d2393d01
Move transmute_float_to_int to its own module
2021-03-02 10:40:24 +01:00
Yusuke Tanaka
acedc7b8f2
Move transmute_int_to_float to its own module
2021-03-02 10:40:24 +01:00
Yusuke Tanaka
d04ea41d1f
Move transmute_int_to_bool to its own module
2021-03-02 10:40:24 +01:00
Yusuke Tanaka
f8bc0e249c
Move transmute_ptr_to_ptr to its own module
2021-03-02 10:40:23 +01:00
Yusuke Tanaka
7af3458b54
Move transmute_bytes_to_str and transmute_ptr_to_ptr to transmute_ref_to_ref module
2021-03-02 10:40:23 +01:00
Yusuke Tanaka
4c65221188
Move transmute_int_to_char to its own module
2021-03-02 10:40:23 +01:00
Yusuke Tanaka
6442d45d3a
Move transmute_ptr_to_ref to its own module
2021-03-02 10:40:23 +01:00
Yusuke Tanaka
afc9275928
Move crosspointer_transmute to its own module
2021-03-02 10:37:30 +01:00
Yusuke Tanaka
ef97764dcc
Move wrong_transmute to its own module
2021-03-02 10:37:30 +01:00
Yusuke Tanaka
0d7dd00860
Move useless_transmute to its own module
2021-03-02 10:37:30 +01:00
Yusuke Tanaka
4ac438bfed
Add transmute/utils.rs
2021-03-02 10:37:30 +01:00
Yusuke Tanaka
306545ff96
Create transmute directory
2021-03-02 10:37:30 +01:00
Yoshitomo Nakanishi
74bd806b05
Simplify check_for_loop_arg
2021-03-02 18:14:20 +09:00
Yoshitomo Nakanishi
eaf63d6df7
Unify names of lint entry functions in loops to 'check'
2021-03-02 18:14:20 +09:00
nahuakang
845a3a061c
Include loops.rs changes from PR#6698
2021-03-02 18:14:20 +09:00
nahuakang
2229a0839e
Clean up: Rename some files to be consistent with lint names; import lints to each file
2021-03-02 18:14:20 +09:00
nahuakang
ecebfe0c9c
Move check_for_loop_arg back to mod; split into 4 lint files
2021-03-02 18:14:20 +09:00
nahuakang
7cfdef6de1
Move MinifyingSugg into manual_memcpy
2021-03-02 18:14:20 +09:00
nahuakang
7158c944a4
Refactor while let loop to its own module
2021-03-02 18:14:20 +09:00
nahuakang
287a4f8ab1
Refactor empty loop to its own module
2021-03-02 18:14:20 +09:00
nahuakang
d0b657c0b7
Refactor while let on iterator lint to its module; rename for loop explicit counter to explicit counter loop
2021-03-02 18:14:20 +09:00
nahuakang
455d0476b1
Refactor never loop to its own module
2021-03-02 18:14:20 +09:00
nahuakang
5b870e1b36
Move detect_manual_memcpy to its module; split up utils structs
2021-03-02 18:14:20 +09:00
nahuakang
2c1f676bfe
Add detect_same_item_push to its own module
2021-03-02 18:14:20 +09:00
nahuakang
453e6b97ac
Add check_needless_collect to its own module
2021-03-02 18:14:20 +09:00
nahuakang
9520cba554
Add check_infinite_loop to its own module
2021-03-02 18:13:32 +09:00
nahuakang
1e5e541ac5
Refactor check_for_single_element_loop to its own module
2021-03-02 18:13:32 +09:00
nahuakang
71026cad54
Refactor check_for_loop_explicit_counter to its own module
2021-03-02 18:13:32 +09:00
nahuakang
71c9fdf8b1
Refactor check_for_loop_range into its module
2021-03-02 18:13:32 +09:00
nahuakang
6e4663dedf
Refactor check_for_mut_range_bound to its own module
2021-03-02 18:13:32 +09:00
nahuakang
7b0f588b77
Refactor check_for_loop_over_map_kv to its own module
2021-03-02 18:13:32 +09:00
nahuakang
408368a82c
Refactor check_for_loop_arg; rename manual_flatten's lint back to check_manual_flatten
2021-03-02 18:13:32 +09:00
nahuakang
62ac4bd1b2
create loops dir; arrange manual_flatten lint and utils
2021-03-02 18:13:32 +09:00
Jason Newcomb
f21320fd74
Use diagnostic or language items instead of paths
2021-03-01 23:10:51 -05:00
Jason Newcomb
2c485e36cd
Don't move yield
or inline assembly into closure
2021-03-01 17:25:23 -05:00
Cameron Steffen
ada8c72f3f
Add version = "Two" to rustfmt.toml
...
Ignore UI tests since this change makes rustfmt less friendly with UI
test comments.
2021-03-01 16:17:33 -06:00
Cameron Steffen
7984e60d9e
Use diagnostic items in into_iter_collections
2021-03-01 09:04:11 -06:00
Jason Newcomb
a3278a16d3
Fix manual_map
: do not expand macros in suggestions
2021-02-28 09:13:24 -05:00
hyd-dev
da3a57377e
Fix false positives on procedural macros of missing_inline_in_public_items
lint
2021-02-28 21:10:44 +08: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
Yoshitomo Nakanishi
bdeec5dbd6
Use TypeckResults::expr_ty instead of TyCtxt::type_of to fix "Not a type" ICE
2021-02-27 22:57:29 +09: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
Jason Newcomb
09a827ac73
Revert #6796 : Downgrade manual_map to nursery
2021-02-26 16:27:41 -05:00
Jason Newcomb
ef87e58993
Fix manual_map
: don't lint when partially moved values are used.
...
Fix `manual_map`: don't lint when `return`, `break`, and `continue` are used.
2021-02-26 16:24:25 -05:00
Matthias Krüger
9dba6a9fde
upper_case_acronyms: don't warn on public items
...
Fixes #6803
changelog: upper_case_acronyms: ignore public items
2021-02-26 21:31:34 +01:00
David Tolnay
8f47a4214e
Downgrade manual_map to nursery
2021-02-25 20:31:24 -08:00
Cameron Steffen
5dbd45cbc1
Improve needless_borrowed_ref docs
2021-02-25 20:16:44 -06:00
bors
d5223be2e3
Auto merge of #6601 - mdm:fix-unit-args-false-positive, r=camsteffen
...
Fix false positive for unit_arg lint
Fixes #6447
To avoid false positives don't complain about unit args when they come from a path expression, e.g. a local variable.
**Note:** This is my first contribution to Clippy, so I might have messed up somewhere. Any feedback is welcome and I'm happy to work out any kinks.
---
changelog: Do not lint unit arguments when they come from a path expression.
2021-02-25 21:16:02 +00: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
flip1995
f64149dd04
Merge commit '928e72dd10749875cbd412f74bfbfd7765dbcd8a' into clippyup
2021-02-25 11:25:22 +01:00
bors
928e72dd10
Auto merge of #6789 - flip1995:rustup, r=flip1995
...
Rustup
r? `@ghost`
changelog: None
2021-02-25 09:49:12 +00:00
flip1995
c6408a47bd
Merge remote-tracking branch 'upstream/master' into rustup
2021-02-25 10:40:00 +01:00
bors
ef41f2baf7
Auto merge of #6788 - matthiaskrgr:upper_case_acronyms, r=flip1995
...
move upper_case_acronyms back to style, but make the default behaviour less aggressive by default (can be unleashed via config option)
Previous discussion in the bi-weekly clippy meeting for reference: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Meeting.202021-02-23/near/227458019
Move the `upper_case_acronyms` lint back to the style group.
Only warn on fully-capitalized names by default.
Add add a clippy-config option `upper-case-acronyms-aggressive: true/false` to enabled more aggressive linting on
all substrings that could be capitalized acronyms.
---
changelog: reenable upper_case_acronyms by default but make the more aggressive linting opt-in via config option
2021-02-25 09:01:41 +00:00
Matthias Krüger
2a6b06108d
run cargo dev update_lints
...
fix sentence / address review comments
2021-02-25 09:59:39 +01:00
Matthias Krüger
913c71018c
upper_case_acronyms: add io-toml tests and bless previous tests
2021-02-24 23:50:55 +01:00
Matthias Krüger
59750dceb8
upper_case_acronyms: add optional aggressive mode and relax default
...
Moves the lint back from pedantic to style group.
The lint default now only warns on names that are completely capitalized, like "WORD"
and only if the name is longer than 2 chars (so that names where each of the letter represents a word are still distinguishable).
For example: FP (false positive) would still be "valid" and not warned about (but EOF would warn).
A "upper_case_acronyms_aggressive: true/false" config option was added that restores the original lint behaviour to warn
on any kind of camel case name that had more than one capital letter following another capital letter.
2021-02-24 23:50:53 +01:00
avitex
72e3335684
Add OpenDNS to doc-valid-idents
2021-02-25 09:30:33 +11:00