]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoFactor out eq_ty_kind
Cameron Steffen [Tue, 23 Mar 2021 15:40:27 +0000 (10:40 -0500)]
Factor out eq_ty_kind

3 years agoAuto merge of #6896 - TaKO8Ki:refactor-lints-in-methods-module, r=phansch
bors [Mon, 22 Mar 2021 19:36:22 +0000 (19:36 +0000)]
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.

3 years agoAuto merge of #6942 - mgacek8:issue_6815_search_is_none, r=llogiq
bors [Mon, 22 Mar 2021 12:58:47 +0000 (12:58 +0000)]
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!

3 years agosearch_is_some: check also when search is none
Mateusz Gacek [Sat, 20 Mar 2021 13:30:45 +0000 (14:30 +0100)]
search_is_some: check also when search is none

3 years agoAuto merge of #6945 - ThibsG:BadSuggestionGenericsForReassignDefault, r=Manishearth
bors [Sun, 21 Mar 2021 14:42:45 +0000 (14:42 +0000)]
Auto merge of #6945 - ThibsG:BadSuggestionGenericsForReassignDefault, r=Manishearth

Fix suggestion with generics for `field_reassign_with_default` lint

Fix bad suggestion where `::` is missing after type if generics are involved

Fixes #6944

changelog: none

3 years agoFix suggestion with generics for `field_reassign_with_default` lint
ThibsG [Sun, 21 Mar 2021 08:50:35 +0000 (09:50 +0100)]
Fix suggestion with generics for `field_reassign_with_default` lint

3 years agoAuto merge of #6941 - ThibsG:suggMatchSingleBinding, r=llogiq
bors [Sat, 20 Mar 2021 17:35:21 +0000 (17:35 +0000)]
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

3 years agoAuto merge of #6939 - ThibsG:suggNewWithoutDefault, r=llogiq
bors [Sat, 20 Mar 2021 17:20:34 +0000 (17:20 +0000)]
Auto merge of #6939 - ThibsG:suggNewWithoutDefault, r=llogiq

Fix bad suggestion for generics in `new_without_default` lint

Fixes bad suggestion where a type parameter was missing for `new_without_default` lint.

Fixes #6933

changelog: none

3 years agoSplit `match_single_binding` tests in 2 files (too many lines for CI)
ThibsG [Sat, 20 Mar 2021 15:31:39 +0000 (16:31 +0100)]
Split `match_single_binding` tests in 2 files (too many lines for CI)

3 years agoFix bad suggestion that needs curly braces for `match_single_binding` lint
ThibsG [Sat, 20 Mar 2021 15:11:19 +0000 (16:11 +0100)]
Fix bad suggestion that needs curly braces for `match_single_binding` lint

3 years agoFix bad suggestion for generics in `new_without_default` lint
ThibsG [Sat, 20 Mar 2021 09:24:10 +0000 (10:24 +0100)]
Fix bad suggestion for generics in `new_without_default` lint

3 years agoAuto merge of #6924 - mgacek8:issue6727_copy_types, r=llogiq
bors [Sat, 20 Mar 2021 06:59:13 +0000 (06:59 +0000)]
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

3 years agowrong_self_convention: Enhance lint message
Mateusz Gacek [Thu, 18 Mar 2021 18:45:13 +0000 (19:45 +0100)]
wrong_self_convention: Enhance lint message

3 years agoAuto merge of #6935 - matthiaskrgr:qmark_marco, r=flip1995
bors [Fri, 19 Mar 2021 09:55:30 +0000 (09:55 +0000)]
Auto merge of #6935 - matthiaskrgr:qmark_marco, r=flip1995

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.

3 years agoneedless_question_mark: don't lint if Some(..) is inside a macro def and the ? is...
Matthias Krüger [Thu, 18 Mar 2021 22:01:42 +0000 (23:01 +0100)]
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.

3 years agoAuto merge of #6928 - mgacek8:issue6675_or_fun_call_unsafe_blocks, r=phansch
bors [Thu, 18 Mar 2021 15:55:06 +0000 (15:55 +0000)]
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

