]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAdd str_util helpers to split camelcase strings
dswij [Wed, 22 Dec 2021 15:18:24 +0000 (23:18 +0800)]
Add str_util helpers to split camelcase strings

2 years agoFix False Positive on `enum_variants` when prefixes are not camel-case
dswij [Wed, 22 Dec 2021 15:18:11 +0000 (23:18 +0800)]
Fix False Positive on `enum_variants` when prefixes are not camel-case

2 years agoRefactor `enum_variants`
dswij [Wed, 15 Dec 2021 04:08:13 +0000 (12:08 +0800)]
Refactor `enum_variants`

2 years agoAuto merge of #8167 - rust-lang:fix-8166, r=xFredNet
bors [Sat, 25 Dec 2021 13:38:08 +0000 (13:38 +0000)]
Auto merge of #8167 - rust-lang:fix-8166, r=xFredNet

fix an ICE on unwrapping a None

This very likely fixes #8166 though I wasn't able to meaningfully reduce a test case. This line is the only call to `unwrap` within that function, which was the one in the stack trace that triggered the ICE, so I think we'll be OK.

`@hackmad` can you pull and build this branch and check if it indeed fixes your problem?

---

changelog: Fixed ICE in [`unnecessary_cast`]

2 years agofix an ICE on unwrapping a None
Andre Bogus [Sat, 25 Dec 2021 12:11:54 +0000 (13:11 +0100)]
fix an ICE on unwrapping a None

2 years agoAuto merge of #8165 - ebobrow:shadow_reuse_fn, r=xFrednet
bors [Sat, 25 Dec 2021 11:58:25 +0000 (11:58 +0000)]
Auto merge of #8165 - ebobrow:shadow_reuse_fn, r=xFrednet

fix [`shadow_reuse`] false negative for if let bindings

fixes #8087

changelog: trigger [`shadow_reuse`] instead of [`shadow_unrelated`] on shadowed `if let` bindings

2 years agofix `shadow_reuse` false negative for if let bindings
Elliot Bobrow [Fri, 24 Dec 2021 21:20:40 +0000 (13:20 -0800)]
fix `shadow_reuse` false negative for if let bindings

2 years agoAuto merge of #8163 - pmnoxx:piotr-improve-unwrap-or-default, r=Manishearth
bors [Fri, 24 Dec 2021 12:34:09 +0000 (12:34 +0000)]
Auto merge of #8163 - pmnoxx:piotr-improve-unwrap-or-default, r=Manishearth

Improve `unwrap_or_else_default` when handling `unwrap_or_else(XXX::new)`

changelog:  change `unwrap_or_else_default` to work with std constructors like `Vec::new`, `HashSet::new`, `HashMap::new`.

Notes:
- Code to handle detecting those constructors is already there. I moved it out to `is_default_equivalent_call`

2 years agoSimplify code
Piotr Mikulski [Fri, 24 Dec 2021 06:12:08 +0000 (22:12 -0800)]
Simplify code

2 years agoRefactor
Piotr Mikulski [Fri, 24 Dec 2021 06:00:14 +0000 (22:00 -0800)]
Refactor

2 years agoclippy
Piotr Mikulski [Fri, 24 Dec 2021 05:47:31 +0000 (21:47 -0800)]
clippy

2 years agorefactor
Piotr Mikulski [Fri, 24 Dec 2021 05:46:21 +0000 (21:46 -0800)]
refactor

2 years agocargo dev fmt
Piotr Mikulski [Fri, 24 Dec 2021 05:44:13 +0000 (21:44 -0800)]
cargo dev fmt

2 years agoFix tests
Piotr Mikulski [Fri, 24 Dec 2021 05:43:30 +0000 (21:43 -0800)]
Fix tests

2 years agoFix tests
Piotr Mikulski [Fri, 24 Dec 2021 05:42:56 +0000 (21:42 -0800)]
Fix tests

2 years agorewrite the PR
Piotr Mikulski [Fri, 24 Dec 2021 05:41:00 +0000 (21:41 -0800)]
rewrite the PR

2 years agoImrpove `unwrap_or_else_default`
Piotr Mikulski [Fri, 24 Dec 2021 03:13:57 +0000 (19:13 -0800)]
Imrpove `unwrap_or_else_default`

2 years agoAuto merge of #8144 - Gh0stm4chine:master, r=xFrednet
bors [Thu, 23 Dec 2021 10:06:17 +0000 (10:06 +0000)]
Auto merge of #8144 - Gh0stm4chine:master, r=xFrednet

Add suggestion for neg_multiply lint

This fixes #8115 by adding a suggestion for [neg_multiply].

My first issue on Github, any feedback or input is welcome 😃

changelog: create a suggestion for `neg_multiply`

2 years agoAdd allow unused
Oussama [Thu, 23 Dec 2021 09:45:16 +0000 (10:45 +0100)]
Add allow unused

