]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agomove PATTERN_METHODS table directly into file
Marcel Hellwig [Mon, 3 May 2021 14:21:27 +0000 (16:21 +0200)]
move PATTERN_METHODS table directly into file

also removed rustfmt::skip

3 years agoadd strip_{prefix,suffix} to PATTERN_METHODS
Marcel Hellwig [Mon, 3 May 2021 14:18:41 +0000 (16:18 +0200)]
add strip_{prefix,suffix} to PATTERN_METHODS

this will warn, if a single_char_pattern is used in one of the above
methods

3 years agoAuto merge of #7150 - camsteffen:better-conf, r=llogiq
bors [Sun, 2 May 2021 14:00:09 +0000 (14:00 +0000)]
Auto merge of #7150 - camsteffen:better-conf, r=llogiq

`Conf` macro improvements

changelog: Allow `default_trait_access` in macros

Mainly this is a change to use serde as in [Manually implementing Deserialize for a struct](https://serde.rs/deserialize-struct.html), which opens the door for a cleaner implementation overall.

* Allow `default_trait_access` in macros (tangential, but used in this PR)
* Deserialize into `TryConf { conf, errors }` instead of using a global `ERRORS` variable.
* Improve the `define_Conf!` macro
* Remove the redundant string literal `(name, "name", ..)`
* Support deprecated configs with `#[conf_deprecated(message)]`. Message shows in error.
* Make the default value optional. Use `Default::default()` if omitted.
* Invalid config value error now shows the key (see test output)
* Cleaner `impl Default for Conf` (no `toml::from_str("")`)

3 years agoRefactor config deserialization
Cameron Steffen [Wed, 28 Apr 2021 02:04:06 +0000 (21:04 -0500)]
Refactor config deserialization

3 years agoDisable default_trait_access in macros
Cameron Steffen [Wed, 28 Apr 2021 02:03:48 +0000 (21:03 -0500)]
Disable default_trait_access in macros

3 years agoAuto merge of #7146 - mgacek8:mgacek8-small-fix, r=flip1995
bors [Fri, 30 Apr 2021 15:39:09 +0000 (15:39 +0000)]
Auto merge of #7146 - mgacek8:mgacek8-small-fix, r=flip1995

Small fix in CONTRIBUTING.md

This is a section for `IntelliJ Rust`, not `rust-analyzer`.
changelog: none

3 years agoSmall fix in CONTRIBUTING.md
Mateusz Gacek [Fri, 30 Apr 2021 15:27:42 +0000 (17:27 +0200)]
Small fix in CONTRIBUTING.md

3 years agoAuto merge of #7144 - rust-lang:while_immutable_mut_cond, r=flip1995
bors [Fri, 30 Apr 2021 15:08:27 +0000 (15:08 +0000)]
Auto merge of #7144 - rust-lang:while_immutable_mut_cond, r=flip1995

while_immutable_cond: check condition for mutation

This fixes #6689 by also checking the bindings mutated in the condition, whereas it was previously only checked in the loop body.

---

changelog: Fix FP in [`while_immutable_cond`] where mutation in the loop variable wasn't picked up.

3 years agoAuto merge of #6951 - Jarcho:implicit_return_fp, r=flip1995
bors [Fri, 30 Apr 2021 14:55:56 +0000 (14:55 +0000)]
Auto merge of #6951 - Jarcho:implicit_return_fp, r=flip1995

`implicit_return` improvements

fixes: #6940

changelog: Fix `implicit_return` suggestion for async functions
changelog: Improve `implicit_return` suggestions when returning the result of a macro
changelog: Check for `break` expressions inside a loop which are then implicitly returned
changelog: Allow all diverging functions in `implicit_return`, not just panic functions

3 years agoAuto merge of #7118 - TaKO8Ki:fix-false-positive-in-comparison-chain, r=giraffate
bors [Fri, 30 Apr 2021 06:30:38 +0000 (06:30 +0000)]
Auto merge of #7118 - TaKO8Ki:fix-false-positive-in-comparison-chain, r=giraffate

Fix a false-positive inside const fn in `comparison_chain`

closes https://github.com/rust-lang/rust-clippy/issues/7082

changelog: fix a false-positive inside const fn in [`comparison_chain`]

3 years agouse `in_constant`
Takayuki [Fri, 30 Apr 2021 05:40:35 +0000 (14:40 +0900)]
use `in_constant`

3 years agoAuto merge of #7141 - camsteffen:conf-file, r=flip1995
bors [Thu, 29 Apr 2021 14:57:24 +0000 (14:57 +0000)]
Auto merge of #7141 - camsteffen:conf-file, r=flip1995

Remove leftover plugin conf_file code

changelog: none

Removes dead code that used to support the following syntax:

```rust
#![plugin(clippy(conf_file="path/to/clippy's/configuration"))]
```

RLS (and others?) will need to remove the `&[]` from `clippy_lints::read_conf(&[], sess)`.

r? `@flip1995`

3 years agowhile_immutable_cond: check condition for mutation
Andre Bogus [Thu, 29 Apr 2021 08:10:58 +0000 (10:10 +0200)]
while_immutable_cond: check condition for mutation

3 years agoRemove leftover plugin conf_file code
Cameron Steffen [Wed, 28 Apr 2021 19:29:13 +0000 (14:29 -0500)]
Remove leftover plugin conf_file code

3 years agoAuto merge of #7140 - matthiaskrgr:ice_std, r=llogiq
bors [Tue, 27 Apr 2021 23:39:41 +0000 (23:39 +0000)]
Auto merge of #7140 - matthiaskrgr:ice_std, r=llogiq

fix ice when checking rustc libstd

```
thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', src/tools/clippy/clippy_lints/src/matches.rs:1595:53
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

I don't have a minimised testcase because I don't have time to reduce libstd down to a few lines right now.

---
changelog: fix index out of bounds access when checking rustc libstd

3 years agofix ice when checking rustc libstd
Matthias Krüger [Tue, 27 Apr 2021 21:16:19 +0000 (23:16 +0200)]
fix ice when checking rustc libstd

thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', src/tools/clippy/clippy_lints/src/matches.rs:1595:53
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I don't have a minimised testcase because I don't have time to reduce libstd down to a few lines right now.

3 years agoAuto merge of #7128 - Jarcho:const_fn_ice, r=flip1995
bors [Tue, 27 Apr 2021 14:21:11 +0000 (14:21 +0000)]
Auto merge of #7128 - Jarcho:const_fn_ice, r=flip1995

Fix ICE checking for feature gated const fn

fixes: #7126
changelog: Fix ICE in `missing_const_for_fn` when using a feature-gated `const fn`

3 years agoAuto merge of #7138 - mgacek8:issue6808_iter_cloned_collect_FN_with_large_array,...
bors [Tue, 27 Apr 2021 13:44:51 +0000 (13:44 +0000)]
Auto merge of #7138 - mgacek8:issue6808_iter_cloned_collect_FN_with_large_array, r=Manishearth

Fix FN in `iter_cloned_collect` with a large array

fixes #6808
changelog: Fix FN in `iter_cloned_collect` with a large array

I spotted that [is_iterable_array](https://github.com/rust-lang/rust-clippy/blob/a362a4d1d0edb66aef186c1d27b28c60573078f4/clippy_lints/src/loops/explicit_iter_loop.rs#L67-L75) function that `explicit_iter_loop` lint is using only works for array sizes <= 32.
There is this comment:
> IntoIterator is currently only implemented for array sizes <= 32 in rustc

I'm a bit confused, because I read that [IntoIterator for arrays](https://doc.rust-lang.org/src/core/array/mod.rs.html#194-201) with const generic `N` is stable since = "1.0.0". Although Const Generics MVP were stabilized in Rust 1.51.

Should I set MSRV for the current change? I will try to test with older compilers soon.

3 years agoAuto merge of #7136 - mgacek8:issue6965_manual_unwrap_or_invalid_sugg_macro_expansion...
bors [Mon, 26 Apr 2021 21:39:40 +0000 (21:39 +0000)]
Auto merge of #7136 - mgacek8:issue6965_manual_unwrap_or_invalid_sugg_macro_expansion, r=llogiq

manual_unwrap_or: fix invalid code suggestion, due to macro expansion

fixes #6965

changelog: fix invalid code suggestion in `manual_unwrap_or` lint, due to macro expansion

3 years agoAuto merge of #7137 - camsteffen:msrv-mod, r=llogiq
bors [Mon, 26 Apr 2021 21:25:19 +0000 (21:25 +0000)]
Auto merge of #7137 - camsteffen:msrv-mod, r=llogiq

Refactor MSRV aliases

changelog: Remove MSRV from `needless_question_mark` and change MSRV for `missing_const_for_fn` from 1.37.0 to 1.46.0.

First [mentioned on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Better.20MSRV.20testing.20idea/near/236215074).

* Moves MSRV constants into `clippy_utils::msrvs`. Now they are named to represent a stabilized feature flag or library item that is required for a lint's suggestion.
* `needless_question_mark` no longer has MSRV. Not needed since it does not suggest adding `?`.
* `missing_const_for_fn` MSRV was changed from 1.37.0 to 1.46.0. This seems to be a past mistake.

3 years agoUpdate MSRV contribution docs
Cameron Steffen [Mon, 26 Apr 2021 20:47:39 +0000 (15:47 -0500)]
Update MSRV contribution docs

3 years agoRefactor MSRV aliases
Cameron Steffen [Mon, 26 Apr 2021 19:10:32 +0000 (14:10 -0500)]
Refactor MSRV aliases

3 years agoRemove needless_question_mark MSRV
Cameron Steffen [Mon, 26 Apr 2021 20:49:25 +0000 (15:49 -0500)]
Remove needless_question_mark MSRV

3 years agoFix FN in `iter_cloned_collect` with a large array
Mateusz Gacek [Mon, 26 Apr 2021 20:03:51 +0000 (13:03 -0700)]
Fix FN in `iter_cloned_collect` with a large array

3 years agofix invalid code suggestion in `manual_unwrap_or`, due to macro expansion
Mateusz Gacek [Mon, 26 Apr 2021 19:08:24 +0000 (12:08 -0700)]
fix invalid code suggestion in `manual_unwrap_or`, due to macro expansion

3 years agoAuto merge of #7134 - camsteffen:copied-msrv, r=Manishearth
bors [Mon, 26 Apr 2021 16:12:04 +0000 (16:12 +0000)]
Auto merge of #7134 - camsteffen:copied-msrv, r=Manishearth

Finish MSRV for cloned_instead_of_copied

changelog: none

r? `@Manishearth`

3 years agoFinish MSRV for cloned_instead_of_copied
Cameron Steffen [Mon, 26 Apr 2021 16:09:24 +0000 (11:09 -0500)]
Finish MSRV for cloned_instead_of_copied

3 years agoAuto merge of #7132 - rust-lang:single_element_loop_iter, r=Manishearth
bors [Mon, 26 Apr 2021 14:28:31 +0000 (14:28 +0000)]
Auto merge of #7132 - rust-lang:single_element_loop_iter, r=Manishearth

extend `single_element_loop` to match `.iter()`

This extends `single_element_loop` to also match `[..].iter()` in the loop argument. Related to #7125, but not completely fixing it due to the lint only firing if the array expression contains a local variable.

---

changelog: none

3 years agoextend `single_element_loop` to match `.iter()`
Andre Bogus [Sun, 25 Apr 2021 16:10:38 +0000 (18:10 +0200)]
extend `single_element_loop` to match `.iter()`

3 years agoAuto merge of #7129 - camsteffen:copied-msrv, r=Manishearth
bors [Sun, 25 Apr 2021 14:55:24 +0000 (14:55 +0000)]
Auto merge of #7129 - camsteffen:copied-msrv, r=Manishearth

cloned_instead_of_copied MSRV

changelog: none
(since the lint is still new)

Fixes #7127

r? `@Manishearth`

3 years agoFix cloned_instead_of_copied MSRV
Cameron Steffen [Sun, 25 Apr 2021 14:51:44 +0000 (09:51 -0500)]
Fix cloned_instead_of_copied MSRV

3 years agoFix ICE checking for feature gated const fn
Jason Newcomb [Sun, 25 Apr 2021 14:07:01 +0000 (10:07 -0400)]
Fix ICE checking for feature gated const fn

3 years agoAuto merge of #7124 - Jarcho:lintcheck-windows, r=phansch
bors [Fri, 23 Apr 2021 06:10:54 +0000 (06:10 +0000)]
Auto merge of #7124 - Jarcho:lintcheck-windows, r=phansch

Fix lintcheck on windows

changelog: None

3 years agoFix lintcheck on windows
Jason Newcomb [Thu, 22 Apr 2021 17:12:10 +0000 (13:12 -0400)]
Fix lintcheck on windows

3 years agoAuto merge of #7120 - cherryblossom000:7106, r=Manishearth
bors [Thu, 22 Apr 2021 14:36:21 +0000 (14:36 +0000)]
Auto merge of #7120 - cherryblossom000:7106, r=Manishearth

`single_component_path_imports`: ignore `pub(crate) use some_macro;`

Fixes #7106

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: Ignore exporting a macro within a crate using `pub(crate) use some_macro;` for [`single_component_path_imports`]

3 years agoAuto merge of #7100 - ABouttefeux:unused_io_amount, r=camsteffen
bors [Thu, 22 Apr 2021 13:57:06 +0000 (13:57 +0000)]
Auto merge of #7100 - ABouttefeux:unused_io_amount, r=camsteffen

Unused io amount detects `.read().ok()?`

fixes #7096
changelog: unused_io_amount now detect expertion like `.read().ok()?`,  `.read().or_else(|err| ...)?` and similar expressions.

3 years agoadd detection unused_io_amount of "or", "or_else" and "ok"
Aliénore Bouttefeux [Fri, 16 Apr 2021 18:12:16 +0000 (20:12 +0200)]
add detection unused_io_amount of "or", "or_else" and "ok"

3 years agoMinor cleanup of `implicit_return`
Jason Newcomb [Thu, 22 Apr 2021 13:11:36 +0000 (09:11 -0400)]
Minor cleanup of `implicit_return`

3 years agoAdd examples to better explain `walk_span_to_context`
Jason Newcomb [Wed, 14 Apr 2021 00:55:12 +0000 (20:55 -0400)]
Add examples to better explain `walk_span_to_context`

3 years agoFix `implicit_return` suggestion for async functions
Jason Newcomb [Fri, 2 Apr 2021 21:53:14 +0000 (17:53 -0400)]
Fix `implicit_return` suggestion for async functions

3 years agoImprove `implicit_return`
Jason Newcomb [Fri, 2 Apr 2021 02:46:10 +0000 (22:46 -0400)]
Improve `implicit_return`
Better suggestions when returning macro calls.
Suggest changeing all the break expressions in a loop, not just the final statement.
Don't lint divergent functions.
Don't suggest returning the result of any divergent fuction.

3 years ago`single_component_path_imports`: ignore `pub(crate) use some_macro;` (fixes #7106)
cherryblossom [Thu, 22 Apr 2021 09:34:36 +0000 (19:34 +1000)]
`single_component_path_imports`: ignore `pub(crate) use some_macro;` (fixes #7106)

3 years agoAuto merge of #7119 - flip1995:rustup, r=flip1995
bors [Thu, 22 Apr 2021 09:27:42 +0000 (09:27 +0000)]
Auto merge of #7119 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

3 years agoBump nightly version -> 2021-04-22
flip1995 [Thu, 22 Apr 2021 09:25:56 +0000 (11:25 +0200)]
Bump nightly version -> 2021-04-22

3 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 22 Apr 2021 09:24:26 +0000 (11:24 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup

3 years agoAuto merge of #7102 - taralx:taralx-patch-1, r=flip1995
bors [Thu, 22 Apr 2021 08:26:14 +0000 (08:26 +0000)]
Auto merge of #7102 - taralx:taralx-patch-1, r=flip1995

Switch transmute_ptr_to_ptr to "pedantic" class.

Per discussion in https://github.com/rust-lang/rust-clippy/issues/6372, this lint has significant false positives.

changelog: transmute_ptr_to_ptr defaults to "allow".

3 years agofix a false-positive inside const fn in comparison_chain
Takayuki [Thu, 22 Apr 2021 07:52:34 +0000 (16:52 +0900)]
fix a false-positive inside const fn in comparison_chain

3 years agoAuto merge of #7072 - ebobrow:imports-ending-with-self, r=camsteffen
bors [Wed, 21 Apr 2021 14:47:49 +0000 (14:47 +0000)]
Auto merge of #7072 - ebobrow:imports-ending-with-self, r=camsteffen

add unnecessary_self_imports lint

fixes #6552

changelog: add `unnecessary_self_imports` lint

3 years agoadd unnecessary_self_imports lint
Elliot Bobrow [Tue, 13 Apr 2021 01:24:47 +0000 (18:24 -0700)]
add unnecessary_self_imports lint

3 years agoAuto merge of #7083 - GuillaumeGomez:bool-assert-eq, r=camsteffen
bors [Wed, 21 Apr 2021 13:58:53 +0000 (13:58 +0000)]
Auto merge of #7083 - GuillaumeGomez:bool-assert-eq, r=camsteffen

Add lint to check for boolean comparison in assert macro calls

This PR adds a lint to check if an assert macro is using a boolean as "comparison value". For example:

```rust
assert_eq!("a".is_empty(), false);
```

Could be rewritten as:

```rust
assert!(!"a".is_empty());
```

PS: The dev guidelines are amazing. Thanks a lot for writing them!

changelog: Add `bool_assert_comparison` lint

3 years agoAuto merge of #7109 - ctennis:ct/asm_syntax_aarch64, r=flip1995
bors [Wed, 21 Apr 2021 08:49:15 +0000 (08:49 +0000)]
Auto merge of #7109 - ctennis:ct/asm_syntax_aarch64, r=flip1995

Ignore aarch64 for this test as it's x86 assembly only.  Fixes #7091

fixes #7091 - asm_syntax lint test will not compile on aarch64

changelog: none

3 years agoAuto merge of #7097 - yawara:fix/7069, r=llogiq
bors [Tue, 20 Apr 2021 08:26:21 +0000 (08:26 +0000)]
Auto merge of #7097 - yawara:fix/7069, r=llogiq

Fixed inconsistent_struct_constructor triggers in macro-generated code

fixes #7069

changelog: `inconsistent_struct_constructor`: Fix FP in macro expansion.

3 years agoAdd a test for FP in macro expansion
Yawara ISHIDA [Tue, 20 Apr 2021 04:33:39 +0000 (13:33 +0900)]
Add a test for FP in macro expansion

3 years agoAuto merge of #7092 - basavesh:fix#7066, r=giraffate
bors [Mon, 19 Apr 2021 23:06:21 +0000 (23:06 +0000)]
Auto merge of #7092 - basavesh:fix#7066, r=giraffate

useless use of format! should return function directly

fixes #7066

changelog: [`useless_format`] wraps the content in the braces when it's needed.

r? `@giraffate`

3 years agoAdd lint to check for boolean comparison in assert macro calls
Guillaume Gomez [Thu, 15 Apr 2021 13:26:57 +0000 (15:26 +0200)]
Add lint to check for boolean comparison in assert macro calls

3 years agofix suggestion for unsized function parameters
lcnr [Sun, 18 Apr 2021 17:35:23 +0000 (19:35 +0200)]
fix suggestion for unsized function parameters

3 years agoAuto merge of #7111 - giraffate:fix_link_in_doc, r=Manishearth
bors [Mon, 19 Apr 2021 15:56:04 +0000 (15:56 +0000)]
Auto merge of #7111 - giraffate:fix_link_in_doc, r=Manishearth

Fix links in doc

changelog: none

3 years agoIgnore aarch64 for this test as it's x86 assembly only. Fixes #7091
Caleb Tennis [Sun, 18 Apr 2021 23:13:46 +0000 (19:13 -0400)]
Ignore aarch64 for this test as it's x86 assembly only.  Fixes #7091

3 years agouseless use of format! should return function directly
Basavesh Shivakumar [Mon, 19 Apr 2021 15:20:21 +0000 (17:20 +0200)]
useless use of format! should return function directly

3 years agoAuto merge of #7112 - giraffate:update_pull_request_template, r=camsteffen
bors [Mon, 19 Apr 2021 14:39:11 +0000 (14:39 +0000)]
Auto merge of #7112 - giraffate:update_pull_request_template, r=camsteffen

Update pull request template

A follow-up of <https://github.com/rust-lang/rust-clippy/pull/7064#issuecomment-817857168>.

changelog: none

3 years agoUpdate pull request template
Takayuki Nakata [Mon, 19 Apr 2021 14:02:41 +0000 (23:02 +0900)]
Update pull request template

3 years agoFix links in doc
Takayuki Nakata [Mon, 19 Apr 2021 13:47:09 +0000 (22:47 +0900)]
Fix links in doc

3 years agoAuto merge of #7101 - camsteffen:flat-map-option, r=giraffate
bors [Mon, 19 Apr 2021 13:34:23 +0000 (13:34 +0000)]
Auto merge of #7101 - camsteffen:flat-map-option, r=giraffate

Add flat_map_option lint

changelog: Add flat_map_option lint

Closes #2241

3 years agoAuto merge of #7108 - rust-lang:fix-return-try-err, r=Manishearth
bors [Sun, 18 Apr 2021 23:47:18 +0000 (23:47 +0000)]
Auto merge of #7108 - rust-lang:fix-return-try-err, r=Manishearth

un-double `return` on try_err

This fixes #7103 by looking at the parent expression and omitting the "return " in the suggestion when its already a `return` expression.

---

changelog: none

3 years agoun-double `return` on try_err
Andre Bogus [Sun, 18 Apr 2021 21:49:54 +0000 (23:49 +0200)]
un-double `return` on try_err

3 years agoAuto merge of #78880 - CDirkx:not_supported, r=joshtriplett
bors [Sun, 18 Apr 2021 20:03:54 +0000 (20:03 +0000)]
Auto merge of #78880 - CDirkx:not_supported, r=joshtriplett

Add `Unsupported` to `std::io::ErrorKind`

I noticed a significant portion of the uses of `ErrorKind::Other` in std is for unsupported operations.
The notion that a specific operation is not available on a target (and will thus never succeed) seems semantically distinct enough from just "an unspecified error occurred", which is why I am proposing to add the variant `Unsupported` to `std::io::ErrorKind`.

**Implementation**:

The following variant will be added to `std::io::ErrorKind`:

```rust
/// This operation is unsupported on this platform.
Unsupported
```
`std::io::ErrorKind::Unsupported` is an error returned when a given operation is not supported on a platform, and will thus never succeed; there is no way for the software to recover. It will be used instead of `Other` where appropriate, e.g. on wasm for file and network operations.

`decode_error_kind` will be updated  to decode operating system errors to `Unsupported`:
- Unix and VxWorks: `libc::ENOSYS`
- Windows: `c::ERROR_CALL_NOT_IMPLEMENTED`
- WASI: `wasi::ERRNO_NOSYS`

**Stability**:
This changes the kind of error returned by some functions on some platforms, which I think is not covered by the stability guarantees of the std? User code could depend on this behavior, expecting `ErrorKind::Other`, however the docs already mention:

> Errors that are `Other` now may move to a different or a new `ErrorKind` variant in the future. It is not recommended to match an error against `Other` and to expect any additional characteristics, e.g., a specific `Error::raw_os_error` return value.

The most recent variant added to `ErrorKind` was `UnexpectedEof` in `1.6.0` (almost 5 years ago), but `ErrorKind` is marked as `#[non_exhaustive]` and the docs warn about exhaustively matching on it, so adding a new variant per se should not be a breaking change.

The variant `Unsupported` itself could be marked as `#[unstable]`, however, because this PR also immediately uses this new variant and changes the errors returned by functions I'm inclined to agree with the others in this thread that the variant should be insta-stabilized.

3 years agoFix clippy test using `ErrorKind`
Christiaan Dirkx [Mon, 29 Mar 2021 10:35:16 +0000 (12:35 +0200)]
Fix clippy test using `ErrorKind`

3 years agoAuto merge of #84064 - hyd-dev:unknown-lints, r=petrochenkov
bors [Sun, 18 Apr 2021 02:12:13 +0000 (02:12 +0000)]
Auto merge of #84064 - hyd-dev:unknown-lints, r=petrochenkov

Do not ignore path segments in the middle in `#[allow]`/`#[warn]`/`#[deny]`/`#[forbid]` attributes

Fixes #83477.

3 years agoDo not ignore path segments in the middle in `#[allow]`/`#[warn]`/`#[deny]`/`#[forbid...
hyd-dev [Sat, 10 Apr 2021 17:08:31 +0000 (01:08 +0800)]
Do not ignore path segments in the middle in `#[allow]`/`#[warn]`/`#[deny]`/`#[forbid]` attributes

3 years agoSwitch transmute_ptr_to_ptr to "pedantic" class.
JP Sugarbroad [Fri, 16 Apr 2021 21:29:23 +0000 (14:29 -0700)]
Switch transmute_ptr_to_ptr to "pedantic" class.

Per discussion in https://github.com/rust-lang/rust-clippy/issues/6372, this lint has significant false positives.

3 years agoAuto merge of #7099 - ABouttefeux:master, r=llogiq
bors [Fri, 16 Apr 2021 21:22:24 +0000 (21:22 +0000)]
Auto merge of #7099 - ABouttefeux:master, r=llogiq

add type in help message of from_over_into

fixes #7088
changelog: add type in help message of from_over_into

3 years agoAdd flat_map_option lint
Cameron Steffen [Fri, 16 Apr 2021 20:06:21 +0000 (15:06 -0500)]
Add flat_map_option lint

3 years agoAuto merge of #7087 - Jarcho:allman_style_else, r=camsteffen
bors [Fri, 16 Apr 2021 20:16:52 +0000 (20:16 +0000)]
Auto merge of #7087 - Jarcho:allman_style_else, r=camsteffen

Allow allman style braces in `suspicious_else_formatting`

fixes: #3864

Indentation checks could be added as well, but the lint already doesn't check for it.

changelog: Allow allman style braces in `suspicious_else_formatting`

3 years agoAllow allman style braces in `suspicious_else_formatting`
Jason Newcomb [Thu, 15 Apr 2021 15:49:45 +0000 (11:49 -0400)]
Allow allman style braces in `suspicious_else_formatting`

3 years agoAuto merge of #7075 - xFrednet:7054-fp-branches-sharing-code, r=camsteffen,flip1995
bors [Fri, 16 Apr 2021 18:33:45 +0000 (18:33 +0000)]
Auto merge of #7075 - xFrednet:7054-fp-branches-sharing-code, r=camsteffen,flip1995

Fixing FPs for the `branches_sharing_code` lint

Fixes #7053
Fixes #7054
And an additional CSS adjustment to support dark mode for every inline code. It currently only works in paragraphs, which was an oversight on my part :sweat_smile:. [Current Example](https://rust-lang.github.io/rust-clippy/master/index.html#blacklisted_name)

This also includes ~50 lines of doc comments and is therefor not as big as the changes would indicate. :penguin:

---

changelog: none

All of these bugs were introduced in this dev version and are therefor not worth a change log entry.

r? `@phansch`
cc: `@camsteffen` since you have a pretty good overview of the `SpanlessEq` implementation :upside_down_face:

3 years agoadded missing line in test ouput
Aliénore Bouttefeux [Fri, 16 Apr 2021 18:13:25 +0000 (20:13 +0200)]
added missing line in test ouput

3 years agoadd type in help of from over Into
Aliénore Bouttefeux [Fri, 16 Apr 2021 17:38:01 +0000 (19:38 +0200)]
add type in help of from over Into

3 years agoAuto merge of #7098 - camsteffen:cloned-copied, r=Manishearth
bors [Fri, 16 Apr 2021 17:32:13 +0000 (17:32 +0000)]
Auto merge of #7098 - camsteffen:cloned-copied, r=Manishearth

Add `cloned_instead_of_copied` lint

Don't go cloning all willy-nilly.

Featuring a new `get_iterator_item_ty` util!

changelog: Add cloned_instead_of_copied lint

Closes #3870

3 years agoAuto merge of #6568 - Jarcho:redundant_pattern_matching, r=flip1995
bors [Fri, 16 Apr 2021 16:45:59 +0000 (16:45 +0000)]
Auto merge of #6568 - Jarcho:redundant_pattern_matching, r=flip1995

Fix: redundant_pattern_matching drop order

Fixes #5746

A note about the change in drop order is added when the scrutinee (or any temporary in the expression) isn't known to be safe to drop in any order (i.e. doesn't implement the `Drop` trait, or contain such a type). There is a whitelist for some `std` types, but it's incomplete. Currently just `Vec<_>`, `Box<_>`, `Rc<_>` and `Arc<_>`, but only if the contained type is also safe to drop in any order.

Another lint for when the drop order changes could be added as allowed by default, but the drop order requirement is pretty subtle in this case. I think the note added to the lint should be enough to make someone think before applying the change.

changelog: Added a note to `redundant_pattern_matching` when the change in drop order might matter

3 years agoEat dogfood
Cameron Steffen [Fri, 16 Apr 2021 16:07:08 +0000 (11:07 -0500)]
Eat dogfood

3 years agoAdd cloned_instead_of_copied lint
Cameron Steffen [Fri, 16 Apr 2021 16:00:08 +0000 (11:00 -0500)]
Add cloned_instead_of_copied lint

3 years agoFixed incosistent_struct_constructor triggers in macro-generated code
Yawara ISHIDA [Fri, 16 Apr 2021 13:50:04 +0000 (22:50 +0900)]
Fixed incosistent_struct_constructor triggers in macro-generated code

3 years agoAuto merge of #6937 - Jarcho:map_entry_suggestion, r=giraffate
bors [Fri, 16 Apr 2021 13:23:23 +0000 (13:23 +0000)]
Auto merge of #6937 - Jarcho:map_entry_suggestion, r=giraffate

Improve `map_entry` suggestion

fixes: #5176
fixes: #4674
fixes: #4664
fixes: #1450

Still need to handle the value returned by `insert` correctly.

changelog: Improve `map_entry` suggestion. Will now suggest `or_insert`, `insert_with` or `match _.entry(_)` as appopriate.
changelog: Fix `map_entry` false positives where the entry api can't be used. e.g. when the map is used for multiple things.

3 years agoAuto merge of #7093 - Jarcho:single_match_fp, r=llogiq
bors [Fri, 16 Apr 2021 06:44:26 +0000 (06:44 +0000)]
Auto merge of #7093 - Jarcho:single_match_fp, r=llogiq

Fix `single_match`

fixes: #7038
changelog: Don't suggest an equality check for types which don't implement `PartialEq` in `single_match`

3 years agoRemove #[main] attribute.
Charles Lew [Thu, 8 Apr 2021 13:37:38 +0000 (21:37 +0800)]
Remove #[main] attribute.

3 years agoAuto merge of #7085 - Jarcho:manual_map_autoderef, r=giraffate
bors [Fri, 16 Apr 2021 03:05:52 +0000 (03:05 +0000)]
Auto merge of #7085 - Jarcho:manual_map_autoderef, r=giraffate

Don't allow adjustments for `manual_map`

fixes: #7077

The other option here would be to add the return type to the closure. It would be fine for simple types, but longer types can be rather unwieldy. Could also implement the adjustment manually.

changelog: Don't lint `manual_map` when type adjustments are added. e.g. autoderef

3 years agoFix `single_match`
Jason Newcomb [Fri, 16 Apr 2021 02:05:37 +0000 (22:05 -0400)]
Fix `single_match`
Check for `PartialEq` in addition to `StructuralPartialEq` before suggesting `==`

3 years ago`redundant_pattern_matching` fix inverted boolean when missing `Drop` trait\r\r# Please...
Jason Newcomb [Fri, 2 Apr 2021 23:04:45 +0000 (19:04 -0400)]
`redundant_pattern_matching` fix inverted boolean when missing `Drop` trait\r\r# Please enter the commit message for your changes. Lines starting\r# with '#' will be ignored, and an empty message aborts the commit.\r#\r# Date:      Fri Apr 2 19:04:45 2021 -0400\r#\r# On branch redundant_pattern_matching\r# Your branch is ahead of 'origin/redundant_pattern_matching' by 1 commit.\r#   (use "git push" to publish your local commits)\r#\r# Changes to be committed:\r# modified:   clippy_lints/src/matches.rs\r#\r\r# Please enter the commit message for your changes. Lines starting\r# with '#' will be ignored, and an empty message aborts the commit.\r#\r# Date:      Fri Apr 2 19:04:45 2021 -0400\r#\r# interactive rebase in progress; onto ebc64690d\r# Last commands done (6 commands done):\r#    pick 25d211ad8 Code cleanup and additional std types checked\r#    r 0c71ce56f `redundant_pattern_matching` fix inverted boolean when missing `Drop` trait\r# No commands remaining.\r# You are currently editing a commit while rebasing branch 'redundant_pattern_matching' on 'ebc64690d'.\r#\r# Changes to be committed:\r# modified:   clippy_lints/src/matches.rs\r#

3 years agoImprove `redundant_pattern_matching`
Jason Newcomb [Sun, 3 Jan 2021 19:01:01 +0000 (14:01 -0500)]
Improve `redundant_pattern_matching`
Add a note when the drop order change may result in different behaviour.

3 years agoAuto merge of #7049 - Jarcho:remove_match_path, r=camsteffen
bors [Thu, 15 Apr 2021 23:54:41 +0000 (23:54 +0000)]
Auto merge of #7049 - Jarcho:remove_match_path, r=camsteffen

Remove `match_path` and `match_qpath`

The only remaining usage is the `author` lint, so the functions are left in for now. The test result for `repl_uninit` changed, the lint was broken before.

The `collapsible_span_lint_calls` and `match_type_on_diag_item` tests have been changed. Both lints were broken when utils was extracted into it's own crate. `match_type_on_diag_item` isn't quite fixed, but it's at least less broken.

changelog: None

3 years agoRemove all usages of `match_path`, `match_qpath` and `match_path_ast` except the...
Jason Newcomb [Wed, 7 Apr 2021 20:19:25 +0000 (16:19 -0400)]
Remove all usages of `match_path`, `match_qpath` and `match_path_ast` except the `author` lint.
Add note to fix `MATCH_TYPE_ON_DIAG_ITEM`
Add false negative test for `uninit_assumed_init`

3 years agoAuto merge of #7090 - camsteffen:pre-expansion-note, r=Manishearth
bors [Thu, 15 Apr 2021 19:43:58 +0000 (19:43 +0000)]
Auto merge of #7090 - camsteffen:pre-expansion-note, r=Manishearth

Add a note for pre-expansion passes

changelog: none

Just had to turn away a PR for using pre-expansion. I don't think that was the first time. So hopefully this will inform people sooner.

r? flip1995

3 years agoAdd note for pre-expansion passes
Cameron Steffen [Thu, 15 Apr 2021 17:57:31 +0000 (12:57 -0500)]
Add note for pre-expansion passes

3 years agoDon't allow adjustments for `manual_map`
Jason Newcomb [Thu, 15 Apr 2021 14:37:42 +0000 (10:37 -0400)]
Don't allow adjustments for `manual_map`

3 years agoMinor cleanup of `map_entry` and a few additional tests.
Jason Newcomb [Tue, 30 Mar 2021 00:17:03 +0000 (20:17 -0400)]
Minor cleanup of `map_entry` and a few additional tests.

3 years ago`map_entry` improvements
Jason Newcomb [Thu, 25 Mar 2021 13:47:56 +0000 (09:47 -0400)]
`map_entry` improvements
Suggest using `or_insert_with` when possible

3 years ago`map_entry` improvements
Jason Newcomb [Thu, 25 Mar 2021 13:36:38 +0000 (09:36 -0400)]
`map_entry` improvements
Lint `if _.[!]contains_key(&_) { .. } else { .. }` so long as one of the branches contains an insertion.

3 years agoImprove `map_entry` lint
Jason Newcomb [Thu, 25 Mar 2021 13:25:04 +0000 (09:25 -0400)]
Improve `map_entry` lint
Fix false positives where the map is used before inserting into the map.
Fix false positives where two insertions happen.
Suggest using `if let Entry::Vacant(e) = _.entry(_)` when `or_insert` might be a semantic change

3 years agoPR suggestions and removing utils::parent_node_is_if_expr
xFrednet [Wed, 14 Apr 2021 17:40:51 +0000 (19:40 +0200)]
PR suggestions and removing utils::parent_node_is_if_expr

3 years agoAdded inferred local type comparion to SpanlessEq
xFrednet [Tue, 13 Apr 2021 20:55:47 +0000 (22:55 +0200)]
Added inferred local type comparion to SpanlessEq