3 years agoAuto merge of #6863 - Jarcho:wild_enum_match, r=llogiq
bors [Thu, 18 Mar 2021 10:39:28 +0000 (10:39 +0000)]
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`

3 years agoAdjust use_self uitest to proper self convention
Mateusz Gacek [Thu, 18 Mar 2021 09:27:55 +0000 (10:27 +0100)]
Adjust use_self uitest to proper self convention

3 years agoor_fun_call: trigger on unsafe blocks
Mateusz Gacek [Wed, 17 Mar 2021 19:29:31 +0000 (20:29 +0100)]
or_fun_call: trigger on unsafe blocks

3 years agowrong_self_convention: `to_` respects `Copy` types
Mateusz Gacek [Wed, 17 Mar 2021 14:52:14 +0000 (15:52 +0100)]
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

3 years agoAuto merge of #6856 - Jarcho:manual_map_if_let, r=Manishearth
bors [Wed, 17 Mar 2021 17:47:59 +0000 (17:47 +0000)]
Auto merge of #6856 - Jarcho:manual_map_if_let, r=Manishearth

Fix `manual_map` suggestion for `if let.. else ... if let.. else` chain

fixes: #6847

changelog: Fix `manual_map` suggestion for `if let.. else ... if let.. else` chain

3 years agoFix `manual_map` suggestion for `if let.. else ... if let.. else` chain
Jason Newcomb [Fri, 5 Mar 2021 20:57:37 +0000 (15:57 -0500)]
Fix `manual_map` suggestion for `if let.. else ... if let.. else` chain

3 years agoFix message for `match_wildcard_for_single_variant`
Jason Newcomb [Tue, 16 Mar 2021 16:56:08 +0000 (12:56 -0400)]
Fix message for `match_wildcard_for_single_variant`

3 years agoreplace crate::methods::utils with super::utils
Takayuki Maeda [Wed, 17 Mar 2021 16:23:37 +0000 (01:23 +0900)]
replace crate::methods::utils with super::utils

3 years agoremove the use of paths
Takayuki Maeda [Wed, 17 Mar 2021 16:06:24 +0000 (01:06 +0900)]
remove the use of paths

3 years agoAdd test for `#[non_exhaustive]` enum in `match_wildcard_for_single-variant`
Jason Newcomb [Mon, 8 Mar 2021 15:33:36 +0000 (10:33 -0500)]
Add test for `#[non_exhaustive]` enum in `match_wildcard_for_single-variant`