2 years agoAdd allow precedence lint to prevent rustfix from failing
Oussama [Thu, 23 Dec 2021 08:22:29 +0000 (09:22 +0100)]
Add allow precedence lint to prevent rustfix from failing

2 years agoAdd support for suggestion when using an expression
Oussama [Tue, 21 Dec 2021 21:00:14 +0000 (22:00 +0100)]
Add support for suggestion when using an expression

2 years agoadd suggestion for neg_multiply lint
Oussama [Sun, 19 Dec 2021 08:48:25 +0000 (09:48 +0100)]
add suggestion for neg_multiply lint

2 years agoAuto merge of #8150 - flip1995:clippy_utils_test, r=xFrednet
bors [Mon, 20 Dec 2021 22:53:47 +0000 (22:53 +0000)]
Auto merge of #8150 - flip1995:clippy_utils_test, r=xFrednet

Test clippy_utils in CI

r? `@xFrednet` Since you did the last refactor of the `str_utils` functions in #7873

changelog: Make sure tests in `clippy_utils` are passing by testing it in CI

2 years agoTest clippy_utils in CI
flip1995 [Mon, 20 Dec 2021 18:56:06 +0000 (19:56 +0100)]
Test clippy_utils in CI

This makes sure that the tests in clippy_utils are run in CI.

When looking into this I discovered that two tests were failing and
multiple doc tests were failing. This fixes those tests and enables a
few more doc tests.

2 years agoAuto merge of #8138 - r00ster91:safety, r=giraffate
bors [Mon, 20 Dec 2021 00:15:18 +0000 (00:15 +0000)]
Auto merge of #8138 - r00ster91:safety, r=giraffate

Fix `SAFETY` comment tag casing in undocumented_unsafe_blocks

This changes the lint introduced in #7748 to suggest adding a `SAFETY` comment instead of a `Safety` comment.

Searching for `// Safety:` in rust-lang/rust yields 67 results while `// SAFETY:` yields 1072.
I think it's safe to say that this comment tag is written in upper case, just like `TODO`, `FIXME` and so on are. As such I would expect this lint to follow the official convention as well.

Note that I intentionally introduced some casing diversity in `tests/ui/undocumented_unsafe_blocks.rs` to test more cases than just `Safety:`.

changelog: Capitalize `SAFETY` comment in [`undocumented_unsafe_blocks`]

2 years agoAuto merge of #8146 - GuillaumeGomez:must-use-self, r=xFrednet
bors [Sun, 19 Dec 2021 14:54:12 +0000 (14:54 +0000)]
Auto merge of #8146 - GuillaumeGomez:must-use-self, r=xFrednet

Don't emit RETURN_SELF_NOT_MUST_USE lint if `Self` already is marked as `#[must_use]`

New bug discovered with this lint. Hopefully, this is the last one.

---

changelog: none

2 years agoDon't emit RETURN_SELF_NOT_MUST_USE lint if `Self` already is marked as `#[must_use]`
Guillaume Gomez [Sun, 19 Dec 2021 14:10:36 +0000 (15:10 +0100)]
Don't emit RETURN_SELF_NOT_MUST_USE lint if `Self` already is marked as `#[must_use]`

2 years agoAuto merge of #8143 - GuillaumeGomez:RETURN_SELF_NOT_MUST_USE, r=xFrednet
bors [Sat, 18 Dec 2021 15:06:09 +0000 (15:06 +0000)]
Auto merge of #8143 - GuillaumeGomez:RETURN_SELF_NOT_MUST_USE, r=xFrednet

Ensure that RETURN_SELF_NOT_MUST_USE is not emitted if the method already has `#[must_use]`

Fixes https://github.com/rust-lang/rust-clippy/issues/8140.

---

Edit:

changelog: none

(The lint is not in beta yet, this should therefore not be included inside the changelog :) )

2 years agoEnsure that RETURN_SELF_NOT_MUST_USE is not emitted if the method already has a must_...
Guillaume Gomez [Sat, 18 Dec 2021 14:26:16 +0000 (15:26 +0100)]
Ensure that RETURN_SELF_NOT_MUST_USE is not emitted if the method already has a must_use attribute

2 years agoFix SAFETY comment tag casing in undocumented_unsafe_blocks
r00ster91 [Fri, 17 Dec 2021 19:48:38 +0000 (20:48 +0100)]
Fix SAFETY comment tag casing in undocumented_unsafe_blocks

2 years agoAuto merge of #8137 - flip1995:changelog, r=Manishearth
bors [Fri, 17 Dec 2021 17:01:05 +0000 (17:01 +0000)]
Auto merge of #8137 - flip1995:changelog, r=Manishearth

Fix commits and formatting of CHANGELOG.md

r? `@Manishearth`

Follow up to #8136

