Commit Graph

5779 Commits

Author SHA1 Message Date
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