3 years agoImprovements to `match_wildcard_for_single_variants` and `wildcard_enum_match_arm...
Jason Newcomb [Sun, 7 Mar 2021 00:25:09 +0000 (19:25 -0500)]
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

3 years agomove get_hint_if_single_char_arg to methods/utils.rs
Takayuki Maeda [Wed, 17 Mar 2021 05:45:20 +0000 (14:45 +0900)]
move get_hint_if_single_char_arg to methods/utils.rs

3 years agomove chars_last_cmp_with_unwrap to its own module
Takayuki Maeda [Wed, 17 Mar 2021 05:34:20 +0000 (14:34 +0900)]
move chars_last_cmp_with_unwrap to its own module

3 years agoextract conditions for single_char_pattern into its own module
Takayuki Maeda [Wed, 17 Mar 2021 05:26:27 +0000 (14:26 +0900)]
extract conditions for single_char_pattern into its own module

3 years agoextract condition for into_iter_on_ref to its own module
Takayuki Maeda [Wed, 17 Mar 2021 05:14:06 +0000 (14:14 +0900)]
extract condition for into_iter_on_ref to its own module

3 years agoextract conditions for `from_iter_instead_of_collect` into its own module
Takayuki Maeda [Wed, 17 Mar 2021 04:22:25 +0000 (13:22 +0900)]
extract conditions for `from_iter_instead_of_collect`  into its own module

3 years agoextract conditions into modules
Takayuki Maeda [Wed, 17 Mar 2021 03:34:37 +0000 (12:34 +0900)]
extract conditions into modules

3 years agomove single_char_add_str to its own module
Takayuki Maeda [Wed, 17 Mar 2021 03:33:09 +0000 (12:33 +0900)]
move single_char_add_str to its own module

3 years agouse clippy_utils::ty::is_type_diagnostic_item
Takayuki Maeda [Wed, 17 Mar 2021 02:18:02 +0000 (11:18 +0900)]
use clippy_utils::ty::is_type_diagnostic_item

3 years agofmt
Takayuki Maeda [Wed, 17 Mar 2021 02:15:25 +0000 (11:15 +0900)]
fmt

3 years agoremove unused arguments
Takayuki Maeda [Sat, 13 Mar 2021 16:37:33 +0000 (01:37 +0900)]
remove unused arguments

3 years agoextract a condition into a function.
Takayuki Maeda [Sat, 13 Mar 2021 16:18:04 +0000 (01:18 +0900)]
extract a condition into a function.

3 years agoremove a needless variable
Takayuki Maeda [Sat, 13 Mar 2021 16:05:37 +0000 (01:05 +0900)]
remove a needless variable

3 years agouse derefs_to_slice in methods/utils.rs
Takayuki Maeda [Sat, 13 Mar 2021 09:16:38 +0000 (18:16 +0900)]
use derefs_to_slice in methods/utils.rs

3 years agomove derefs_to_slice to methods/utils.rs
Takayuki Maeda [Sat, 13 Mar 2021 09:13:31 +0000 (18:13 +0900)]
move derefs_to_slice to methods/utils.rs

3 years agorefactor string_extend_chars: return when obj type is not string
Takayuki Maeda [Sat, 13 Mar 2021 08:36:04 +0000 (17:36 +0900)]
refactor string_extend_chars: return when obj type is not string

3 years agomove chars_cmp_with_unwrap, chars_last_cmp and chars_next_cmp_with_unwrap to their...
Takayuki Maeda [Sat, 13 Mar 2021 08:28:22 +0000 (17:28 +0900)]
move chars_cmp_with_unwrap, chars_last_cmp and chars_next_cmp_with_unwrap to their own modules

3 years agomove chars_cmp and chars_next_cmp to its own modules
Takayuki Maeda [Sat, 13 Mar 2021 08:17:10 +0000 (17:17 +0900)]
move chars_cmp and chars_next_cmp to its own modules

3 years agoAuto merge of #6918 - camsteffen:utils-re-export, r=flip1995
bors [Wed, 17 Mar 2021 14:42:46 +0000 (14:42 +0000)]
Auto merge of #6918 - camsteffen:utils-re-export, r=flip1995

Don't re-export `clippy_utils::*`

changelog: none

This should wrap up the utils-related really big changes. I personally don't see any more sub-modules to be added to `clippy_utils`.

3 years agoAdd clippy_utils::paths imports
Cameron Steffen [Wed, 17 Mar 2021 14:31:20 +0000 (09:31 -0500)]
Add clippy_utils::paths imports

3 years agoDon't re-export clippy_utils::*
Cameron Steffen [Tue, 16 Mar 2021 16:06:34 +0000 (11:06 -0500)]
Don't re-export clippy_utils::*

3 years agoAuto merge of #6805 - matthiaskrgr:uca_nopub_6803, r=flip1995
bors [Wed, 17 Mar 2021 10:53:02 +0000 (10:53 +0000)]
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

3 years agoAuto merge of #6821 - Jarcho:write_literal_suggestion, r=flip1995
bors [Wed, 17 Mar 2021 09:49:20 +0000 (09:49 +0000)]
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

3 years agoAuto merge of #6888 - matthiaskrgr:rip_ra_setup, r=flip1995
bors [Wed, 17 Mar 2021 09:24:54 +0000 (09:24 +0000)]
Auto merge of #6888 - matthiaskrgr:rip_ra_setup, r=flip1995

docs: update RA setup documentation

Add documentation how to get rust-analyzer to like clippys `extern crate` rustc deps.

Fixes #6883

This initially removed `cargo-dev ra_setup` but it is still needed by folks who use intellij rust, so keeping that.

changelog: none

3 years agoRename the last ra_setup mention to ide_setup
Philipp Krones [Wed, 17 Mar 2021 09:24:27 +0000 (10:24 +0100)]
Rename the last ra_setup mention to ide_setup

3 years agorename `cargo dev ra_setup` to `cargo dev ide_setup`
Matthias Krüger [Wed, 17 Mar 2021 09:12:20 +0000 (10:12 +0100)]
rename `cargo dev ra_setup` to `cargo dev ide_setup`

3 years agoCONTRIBUTING: update section explaining how to get ra to work inside the clippy repo
Matthias Krüger [Fri, 12 Mar 2021 00:26:13 +0000 (01:26 +0100)]
CONTRIBUTING: update section explaining how to get ra to work inside the clippy repo

3 years agoAuto merge of #6917 - MysteryJump:fix-manual-unwrap-or-const-fn, r=giraffate
bors [Wed, 17 Mar 2021 04:34:15 +0000 (04:34 +0000)]
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.

3 years agoRemove SmallVec
Jason Newcomb [Tue, 16 Mar 2021 16:06:41 +0000 (12:06 -0400)]
Remove SmallVec

3 years agoAdd suggestion to `write_literal` and `print_literal`
Jason Newcomb [Mon, 1 Mar 2021 21:31:04 +0000 (16:31 -0500)]
Add suggestion to `write_literal` and `print_literal`
Don't lint on a mixture of raw and regular strings
Fix spans in format strings

3 years agoMore specific spans for `use_debug` lint
Jason Newcomb [Mon, 1 Mar 2021 18:28:36 +0000 (13:28 -0500)]
More specific spans for `use_debug` lint

3 years agoKeep track of spans in format strings
Jason Newcomb [Mon, 1 Mar 2021 18:14:52 +0000 (13:14 -0500)]
Keep track of spans in format strings

3 years agoUse in_constant instead of is_const
Yukio Tanaka [Tue, 16 Mar 2021 15:06:42 +0000 (00:06 +0900)]
Use in_constant instead of is_const

3 years agoAuto merge of #6912 - flip1995:dep-cleanup, r=Manishearth
bors [Tue, 16 Mar 2021 13:56:13 +0000 (13:56 +0000)]
Auto merge of #6912 - flip1995:dep-cleanup, r=Manishearth

Get rid of some unused dependecies

changelog: none

3 years agoGet rid of some unused dependecies
flip1995 [Mon, 15 Mar 2021 18:20:01 +0000 (19:20 +0100)]
Get rid of some unused dependecies

3 years agoFix typo
Yukio Tanaka [Tue, 16 Mar 2021 10:56:47 +0000 (19:56 +0900)]
Fix typo

3 years agoFix FP of `manual_unwrap_or` in const fn
Yukio Tanaka [Tue, 16 Mar 2021 10:46:40 +0000 (19:46 +0900)]
Fix FP of `manual_unwrap_or` in const fn

3 years agoAuto merge of #6915 - smoelius:docs-link, r=llogiq
bors [Tue, 16 Mar 2021 07:08:48 +0000 (07:08 +0000)]
Auto merge of #6915 - smoelius:docs-link, r=llogiq

Do not show docs link when lint doesn't start with "clippy::"

This small change ensures that if the diagnostic functions are called from outside of Clippy, a docs link is not displayed.

---

*Please write a short comment explaining your change (or "none" for internal only changes)*
changelog: restrict docs links

3 years agoAuto merge of #6889 - Y-Nak:refactor-unit-types, r=flip1995
bors [Tue, 16 Mar 2021 02:57:33 +0000 (02:57 +0000)]
Auto merge of #6889 - Y-Nak:refactor-unit-types, r=flip1995

Refactor unit types

Ref:  #6724
r? `@flip1995`

Changes:
1. Extract `unit_types` from `types` group.
2. Move lints of `unit_types` to their own modules.

Notes:
Other lints of `unit_types` is still scattered around the `clippy_lints`, e.g. `result_unit_err` or `option_map_unit_fn`.
These should be addressed in another PR.

changelog: none

3 years agoRemove unit_types::utils::is_unit
Yoshitomo Nakanishi [Tue, 16 Mar 2021 01:37:05 +0000 (10:37 +0900)]
Remove unit_types::utils::is_unit

3 years agoMove unit_arg to its own module
Yoshitomo Nakanishi [Fri, 12 Mar 2021 03:47:21 +0000 (12:47 +0900)]
Move unit_arg to its own module

3 years agoMove unit_cmp to its own module
Yoshitomo Nakanishi [Fri, 12 Mar 2021 03:38:31 +0000 (12:38 +0900)]
Move unit_cmp to its own module

3 years agoMove let_unit_value to its own module
Yoshitomo Nakanishi [Fri, 12 Mar 2021 03:28:31 +0000 (12:28 +0900)]
Move let_unit_value to its own module

3 years agoExtract utility functions to utils.rs
Yoshitomo Nakanishi [Fri, 12 Mar 2021 03:15:45 +0000 (12:15 +0900)]
Extract utility functions to utils.rs

3 years agoExtract lints of unit_types group from types group
Yoshitomo Nakanishi [Fri, 12 Mar 2021 03:04:44 +0000 (12:04 +0900)]
Extract lints of unit_types group from types group

3 years agoAuto merge of #6916 - camsteffen:diagnostics-util, r=Manishearth
bors [Tue, 16 Mar 2021 02:09:43 +0000 (02:09 +0000)]
Auto merge of #6916 - camsteffen:diagnostics-util, r=Manishearth

Don't re-export `clippy_utils::diagnostics::*`

changelog: none

Continues #6907

3 years agoDon't re-export clippy_utils::diagnostics::*
Cameron Steffen [Tue, 16 Mar 2021 00:55:45 +0000 (19:55 -0500)]
Don't re-export clippy_utils::diagnostics::*

3 years agoAuto merge of #6914 - camsteffen:source-utils, r=Manishearth
bors [Tue, 16 Mar 2021 00:08:01 +0000 (00:08 +0000)]
Auto merge of #6914 - camsteffen:source-utils, r=Manishearth

Move some utils to `clippy_utils::source`

changelog: none

Continues #6907

3 years agoAuto merge of #6828 - mgacek8:issue_6758_enhance_wrong_self_convention, r=flip1995
bors [Mon, 15 Mar 2021 22:36:57 +0000 (22:36 +0000)]
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`.