I think the beta commit update didn't take the backport we've done into account. I fixed the commit ranges. And while I was at it, I also applied my usual formatting to the changelog entries.

changelog: none

2 years agoFix commits and formatting of CHANGELOG.md
flip1995 [Fri, 17 Dec 2021 15:27:29 +0000 (16:27 +0100)]
Fix commits and formatting of CHANGELOG.md

2 years agoAuto merge of #8136 - Manishearth:changelog, r=giraffate
bors [Fri, 17 Dec 2021 14:24:35 +0000 (14:24 +0000)]
Auto merge of #8136 - Manishearth:changelog, r=giraffate

Update changelog

Apologies for the delay!

changelog: none

2 years agoUpdate CHANGELOG.md
Manish Goregaokar [Fri, 17 Dec 2021 14:21:01 +0000 (19:51 +0530)]
Update CHANGELOG.md

Co-authored-by: Takayuki Nakata <f.seasons017@gmail.com>
2 years agoUpdate CHANGELOG.md
Manish Goregaokar [Fri, 17 Dec 2021 14:20:53 +0000 (19:50 +0530)]
Update CHANGELOG.md

Co-authored-by: Takayuki Nakata <f.seasons017@gmail.com>
2 years agoUpdate changelog
Manish Goregaokar [Fri, 17 Dec 2021 13:56:29 +0000 (19:26 +0530)]
Update changelog

2 years agoAuto merge of #8135 - flip1995:backport_remerge, r=flip1995
bors [Fri, 17 Dec 2021 13:52:54 +0000 (13:52 +0000)]
Auto merge of #8135 - flip1995:backport_remerge, r=flip1995

Beta branch remerge

r? `@ghost`

changelog: none

2 years agoMerge remote-tracking branch 'upstream/beta' into backport_remerge
flip1995 [Fri, 17 Dec 2021 13:49:05 +0000 (14:49 +0100)]
Merge remote-tracking branch 'upstream/beta' into backport_remerge

2 years agoAuto merge of #8134 - flip1995:rustup, r=flip1995
bors [Fri, 17 Dec 2021 12:24:03 +0000 (12:24 +0000)]
Auto merge of #8134 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

