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
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
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
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
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
Marc Dominik Migge
9fe9d94abd
Don't lint unit args if expression kind is path
2021-02-24 13:31:04 +01:00
Samuel E. Moelius III
8047458f40
Move conf.rs back into clippy_lints
2021-02-24 06:21:46 -05:00
Samuel E. Moelius III
ab7381f085
Move declare_clippy_lint
back into clippy_lints
2021-02-23 18:50:30 -05:00
Samuel E. Moelius III
b7f03c6697
Remove unused features
2021-02-23 18:50:30 -05:00
Samuel E. Moelius III
8d2de8f256
Update clippy_lints/src/lib.rs
2021-02-23 18:50:30 -05:00
Samuel E. Moelius III
09bded4437
Factor out clippy_utils
crate
2021-02-23 18:50:30 -05:00
bors
a2c25fa9f0
Auto merge of #6573 - Jarcho:option_match_map, r=llogiq
...
New lint: option_manual_map
fixes : #6
changelog: Added lint: `match_map`
2021-02-23 21:56:25 +00:00
bors
0984754dd7
Auto merge of #6777 - giraffate:remove_unneeded_blank_lines_from_doc, r=phansch
...
Remove unneeded blank lines from doc
Remove unneeded blank lines like below.
<img width="1142" alt="スクリーンショット 2021-02-22 23 01 17" src="https://user-images.githubusercontent.com/17407489/108719295-bb9ff800-7562-11eb-9338-8f2571e61c56.png ">
changelog: none
2021-02-23 06:05:27 +00:00
Takayuki Nakata
e05965eb13
Remove unneeded blank lines from doc
2021-02-22 23:02:04 +09:00
Matthias Krüger
0eefa6169d
upper_case_acronyms: move lint from style to pedantic lint group
...
The lint does point out inconsistency with the Rust naming convention,
but the fact that rustc does not warn about the inconsistency by default
means that clippy probably should not warn by default either.
changelog: move upper_case_acronyms lint from style to pedantic group.
2021-02-22 12:30:28 +01:00
bors
fe01ddc8bc
Auto merge of #6769 - Y-Nak:inconsistent-struct-constructor, r=matthiaskrgr
...
Inconsistent struct constructor
fixes : #6352
r? `@matthiaskrgr`
I added the lint that checks for the struct constructors where the order of the field init shorthands is inconsistent with that in the struct definition.
changelog: Add style lint: `inconsistent_struct_constructor`
2021-02-22 09:29:20 +00:00
Jason Newcomb
23aa2f880c
Fix dogfood errors
2021-02-21 23:15:28 -05:00
Jason Newcomb
efe33f9fe4
Add: option_manual_map lint
2021-02-21 22:06:03 -05:00
Yoshitomo Nakanishi
bfdf0fa03f
Describe the order of fields in struct ctor doesn't affect the resulted instance
2021-02-22 11:45:25 +09:00
bors
728f3976f0
Auto merge of #6771 - MortenLohne:master, r=flip1995
...
Fix FP in inherent_to_string when the function has generic parameters
Minimal example of the false positive:
````
struct G;
impl G {
fn to_string<const _N: usize>(&self) -> String {
"G.to_string()".to_string()
}
}
fn main() {
let g = G;
g.to_string::<1>();
}
````
Clippy emits an `inherent_to_string` warning, and suggests that we implement `Display` for `G` instead. However, this is not possible, since the generic parameter _N only exists in this function, not in `G` itself. This particular example uses const generics, which is where the issue is most likely to come up, but this PR skips the lint if the `to_string` function has any kind of generic parameters.
changelog: Fix FP in `inherent_to_string`
2021-02-21 16:10:03 +00:00
bors
208e95781b
Auto merge of #6770 - ThibsG:PostfixEnumVariant, r=flip1995
...
Fix camel case postfix for `enum_variant_names` lint
Fix camel case postfix
Fixes : #4639
changelog: none
2021-02-21 15:58:47 +00:00
bors
8a47901bac
Auto merge of #6765 - camsteffen:unnecessary-wraps-pedantic, r=flip1995
...
Change unnecessary_wraps to pedantic
changelog: Change unnecessary_wraps to pedantic
There seems to be enough evidence that this lint is not wanted as warn-by-default. Attempted before at #6380 . False positives at #6721 and #6427 . Actually requested to change the category at #6726 .
Closes #6726
2021-02-21 15:33:50 +00:00
bors
d2ddf9c796
Auto merge of #6754 - camsteffen:spanlesseq-res, r=flip1995
...
Teach SpanlessEq binding IDs
changelog: Fix collapsible_match false positive
Fixes #6740
This PR changes the way `SpanlessEq` determines whether two local variables are the same. Instead of checking that the names match, it checks that the `HirId`s match. If local bindings are declared within the expressions that are being compared, `SpanlessEq` will remember bindings that correspond to each other in a `FxHashMap<HirId, HirId>`. This makes `SpanlessEq` more flexible while also fixing false positives.
Example: `{ let x = 1; x + 2 }` is equal to `{ let y = 1; y + 2 }`.
CC `@xFrednet` I think this will resolve some concerns in #6463
2021-02-21 15:22:35 +00:00
Morten Lohne
19a377510c
Fix FP in inherent_to_string when the function has generic parameters
2021-02-21 00:11:17 +01:00
Yoshitomo Nakanishi
d646aa2ae7
Fix unnecessary_sort_by.rs that fails the dogfood test
2021-02-21 05:05:13 +09:00
Yoshitomo Nakanishi
d23038944a
New lint: inconsistent_struct_constructor
2021-02-21 05:05:11 +09:00
ThibsG
5af6f96c8f
Fix camel case postfix for enum_variant_names
lint
2021-02-20 19:48:04 +01:00
bors
67087a1b4e
Auto merge of #6717 - booleancoercion:master, r=llogiq
...
Add the from_str_radix_10 lint
changelog: added the new `from_str_radix_10` which sometimes replaces calls to `primitive::from_str_radix` to `str::parse`
This is ready to be merged, although maybe the category should be `pedantic` instead of `style`? I'm not sure where it fits better.
Closes #6713 .
2021-02-20 09:33:11 +00:00
bool
c4b8d87ab9
Fixed the known problems section
2021-02-19 22:00:23 +02:00
bool
bf55aee7b1
Updated from_str_radix_10 sugg to be slightly smarter and ran bless
2021-02-19 21:56:21 +02:00
Matthias Krüger
1f4153aa1e
collapsible_match: fix lint message capitalization
...
(see https://rustc-dev-guide.rust-lang.org/diagnostics.html for details)
2021-02-19 10:02:17 +01:00
Cameron Steffen
46c91db1e1
Change known problems
2021-02-18 20:23:49 -06:00
Cameron Steffen
54c6054ec7
Change unnecessary_wraps to pedantic
2021-02-18 20:03:13 -06:00
Dylan DPC
2c302b246e
Rollup merge of #82238 - petrochenkov:nocratemod, r=Aaron1011
...
ast: Keep expansion status for out-of-line module items
I.e. whether a module `mod foo;` is already loaded from a file or not.
This is a pre-requisite to correctly treating inner attributes on such modules (https://github.com/rust-lang/rust/issues/81661 ).
With this change AST structures for `mod` items diverge even more for AST structure for the crate root, which previously used `ast::Mod`.
Therefore this PR removes `ast::Mod` from `ast::Crate` in the first commit, these two things are sufficiently different from each other, at least at syntactic level.
Customization points for visiting a "`mod` item or crate root" were also removed from AST visitors (`fn visit_mod`).
`ast::Mod` itself was refactored away in the second commit in favor of `ItemKind::Mod(Unsafe, ModKind)`.
2021-02-19 02:49:08 +01:00
bors
0f70e88137
Auto merge of #6665 - pag4k:unnecessary_wraps_bug_6640, r=camsteffen
...
Fix for issue 6640
*Please write a short comment explaining your change (or "none" for internal only changes)*
changelog: unnecessary_wraps will now suggest to remove unnecessary wrapped return unit type, like Option<()>
fixes #6640
2021-02-18 22:47:44 +00:00
Pierre-Andre Gagnon
a78271b861
Changed fn body suggestion msg
2021-02-18 17:32:55 -05:00
Dylan DPC
6e12a2f9e2
Rollup merge of #82215 - TaKO8Ki:replace-if-let-while-let, r=varkor
...
Replace if-let and while-let with `if let` and `while let`
This pull request replaces if-let and while-let with `if let` and `while let`.
closes https://github.com/rust-lang/rust/issues/82205
2021-02-18 16:57:37 +01:00
Vadim Petrochenkov
b185fa3ae2
ast: Keep expansion status for out-of-line module items
...
Also remove `ast::Mod` which is mostly redundant now
2021-02-18 13:07:49 +03:00
Yoshitomo Nakanishi
a87fa0e350
Fix FP of result_unit_err when using type aliases
2021-02-18 18:49:26 +09: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
Pierre-Andre Gagnon
6165cccf7e
Added detailled suggs for new case
2021-02-17 16:41:50 -05:00
Cameron Steffen
9ad6e263c9
Fix match_same_arms with SpanlessEq changes
2021-02-17 10:47:26 -06:00
Cameron Steffen
742922a41a
Make expr_fallback FnMut
2021-02-17 10:47:26 -06:00
Cameron Steffen
4ac14f9e63
Teach SpanlessEq binding IDs
2021-02-17 10:47:26 -06:00
Takayuki Maeda
2d60a6113d
replace if-let and while-let with if let
and while let
2021-02-17 19:26:38 +09:00
bors
e2753f9a7b
Auto merge of #6662 - Y-Nak:default-numeric-fallback, r=flip1995
...
New lint: default_numeric_fallback
fixes #6064
r? `@flip1995`
As we discussed in [here](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Issue.20.236064/near/224647188 ) and [here](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Issue.20clippy.236064/near/224746333 ), I start implementing this lint from the strictest version.
In this PR, I'll allow the below two cases to pass the lint to reduce FPs.
1. Appearances of unsuffixed numeric literals in `Local` if `Local` has a type annotation, for example:
```rust
// Good.
let x: i32 = 1;
// Also good.
let x: (i32, i32) = if cond {
(1, 2)
} else {
(2, 3)
};
```
2. Appearances of unsuffixed numeric literals in args of `Call` or `MethodCall` if corresponding arguments of their signature have concrete types, for example:
```rust
fn foo_mono(x: i32) -> i32 {
x
}
fn foo_poly<T>(t: T) -> t {
t
}
// Good.
let x = foo_mono(13);
// Still bad.
let x: i32 = foo_poly(13);
```
changelog: Added restriction lint: `default_numeric_fallback`
2021-02-16 09:58:49 +00:00
Yoshitomo Nakanishi
9b0c1ebc18
Change to span_lint_and_sugg from span_lint_and_help
2021-02-16 18:07:09 +09:00
Yoshitomo Nakanishi
1f8ee3cc19
Handle struct ctor case
2021-02-16 11:20:51 +09: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
Camille GILLOT
5b68fc16ed
Use ItemId as a strongly typed index.
2021-02-15 19:24:58 +01:00
Yoshitomo Nakanishi
fb91c76586
Add more tests for default_numeric_fallback
2021-02-15 23:33:27 +09:00
Yoshitomo Nakanishi
0198ac7bdd
Add fn_sig_opt to get fn signature from HirId
2021-02-15 23:29:18 +09:00
Yoshitomo Nakanishi
93796b2346
Add some restrictions to default_numeric_fallback to avoid FNs
2021-02-15 14:43:37 +09:00
bors
2f19f5f0d7
Auto merge of #6741 - ThibsG:BlockInIfConditions1141, r=flip1995
...
Do not lint when the closure is called using an iterator
Fix FP when the closure is used in an iterator for `blocks_in_if_conditions` lint
FIxes : #1141
changelog: none
2021-02-14 15:55:12 +00:00
ThibsG
12025506d6
Do not lint when the closure is called using an iterator
2021-02-14 16:21:12 +01:00
bors
9c3b43efdd
Auto merge of #6701 - camsteffen:collapsible-if, r=flip1995
...
Fix collapsible_if with attributes
changelog: Fix collapsible_if FP with attributes
Fixes #6593
2021-02-14 14:43:35 +00:00
bors
eb80ac4e72
Auto merge of #6697 - camsteffen:vec-init-push-fp, r=flip1995
...
Fix vec_init_then_push false positives
changelog: Fix vec_init_then_push false positives
Fixes #6615
2021-02-14 14:27:13 +00:00
bors
ce0a47ab8c
Auto merge of #81238 - RalfJung:copy-intrinsics, r=m-ou-se
...
directly expose copy and copy_nonoverlapping intrinsics
This effectively un-does https://github.com/rust-lang/rust/pull/57997 . That should help with `ptr::read` codegen in debug builds (and any other of these low-level functions that bottoms out at `copy`/`copy_nonoverlapping`), where the wrapper function will not get inlined. See the discussion in https://github.com/rust-lang/rust/pull/80290 and https://github.com/rust-lang/rust/issues/81163 .
Cc `@bjorn3` `@therealprof`
2021-02-13 20:30:07 +00:00
Mara Bos
dd91987533
Fix clippy's path to the copy intrinsics.
2021-02-13 18:58:54 +01:00
boolean_coercion
d36fe85569
Made parens addition smarter and added tests with bless
2021-02-13 00:33:08 +02:00