3 years agoAuto merge of #6907 - camsteffen:ty-utils, r=flip1995
bors [Mon, 15 Mar 2021 22:13:45 +0000 (22:13 +0000)]
Auto merge of #6907 - camsteffen:ty-utils, r=flip1995

Move some utils to `clippy_utils::ty`

changelog: none

`clippy_utils::*` has become a giant junk drawer. This is one step to clean it up a bit. One motivation is that I believe the long import statements cause more merge conflicts.

3 years agoMove some utils to clippy_utils::source module
Cameron Steffen [Sun, 14 Mar 2021 23:17:44 +0000 (18:17 -0500)]
Move some utils to clippy_utils::source module

3 years agoMove some utils to ty_utils
Cameron Steffen [Sat, 13 Mar 2021 23:01:03 +0000 (17:01 -0600)]
Move some utils to ty_utils

3 years agoAuto merge of #6831 - camsteffen:suspicious-map, r=Y-Nak,flip1995
bors [Mon, 15 Mar 2021 15:56:56 +0000 (15:56 +0000)]
Auto merge of #6831 - camsteffen:suspicious-map, r=Y-Nak,flip1995

Fix suspicious_map false positives

changelog: Fix suspicious_map false positives

Fixes #5253
Replaces #5375

3 years agoImprove `find_binding_init` docs
Cameron Steffen [Mon, 15 Mar 2021 13:51:23 +0000 (08:51 -0500)]
Improve `find_binding_init` docs