2 years agoBump nightly version -> 2021-12-17
flip1995 [Fri, 17 Dec 2021 12:22:34 +0000 (13:22 +0100)]
Bump nightly version -> 2021-12-17

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Fri, 17 Dec 2021 11:22:41 +0000 (12:22 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agoAuto merge of #7978 - smoelius:master, r=llogiq
bors [Wed, 15 Dec 2021 10:46:43 +0000 (10:46 +0000)]
Auto merge of #7978 - smoelius:master, r=llogiq

Add `unnecessary_to_owned` lint

This PR adds a lint to check for unnecessary calls to `ToOwned::to_owned` and other similar functions (e.g., `Cow::into_owned`, `ToString::to_string`, etc.).

The lint checks for expressions of the form `&receiver.to_owned_like()` used in a position requiring type `&T` where one of the following is true:
* `receiver`'s type is `T` exactly
* `receiver`'s type implements `Deref<Target = T>`
* `receiver`'s type implements `AsRef<T>`

The lint additionally checks for expressions of the form `receiver.to_owned_like()` used as arguments of type `impl AsRef<T>`.

It would be nice if the lint could also check for expressions used as arguments to functions like the following:
```
fn foo<T: AsRef<str>>(x: T) { ... }
```
However, I couldn't figure out how to determine whether a function input type was instantiated from a parameter with a trait bound.

If someone could offer me some guidance, I would be happy to add such functionality.

Closes #7933

changelog: Add [`unnecessary_to_owned`] lint

2 years agoExpand `is_clone_like` comment
Samuel E. Moelius III [Wed, 15 Dec 2021 10:25:47 +0000 (05:25 -0500)]
Expand `is_clone_like` comment

2 years agoRollup merge of #90521 - jhpratt:stabilize-destructuring_assignment, r=jackh726,pnkfelix
Matthias Krüger [Wed, 15 Dec 2021 07:36:19 +0000 (08:36 +0100)]
Rollup merge of #90521 - jhpratt:stabilize-destructuring_assignment, r=jackh726,pnkfelix

Stabilize `destructuring_assignment`

Closes #71126

- [Stabilization report](https://github.com/rust-lang/rust/issues/71126#issuecomment-941148058)
- [Completed FCP](https://github.com/rust-lang/rust/issues/71126#issuecomment-954914819)

`@rustbot` label +F-destructuring-assignment +T-lang
Also needs +relnotes but I don't have permission to add that tag.

2 years agoStabilize `destructuring_assignment`
Jacob Pratt [Wed, 3 Nov 2021 06:50:57 +0000 (02:50 -0400)]
Stabilize `destructuring_assignment`

2 years agoRollup merge of #91881 - Patrick-Poitras:stabilize-iter-zip, r=scottmcm
Matthias Krüger [Wed, 15 Dec 2021 00:28:08 +0000 (01:28 +0100)]
Rollup merge of #91881 - Patrick-Poitras:stabilize-iter-zip, r=scottmcm

Stabilize `iter::zip`

Hello all!

As the tracking issue (#83574) for `iter::zip` completed the final commenting period without any concerns being raised, I hereby submit this stabilization PR on the issue.

As the pull request that introduced the feature (#82917) states, the `iter::zip` function is a shorter way to zip two iterators. As it's generally a quality-of-life/ergonomic improvement, it has been integrated into the codebase without any trouble, and has been
used in many places across the rust compiler and standard library since March without any issues.

For more details, I would refer to `@cuviper's` original PR, or the [function's documentation](https://doc.rust-lang.org/std/iter/fn.zip.html).

2 years agoRollup merge of #90939 - estebank:wg-af-polish, r=tmandry
Matthias Krüger [Wed, 15 Dec 2021 00:28:04 +0000 (01:28 +0100)]
Rollup merge of #90939 - estebank:wg-af-polish, r=tmandry

Tweak errors coming from `for`-loop, `?` and `.await` desugaring

 * Suggest removal of `.await` on non-`Future` expression
 * Keep track of obligations introduced by desugaring
 * Remove span pointing at method for obligation errors coming from desugaring
 * Point at called local sync `fn` and suggest making it `async`

```
error[E0277]: `()` is not a future
  --> $DIR/unnecessary-await.rs:9:10
   |
LL |     boo().await;
   |     -----^^^^^^ `()` is not a future
   |     |
   |     this call returns `()`
   |
   = help: the trait `Future` is not implemented for `()`
help: do not `.await` the expression
   |
LL -     boo().await;
LL +     boo();
   |
help: alternatively, consider making `fn boo` asynchronous
   |
LL | async fn boo () {}
   | +++++
```

Fix #66731.

2 years agoAddress review comments
Samuel E. Moelius III [Tue, 14 Dec 2021 23:36:19 +0000 (18:36 -0500)]
Address review comments

2 years agoRemove iter::zip feature gate from clippy
PFPoitras [Tue, 14 Dec 2021 22:10:57 +0000 (18:10 -0400)]
Remove iter::zip feature gate from clippy

2 years agoAuto merge of #91728 - Amanieu:stable_asm, r=joshtriplett
bors [Tue, 14 Dec 2021 21:15:22 +0000 (21:15 +0000)]
Auto merge of #91728 - Amanieu:stable_asm, r=joshtriplett

Stabilize asm! and global_asm!

Tracking issue: #72016

It's been almost 2 years since the original [RFC](https://github.com/rust-lang/rfcs/pull/2850) was posted and we're finally ready to stabilize this feature!

The main changes in this PR are:
- Removing `asm!` and `global_asm!` from the prelude as per the decision in #87228.
- Stabilizing the `asm` and `global_asm` features.
- Removing the unstable book pages for `asm` and `global_asm`. The contents are moved to the [reference](https://github.com/rust-lang/reference/pull/1105) and [rust by example](https://github.com/rust-lang/rust-by-example/pull/1483).
  - All links to these pages have been removed to satisfy the link checker. In a later PR these will be replaced with links to the reference or rust by example.
- Removing the automatic suggestion for using `llvm_asm!` instead of `asm!` if you're still using the old syntax, since it doesn't work anymore with `asm!` no longer being in the prelude. This only affects code that predates the old LLVM-style `asm!` being renamed to `llvm_asm!`.
- Updating `stdarch` and `compiler-builtins`.
- Updating all the tests.

r? `@joshtriplett`

2 years agoAdd comma
Samuel E. Moelius III [Mon, 13 Dec 2021 17:27:47 +0000 (12:27 -0500)]
Add comma

2 years agofix clippy tests
Esteban Kuber [Fri, 10 Dec 2021 17:20:57 +0000 (17:20 +0000)]
fix clippy tests

2 years agoFix rebase and clippy tests
Esteban Kuber [Tue, 16 Nov 2021 22:06:25 +0000 (22:06 +0000)]
Fix rebase and clippy tests

2 years agoFix clippy uses of QPath::LangItem
Esteban Kuber [Tue, 16 Nov 2021 20:44:25 +0000 (20:44 +0000)]
Fix clippy uses of QPath::LangItem

2 years agoHandle `to_vec` on for loop expression #8069
Samuel E. Moelius III [Mon, 13 Dec 2021 10:49:43 +0000 (05:49 -0500)]
Handle `to_vec` on for loop expression #8069

2 years agoAddress review comments
Samuel E. Moelius III [Tue, 30 Nov 2021 10:52:01 +0000 (05:52 -0500)]
Address review comments

* Share a list of methods with `implicit_clone`
* Ensure no overlap with `redundant_clone`

2 years agoAdd `unnecessary_to_owned` lint
Samuel E. Moelius III [Tue, 16 Nov 2021 00:25:08 +0000 (19:25 -0500)]
Add `unnecessary_to_owned` lint

2 years agoFix clippy tests
Amanieu d'Antras [Mon, 13 Dec 2021 00:00:51 +0000 (00:00 +0000)]
Fix clippy tests

2 years agoAuto merge of #91549 - fee1-dead:const_env, r=spastorino
bors [Sun, 12 Dec 2021 22:15:32 +0000 (22:15 +0000)]
Auto merge of #91549 - fee1-dead:const_env, r=spastorino

Eliminate ConstnessAnd again

Closes #91489.
Closes #89432.

Reverts #91491.
Reverts #89450.

r? `@spastorino`

2 years agoclippy owo
Ellen [Sun, 12 Dec 2021 12:34:21 +0000 (12:34 +0000)]
clippy owo

2 years agoRevert "Auto merge of #91491 - spastorino:revert-91354, r=oli-obk"
Deadbeef [Sun, 12 Dec 2021 04:34:46 +0000 (12:34 +0800)]
Revert "Auto merge of #91491 - spastorino:revert-91354, r=oli-obk"

This reverts commit ff2439b7b9bafcfdff86b7847128014699df8442, reversing
changes made to 2a9e0831d6603d87220cedd1b1293e2eb82ef55c.

2 years agoAuto merge of #8100 - c410-f3r:blah-blah-blah, r=giraffate
bors [Thu, 9 Dec 2021 23:50:02 +0000 (23:50 +0000)]
Auto merge of #8100 - c410-f3r:blah-blah-blah, r=giraffate

Fix `blocks_in_if_conditions` false positive

Fix #8099

changelog: Fix [`blocks_in_if_conditions`] false positive with an empty closure

2 years agoAuto merge of #8110 - xFrednet:0000-lintcheck-markdown-output, r=matthiaskrgr
bors [Thu, 9 Dec 2021 22:49:47 +0000 (22:49 +0000)]
Auto merge of #8110 - xFrednet:0000-lintcheck-markdown-output, r=matthiaskrgr

Update lintcheck output to use tables and add markdown support

This PR updates changes lintcheck's output to use text tables and adds a markdown option to use Markdown links in the reports table. At first, I tried to keep the original output format, but the loading of old stats broke with the markdown option. The old format is therefore sadly incompatible with the new one. I can if requested make it in a way that the markdown output is only and optional additional output, but that would require more work for little benefit IMO.

For now, lintcheck has two output types. Here are the examples (best viewed on desktop):

<details>
<summary>`cargo lintcheck --only anyhow`</summary>

```txt
clippy 0.1.59 (460bef22a 2021-12-08)

### Reports

target/lintcheck/sources/anyhow-1.0.38/build.rs:1:null clippy::cargo_common_metadata "package `anyhow` is missing `package.keywords` metadata"
target/lintcheck/sources/anyhow-1.0.38/src/error.rs:350:5 clippy::missing_panics_doc "docs for function which may panic missing `# Panics` section"
target/lintcheck/sources/anyhow-1.0.38/src/lib.rs:1:null clippy::cargo_common_metadata "package `anyhow` is missing `package.keywords` metadata"

### Stats:

| lint                                               | count |
| -------------------------------------------------- | ----- |
| clippy::missing_panics_doc                         |     1 |
| clippy::cargo_common_metadata                      |     2 |

### ICEs:

```

</details>

<details>
<summary>`cargo lintcheck --only anyhow --markdown` (The file links only work locally)</summary>

clippy 0.1.59 (460bef22a 2021-12-08)

### Reports

| file | lint | message |
| --- | --- | --- |
| [`anyhow-1.0.38/build.rs:1:null`](../target/lintcheck/sources/anyhow-1.0.38/build.rs#L1) | `clippy::cargo_common_metadata`                    | "package `anyhow` is missing `package.keywords` metadata" |
| [`anyhow-1.0.38/src/error.rs:350:5`](../target/lintcheck/sources/anyhow-1.0.38/src/error.rs#L350) | `clippy::missing_panics_doc`                       | "docs for function which may panic missing `# Panics` section" |
| [`anyhow-1.0.38/src/lib.rs:1:null`](../target/lintcheck/sources/anyhow-1.0.38/src/lib.rs#L1) | `clippy::cargo_common_metadata`                    | "package `anyhow` is missing `package.keywords` metadata" |

### Stats:

| lint                                               | count |
| -------------------------------------------------- | ----- |
| clippy::missing_panics_doc                         |     1 |
| clippy::cargo_common_metadata                      |     2 |

### ICEs:

</details>

The table margins are so large to keep the table inline for long file names and lint names

---

changelog: none

r? `@matthiaskrgr`

2 years agoUpdate lintcheck output to use tables and add markdown support
xFrednet [Thu, 9 Dec 2021 19:14:35 +0000 (20:14 +0100)]
Update lintcheck output to use tables and add markdown support

2 years agoAuto merge of #8096 - xFrednet:0000-remove-lintcheck-log-file, r=matthiaskrgr
bors [Thu, 9 Dec 2021 17:40:32 +0000 (17:40 +0000)]
Auto merge of #8096 - xFrednet:0000-remove-lintcheck-log-file, r=matthiaskrgr

Remove lintcheck log and add `--filter` option to lintcheck

This PR removes the really outdated lintcheck log from this repo and adds a new `--filter` option to force warnings of a lint. This also ignores `allow` attributes. I believe that this is a good thing, as we'll see if suppressed false positives are also fixed by the changes.

---

#### Example:
```sh
$ cargo lintcheck --filter identity_op
```

#### Output
```
clippy 0.1.59 (460bef22a 2021-12-08)

[..]/cargo-0.49.0/src/cargo/core/compiler/fingerprint.rs:1910:17 clippy::identity_op "the operation is ineffective. Consider reducing it to `(ret[0] as usize)`"
[..]/cargo-0.49.0/src/cargo/util/hex.rs:8:9 clippy::identity_op "the operation is ineffective. Consider reducing it to `num`"
[..]/libc-0.2.81/src/unix/linux_like/linux/mod.rs:2654:18 clippy::identity_op "the operation is ineffective. Consider reducing it to `(dev & 0x00000000000000ff)`"
[..]/libc-0.2.81/src/unix/linux_like/linux/mod.rs:2665:16 clippy::identity_op "the operation is ineffective. Consider reducing it to `(minor & 0x000000ff)`"
[..]/libc-0.2.81/src/unix/linux_like/mod.rs:1218:27 clippy::identity_op "the operation is ineffective. Consider reducing it to `IPOPT_CONTROL`"
[..]/rayon-1.5.0/src/slice/quicksort.rs:588:17 clippy::identity_op "the operation is ineffective. Consider reducing it to `len / 4`"
[..]/regex-1.3.2/src/dfa.rs:1380:14 clippy::identity_op "the operation is ineffective. Consider reducing it to `(empty_flags.start as u8)`"

Stats:
clippy::identity_op 7
ICEs:
```
Two of these lints are suppressed when lintcheck runs normally

---

changelog: none

r? `@matthiaskrgr` Feel free to reassign if you think that someone else would be a better reviewer :upside_down_face:

2 years agoAdd `filter` option to lintcheck
xFrednet [Wed, 8 Dec 2021 21:24:06 +0000 (22:24 +0100)]
Add `filter` option to lintcheck

2 years agoAuto merge of #8106 - medwards:rustc-lint-groups, r=flip1995
bors [Thu, 9 Dec 2021 13:36:51 +0000 (13:36 +0000)]
Auto merge of #8106 - medwards:rustc-lint-groups, r=flip1995

Remind users of separate `rustc` lint groups

changelog: none

fixes #8104

2 years agoRemind users of separate `rustc` lint groups
Michael Edwards [Thu, 9 Dec 2021 11:39:17 +0000 (12:39 +0100)]
Remind users of separate `rustc` lint groups

2 years agoFix `blocks_in_if_conditions` false positive
Caio [Wed, 8 Dec 2021 23:02:28 +0000 (20:02 -0300)]
Fix `blocks_in_if_conditions` false positive

2 years agoRemove and ignore lintcheck's log file
xFrednet [Sun, 28 Nov 2021 20:57:32 +0000 (21:57 +0100)]
Remove and ignore lintcheck's log file

2 years agoAuto merge of #8071 - GuillaumeGomez:method-must-use, r=xFrednet
bors [Wed, 8 Dec 2021 19:09:25 +0000 (19:09 +0000)]
Auto merge of #8071 - GuillaumeGomez:method-must-use, r=xFrednet

Add new lint to warn when #[must_use] attribute should be used on a method

This lint is somewhat similar to https://rust-lang.github.io/rust-clippy/master/index.html#must_use_candidate but also different: it emits a warning by default and only targets methods (so not functions nor associated functions).

Someone suggested it to me after this tweet: https://twitter.com/m_ou_se/status/1466439813230477312

I think it would reduce the number of cases of API misuses quite a lot.

What do you think?

---

changelog: Added new [`return_self_not_must_use`] lint

2 years agoAuto merge of #8030 - WaffleLapkin:ignore_trait_assoc_types_type_complexity, r=llogiq
bors [Wed, 8 Dec 2021 11:54:03 +0000 (11:54 +0000)]
Auto merge of #8030 - WaffleLapkin:ignore_trait_assoc_types_type_complexity, r=llogiq

Ignore associated types in traits when considering type complexity

changelog: Ignore associated types in traits when checking ``[`type_complexity`]`` lint.

fixes #1013

2 years agoIgnore associated items in trait *implementations* when considering type complexity
Maybe Waffle [Wed, 8 Dec 2021 11:27:49 +0000 (14:27 +0300)]
Ignore associated items in trait *implementations* when considering type complexity

2 years agoApply new lint on clippy source code
Guillaume Gomez [Fri, 3 Dec 2021 17:00:41 +0000 (18:00 +0100)]
Apply new lint on clippy source code

2 years agoUpdate other UI tests as well
Guillaume Gomez [Fri, 3 Dec 2021 16:51:55 +0000 (17:51 +0100)]
Update other UI tests as well

2 years agoAdd new lint to warn when #[must_use] attribute should be used on a method
Guillaume Gomez [Fri, 3 Dec 2021 15:35:04 +0000 (16:35 +0100)]
Add new lint to warn when #[must_use] attribute should be used on a method

2 years agoAuto merge of #8086 - dswij:7991, r=giraffate
bors [Tue, 7 Dec 2021 23:45:58 +0000 (23:45 +0000)]
Auto merge of #8086 - dswij:7991, r=giraffate

Fix bad suggestion on `option_if_let_else` when there is complex subpat

closes #7991

Prefer not warning any complex subpat in `option_if_let_else` rather than suggesting obscure suggestions.

changelog: [`option_if_let_else`] does not warn when complex subpat is present

2 years agoAuto merge of #8075 - Qwaz:non_send_fields_documentation, r=xFrednet
bors [Tue, 7 Dec 2021 22:14:10 +0000 (22:14 +0000)]
Auto merge of #8075 - Qwaz:non_send_fields_documentation, r=xFrednet

Clarify the purpose of the non_send lint

PR 2/2 for issue #8045. Tried to tone down the warning message and clarify the intention of the lint. Specifically, I added a description that this lint tries to detect "types that are not safe to be sent to another thread".

changelog: none

r? `@xFrednet`

2 years agoMove `non_send_fields_in_send_ty` back to `nursery`
Yechan Bae [Tue, 7 Dec 2021 15:45:59 +0000 (10:45 -0500)]
Move `non_send_fields_in_send_ty` back to `nursery`

2 years agoFix grammar issues
Yechan Bae [Tue, 7 Dec 2021 15:02:58 +0000 (10:02 -0500)]
Fix grammar issues

2 years agoClarify the purpose of the lint
Yechan Bae [Sat, 4 Dec 2021 01:28:14 +0000 (20:28 -0500)]
Clarify the purpose of the lint

2 years ago`option_if_let_else` Do not warn when complex subpat is present
dswij [Tue, 7 Dec 2021 07:34:44 +0000 (15:34 +0800)]
`option_if_let_else` Do not warn when complex subpat is present

2 years agoAuto merge of #8085 - jqnatividad:8084-needless_lifetimes_typo, r=giraffate
bors [Tue, 7 Dec 2021 00:45:59 +0000 (00:45 +0000)]
Auto merge of #8085 - jqnatividad:8084-needless_lifetimes_typo, r=giraffate

`needless_lifetimes` Known problems typo

fixes #8084

[needless_lifetimes]

changelog: none

2 years ago`needless_lifetimes` Known problems typo
Joel Natividad [Tue, 7 Dec 2021 00:11:19 +0000 (19:11 -0500)]
`needless_lifetimes` Known problems typo

fixes #8084

2 years agoAuto merge of #8080 - dswij:8019, r=giraffate
bors [Tue, 7 Dec 2021 00:07:46 +0000 (00:07 +0000)]
Auto merge of #8080 - dswij:8019, r=giraffate

Fix FP on `question_mark` if returned object is not local

Closes #8019

changelog: [`question_mark`] Fix FP when returned object is not local

2 years agoAuto merge of #8042 - camsteffen:peel-blocks, r=xFrednet
bors [Mon, 6 Dec 2021 18:34:27 +0000 (18:34 +0000)]
Auto merge of #8042 - camsteffen:peel-blocks, r=xFrednet

Peel blocks and statements utils

changelog: none

* Rename `remove_blocks` to `peel_blocks`
* Add `peel_blocks_and_stmts`
* Various refactors to use the above utils
* The utils also now check `block.rules`

2 years agoSimplify needless_bool
Cameron Steffen [Thu, 25 Mar 2021 00:17:25 +0000 (19:17 -0500)]
Simplify needless_bool

2 years agoRefactors with peel_blocks
Cameron Steffen [Mon, 29 Nov 2021 14:34:36 +0000 (08:34 -0600)]
Refactors with peel_blocks

2 years agoRename remove_blocks to peel_blocks
Cameron Steffen [Thu, 1 Apr 2021 15:31:11 +0000 (10:31 -0500)]
Rename remove_blocks to peel_blocks

2 years agoAuto merge of #8066 - rust-lang:needless_bool_parenthesize, r=camsteffen
bors [Mon, 6 Dec 2021 15:15:26 +0000 (15:15 +0000)]
Auto merge of #8066 - rust-lang:needless_bool_parenthesize, r=camsteffen

Parenthesize blocks in `needless_bool` suggestion

Because the `if .. {}` statement already puts the condition in expression scope, contained blocks would be parsed as complete
statements, so any `&` binary expression whose left operand ended in a block would lead to a non-compiling suggestion.

We identify such expressions and add parentheses. Note that we don't make a difference between normal and unsafe blocks because the parsing problems are the same for both.

This fixes #8052.

---

changelog: none

2 years agoParenthesize blocks in `needless_bool` suggestion
Andre Bogus [Thu, 2 Dec 2021 21:47:57 +0000 (22:47 +0100)]
Parenthesize blocks in `needless_bool` suggestion

Because the `if .. {}` statement already puts the condition in
expression scope, contained blocks would be parsed as complete
statements, so any `&` binary expression whose left operand ended in a
block would lead to a non-compiling suggestion.

This adds a visitor to identify such expressions and add parentheses.

This fixes #8052.

2 years agoMerge commit 'a5d597637dcb78dc73f93561ce474f23d4177c35' into clippyup
flip1995 [Mon, 6 Dec 2021 11:33:31 +0000 (12:33 +0100)]
Merge commit 'a5d597637dcb78dc73f93561ce474f23d4177c35' into clippyup

2 years agoFix FP on `question_mark` if returned object is not local
dswij [Mon, 6 Dec 2021 09:18:17 +0000 (17:18 +0800)]
Fix FP on `question_mark` if returned object is not local

2 years agoAuto merge of #8077 - nixxquality:single_char_pattern-false-negatives, r=camsteffen
bors [Mon, 6 Dec 2021 05:12:12 +0000 (05:12 +0000)]
Auto merge of #8077 - nixxquality:single_char_pattern-false-negatives, r=camsteffen

Fix some false negatives for [`single_char_pattern`]

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

changelog: Fix some false negatives for [`single_char_pattern`]

I noticed that clippy wasn't complaining about my usage of `split_once("x")` in a personal project so I updated the list of functions.

I had to update the test case for an unrelated issue because replace is now included in the list of functions to be linted.

2 years agoFix dogfood
nixx quality [Sun, 5 Dec 2021 20:50:05 +0000 (21:50 +0100)]
Fix dogfood

2 years agoAuto merge of #8072 - xFrednet:0000-teach-rustbot-acronyms, r=llogiq
bors [Sun, 5 Dec 2021 17:33:25 +0000 (17:33 +0000)]
Auto merge of #8072 - xFrednet:0000-teach-rustbot-acronyms, r=llogiq

Enable rustbot shortcuts for rust-clippy

This enables shortcuts for ``@rustbot`.` Just a quality of life feature for contributors.

|Shortcut| Full comment |
|---|---|
| ``@rustbot` ready` | ``@rustbot` label -S-waiting-on-author +S-waiting-on-review` |
| ``@rustbot` author` | ``@rustbot` label +S-waiting-on-author -S-waiting-on-review` |

See: https://github.com/rust-lang/triagebot/wiki/Shortcuts

The documentation also states that the author/assignee will be pinged. However, this doesn't seem to be the case, it at least hasn't done so for me and in this [PR](https://github.com/rust-lang/rust/pull/90642#issuecomment-962465404)

---

changelog: none

2 years agofix some false negatives for single_char_pattern
nixx quality [Sun, 5 Dec 2021 16:33:52 +0000 (17:33 +0100)]
fix some false negatives for single_char_pattern

2 years agoUse IntoIterator for array impl everywhere.
Mara Bos [Fri, 3 Sep 2021 10:36:33 +0000 (12:36 +0200)]
Use IntoIterator for array impl everywhere.

2 years agoAuto merge of #8074 - Qwaz:send_nonnull, r=xFrednet
bors [Sat, 4 Dec 2021 17:19:07 +0000 (17:19 +0000)]
Auto merge of #8074 - Qwaz:send_nonnull, r=xFrednet

Consider NonNull as a pointer type

PR 1/2 for issue #8045. Add `NonNull` as a pointer class to suppress false positives like `UnsafeCell<NonNull<()>>`. However, this change is not sufficient to handle the cases shared in gtk-rs and Rug in the issue.

changelog: none

r? `@xFrednet`

2 years agoAuto merge of #8054 - camsteffen:map-flatten-style, r=giraffate
bors [Sat, 4 Dec 2021 13:30:09 +0000 (13:30 +0000)]
Auto merge of #8054 - camsteffen:map-flatten-style, r=giraffate

Upgrade map_flatten to complexity

changelog: upgrade [`map_flatten`] to complexity

Resolves #7999