]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 25 Mar 2021 17:38:13 +0000 (18:38 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

3 years agoAuto merge of #6959 - ebobrow:iss-6927-fix, r=camsteffen
bors [Thu, 25 Mar 2021 03:01:35 +0000 (03:01 +0000)]
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

3 years agocheck for `.to_string().into_bytes()` in string_lit_to_bytes
Elliot Bobrow [Wed, 24 Mar 2021 00:10:27 +0000 (17:10 -0700)]
check for `.to_string().into_bytes()` in string_lit_to_bytes

apply changes from review

3 years agoAuto merge of #6952 - Jarcho:new_ret_no_self_fp, r=Manishearth
bors [Wed, 24 Mar 2021 21:09:01 +0000 (21:09 +0000)]
Auto merge of #6952 - Jarcho:new_ret_no_self_fp, r=Manishearth

Fix `new_ret_no_self` false positive

fixes: #1724

changelog: Fix false positive with `new_ret_no_self` when returning `Self` with different generic arguments

3 years agoRename `contains_adt` to `contains_adt_constructor`
Jason Newcomb [Wed, 24 Mar 2021 20:19:27 +0000 (16:19 -0400)]
Rename `contains_adt` to `contains_adt_constructor`

3 years agoFix false positive with `new_ret_no_self` when returning `Self` with different generi...
Jason Newcomb [Tue, 23 Mar 2021 01:38:14 +0000 (21:38 -0400)]
Fix false positive with `new_ret_no_self` when returning `Self` with different generic arguments

3 years agoAuto merge of #6962 - TaKO8Ki:fix-false-positive-in-manual-flatten, r=llogiq
bors [Wed, 24 Mar 2021 18:42:20 +0000 (18:42 +0000)]
Auto merge of #6962 - TaKO8Ki:fix-false-positive-in-manual-flatten, r=llogiq

Fix false positive in `manual_flatten`

This pull request fixes false positive in `manual_flatten` in case using a slice of references .

closes: #6893

changelog: fix false positive in `manual_flatten`

3 years agomerge imports
Takayuki Maeda [Wed, 24 Mar 2021 15:17:43 +0000 (00:17 +0900)]
merge imports

3 years agofix false positive in manual_flatten
Takayuki Maeda [Wed, 24 Mar 2021 15:15:15 +0000 (00:15 +0900)]
fix false positive in manual_flatten

3 years agoAdd has_default to GenericParamDefKind::Const
kadmin [Tue, 11 Aug 2020 00:02:45 +0000 (00:02 +0000)]
Add has_default to GenericParamDefKind::Const

This currently creates a field which is always false on GenericParamDefKind for future use when
consts are permitted to have defaults

Update const_generics:default locations

Previously just ignored them, now actually do something about them.

Fix using type check instead of value

Add parsing

This adds all the necessary changes to lower const-generics defaults from parsing.

Change P<Expr> to AnonConst

This matches the arguments passed to instantiations of const generics, and makes it specific to
just anonymous constants.

Attempt to fix lowering bugs

3 years agoAuto merge of #6957 - camsteffen:eq-ty-kind, r=flip1995
bors [Tue, 23 Mar 2021 16:25:28 +0000 (16:25 +0000)]
Auto merge of #6957 - camsteffen:eq-ty-kind, r=flip1995

Factor out `SpanlessEq::eq_ty_kind`

changelog: none

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 #6950 - Sciencentistguy:master, r=phansch
bors [Mon, 22 Mar 2021 20:29:13 +0000 (20:29 +0000)]
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

3 years agoAuto merge of #79278 - mark-i-m:stabilize-or-pattern, r=nikomatsakis
bors [Mon, 22 Mar 2021 19:48:27 +0000 (19:48 +0000)]
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

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 agoIgnore str::len() in or_fun_call lint.
Jamie Quigley [Mon, 22 Mar 2021 19:34:20 +0000 (19:34 +0000)]
Ignore str::len() in or_fun_call lint.

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 agoupdate `const_eval_resolve`
lcnr [Sat, 13 Mar 2021 15:31:38 +0000 (16:31 +0100)]
update `const_eval_resolve`

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 agoclippy: stabilize or_patterns lint
mark [Sat, 21 Nov 2020 21:22:32 +0000 (15:22 -0600)]
clippy: stabilize or_patterns lint

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 agohir: Preserve used syntax in `TyKind::TraitObject`
Vadim Petrochenkov [Sat, 13 Mar 2021 12:44:29 +0000 (15:44 +0300)]
hir: Preserve used syntax in `TyKind::TraitObject`

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 #82122 - bstrie:dep4real, r=dtolnay
bors [Wed, 17 Mar 2021 19:39:03 +0000 (19:39 +0000)]
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.

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 agoAuto merge of #83188 - petrochenkov:field, r=lcnr
bors [Wed, 17 Mar 2021 16:49:46 +0000 (16:49 +0000)]
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.

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 agoRollup merge of #83092 - petrochenkov:qspan, r=estebank
Yuki Okushi [Wed, 17 Mar 2021 06:20:54 +0000 (15:20 +0900)]
Rollup merge of #83092 - petrochenkov:qspan, r=estebank

More precise spans for HIR paths

`Ty::assoc_item` is lowered to `<Ty>::assoc_item` in HIR, but `Ty` got span from the whole path.
This PR fixes that, and adjusts some diagnostic code that relied on `Ty` having the whole path span.

This is a pre-requisite for https://github.com/rust-lang/rust/pull/82868 (we cannot report suggestions like `Tr::assoc` -> `<dyn Tr>::assoc` with the current imprecise spans).
r? ````@estebank````

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 agoAuto merge of #82536 - sexxi-goose:handle-patterns-take-2, r=nikomatsakis
bors [Tue, 16 Mar 2021 19:19:06 +0000 (19:19 +0000)]
Auto merge of #82536 - sexxi-goose:handle-patterns-take-2, r=nikomatsakis

2229: Handle patterns within closures correctly when `capture_disjoint_fields` is enabled

This PR fixes several issues related to handling patterns within closures when `capture_disjoint_fields` is enabled.
1. Matching is always considered a use of the place, even with `_` patterns
2. Compiler ICE when capturing fields in closures through `let` assignments

To do so, we

- Introduced new Fake Reads
- Delayed use of `Place` in favor of `PlaceBuilder`
- Ensured that `PlaceBuilder` can be resolved before attempting to extract `Place` in any of the pattern matching code

Closes rust-lang/project-rfc-2229/issues/27
Closes rust-lang/project-rfc-2229/issues/24
r? `@nikomatsakis`

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 agoast: Reduce size of `ExprKind` by boxing fields of `ExprKind::Struct`
Vadim Petrochenkov [Tue, 16 Mar 2021 00:15:53 +0000 (03:15 +0300)]
ast: Reduce size of `ExprKind` by boxing fields of `ExprKind::Struct`

3 years agoast/hir: Rename field-related structures
Vadim Petrochenkov [Mon, 15 Mar 2021 21:36:07 +0000 (00:36 +0300)]
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.

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 agoUpdate clippy tests
Vadim Petrochenkov [Mon, 15 Mar 2021 20:52:57 +0000 (23:52 +0300)]
Update clippy tests