3 years agoDo not show docs link when lint doesn't start with "clippy::"
Samuel E. Moelius III [Mon, 15 Mar 2021 09:40:21 +0000 (05:40 -0400)]
Do not show docs link when lint doesn't start with "clippy::"

3 years agoFix suspicious_map false positives
Ben Boeckel [Thu, 26 Mar 2020 01:13:24 +0000 (21:13 -0400)]
Fix suspicious_map false positives

3 years agoAuto merge of #6895 - iobtl:reformat_unnecessary_cast, r=llogiq
bors [Sun, 14 Mar 2021 15:01:01 +0000 (15:01 +0000)]
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.

3 years agouse lint_unnecessary_cast for literals, suggest `_` if not present
iobtl [Sun, 14 Mar 2021 00:09:08 +0000 (08:09 +0800)]
use lint_unnecessary_cast for literals, suggest `_` if not present

3 years agoAuto merge of #6859 - magurotuna:if_then_some_else_none, r=giraffate
bors [Sat, 13 Mar 2021 15:54:54 +0000 (15:54 +0000)]
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`

3 years agoAuto merge of #6820 - mgacek8:issue_6562_enhance_mem_replace_with_default_with_other_...
bors [Sat, 13 Mar 2021 15:43:00 +0000 (15:43 +0000)]
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()`

3 years agoAuto merge of #6865 - Jarcho:explicit_deref_methods, r=llogiq
bors [Sat, 13 Mar 2021 15:31:14 +0000 (15:31 +0000)]
Auto merge of #6865 - Jarcho:explicit_deref_methods, r=llogiq

`explicit_deref_methods` improvements

Breaking up #6837

changelog: `explicit_deref_methods` will lint chained `deref` calls and ufcs style calls

3 years agoProperly lint macro arguments for `explicit_deref_methods`
Jason Newcomb [Sat, 13 Mar 2021 13:27:42 +0000 (08:27 -0500)]
Properly lint macro arguments for `explicit_deref_methods`

3 years agoKeep track of whether `deref` or `deref_mut` was called
Jason Newcomb [Sat, 13 Mar 2021 01:13:45 +0000 (20:13 -0500)]
Keep track of whether `deref` or `deref_mut` was called
Remove more unnecessary code

3 years agoRemove unneeded code.
Jason Newcomb [Tue, 9 Mar 2021 15:37:15 +0000 (10:37 -0500)]
Remove unneeded code.

3 years agoMake `explicit_deref_methods` check for multiple deref calls
Jason Newcomb [Tue, 2 Mar 2021 18:32:56 +0000 (13:32 -0500)]
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

3 years agoreplace span_lint with span_lint_and_sugg along with error message
iobtl [Sat, 13 Mar 2021 08:54:59 +0000 (16:54 +0800)]
replace span_lint with span_lint_and_sugg along with error message

3 years agoAuto merge of #6892 - matthiaskrgr:inc_struct_ctor, r=Y-Nak
bors [Sat, 13 Mar 2021 04:52:40 +0000 (04:52 +0000)]
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`

3 years agoAuto merge of #6891 - Y-Nak:use-iterator-sym, r=Manishearth
bors [Fri, 12 Mar 2021 22:36:49 +0000 (22:36 +0000)]
Auto merge of #6891 - Y-Nak:use-iterator-sym, r=Manishearth

Use sym::Iterator instead of paths::ITERATOR

Since `sym::Iterator` was added to diagnostic_item, it's time to remove `paths::ITERATOR`.
ref: #5393

changelog: Add `is_trait_method` to `clippy_utils`
changelog: Remove `paths::ITERATOR`

3 years agomem_replace_with_default: use diagnostic items intead of paths
Mateusz Gacek [Fri, 12 Mar 2021 20:00:08 +0000 (12:00 -0800)]
mem_replace_with_default: use diagnostic items intead of paths

3 years agomem_replace_with_default: recognize some std library ctors
Mateusz Gacek [Mon, 1 Mar 2021 15:49:52 +0000 (16:49 +0100)]
mem_replace_with_default: recognize some std library ctors

3 years agoinconsistent_struct_constructor: try to make message and lint description a bit clearer
Matthias Krüger [Fri, 12 Mar 2021 19:40:23 +0000 (20:40 +0100)]
inconsistent_struct_constructor: try to make message and lint description a bit clearer

3 years agoUse sym::Iterator instead of paths::ITERATOR
Yoshitomo Nakanishi [Fri, 12 Mar 2021 17:09:19 +0000 (02:09 +0900)]
Use sym::Iterator instead of paths::ITERATOR

3 years agoImprove suggestion and make it work for macros
Yusuke Tanaka [Fri, 12 Mar 2021 11:46:46 +0000 (20:46 +0900)]
Improve suggestion and make it work for macros

3 years agowrong_self_convention: fix lint in case of `to_*_mut` method
Mateusz Gacek [Fri, 12 Mar 2021 07:47:15 +0000 (23:47 -0800)]
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`.