]> git.lizzy.rs Git - rust.git/log
rust.git
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 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 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

2 years agoConsider NonNull as a pointer type
Yechan Bae [Sat, 4 Dec 2021 00:11:40 +0000 (19:11 -0500)]
Consider NonNull as a pointer type

2 years agoAuto merge of #8040 - xFrednet:6610-known-problems-section-for-pre-expansion, r=camst...
bors [Fri, 3 Dec 2021 19:31:33 +0000 (19:31 +0000)]
Auto merge of #8040 - xFrednet:6610-known-problems-section-for-pre-expansion, r=camsteffen

Updated known problems section for pre-expansion lints about level attributes

Our last three pre-macro expansion lints aren't affected by lint level attributes. This adds a comment to the know problems section of them. I've also updated some CSS to add some spacing after lists on Clippy's lint list:

Before:

![image](https://user-images.githubusercontent.com/17087237/143783579-064326d4-4e58-4d7d-bbe4-fad8b115fcd4.png)

After:

![image](https://user-images.githubusercontent.com/17087237/143783650-9803fa03-c332-4e0e-886f-523d4217c6e6.png)

---

changelog: [`print_stdout`], [`print_stderr`], [`dbg_macro`]: Document how the lint level can be changed and reference rust-lang/rust-clippy#6610

cc: rust-lang/rust-clippy#6610

2 years agoAdd margin after lists on Clippy's lint list
xFrednet [Fri, 3 Dec 2021 18:53:15 +0000 (19:53 +0100)]
Add margin after lists on Clippy's lint list

2 years agoUpgrade map_flatten to complexity
Cameron Steffen [Wed, 1 Dec 2021 14:38:54 +0000 (08:38 -0600)]
Upgrade map_flatten to complexity

2 years agoAdd note about crate lint level attributes to pre-expansion lints
xFrednet [Fri, 3 Dec 2021 18:29:57 +0000 (19:29 +0100)]
Add note about crate lint level attributes to pre-expansion lints

2 years agoEnable rustbot shortcuts for rust-clippy
xFrednet [Fri, 3 Dec 2021 18:10:14 +0000 (19:10 +0100)]
Enable rustbot shortcuts for rust-clippy

2 years agoAuto merge of #8061 - vallentin:fix-same-name-method-desc, r=flip1995
bors [Fri, 3 Dec 2021 00:37:52 +0000 (00:37 +0000)]
Auto merge of #8061 - vallentin:fix-same-name-method-desc, r=flip1995

Fixed same_name_method description

Noticed some odd phrasing, while checking out the new release.

changelog: none

2 years agoAuto merge of #8067 - frobiac:8060-backslash_escaped_in_single_char_pattern, r=giraffate
bors [Fri, 3 Dec 2021 00:23:59 +0000 (00:23 +0000)]
Auto merge of #8067 - frobiac:8060-backslash_escaped_in_single_char_pattern, r=giraffate

Escape backslash in single_char_pattern.rs

Escape backslash in single_char_pattern.

Previously, the proposed clippy fix for a single backslash in raw strings ```r"\"``` or ```r#"\"#``` was also only an unescaped, *single* ```'\'```:
```shell
warning: single-character string constant used as pattern
2 |     let s = r#"abc\xyz/"#.find(r"\");
  |                                ^^^^ help: try using a `char` instead: `'\'`
  |
  = note: `#[warn(clippy::single_char_pattern)]` on by default
```

This PR corrects this to a properly escaped *double* backslash ```'\\'```.
I haven't come up with any other problematic cases, a single quote was already handled.

Closes: #8060
changelog:  Escape backslash in ``[`single_char_pattern`]``

2 years agoEscape backslash for singe_char_pattern.rs
frobiac [Thu, 2 Dec 2021 22:47:23 +0000 (23:47 +0100)]
Escape backslash for singe_char_pattern.rs

2 years agoAuto merge of #7463 - ThibsG:find_any_7392, r=xFrednet
bors [Thu, 2 Dec 2021 17:27:54 +0000 (17:27 +0000)]
Auto merge of #7463 - ThibsG:find_any_7392, r=xFrednet

Fix `any()` not taking reference in `search_is_some` lint

`find` gives reference to the item, but `any` does not, so suggestion is broken in some specific cases.

Fixes: #7392
changelog: [`search_is_some`] Fix suggestion for `any()` not taking item by reference

2 years agoFixed same_name_method description
vallentin [Thu, 2 Dec 2021 17:07:28 +0000 (18:07 +0100)]
Fixed same_name_method description

2 years agoAuto merge of #8057 - flip1995:rustup, r=flip1995
bors [Thu, 2 Dec 2021 09:36:28 +0000 (09:36 +0000)]
Auto merge of #8057 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

2 years agoBump Clippy Version -> 0.1.59
flip1995 [Thu, 2 Dec 2021 09:32:47 +0000 (09:32 +0000)]
Bump Clippy Version -> 0.1.59

2 years agoBump nightly version -> 2021-12-02
flip1995 [Thu, 2 Dec 2021 09:32:38 +0000 (09:32 +0000)]
Bump nightly version -> 2021-12-02

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 2 Dec 2021 09:32:09 +0000 (09:32 +0000)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agoAuto merge of #8049 - surechen:fixes_7946, r=flip1995
bors [Wed, 1 Dec 2021 09:58:54 +0000 (09:58 +0000)]
Auto merge of #8049 - surechen:fixes_7946, r=flip1995

Add test for pattern_type_mismatch.

This issue has been fixed by [commit](https://github.com/rust-lang/rust-clippy/commit/8c1c763c2d5897c66f52bd5e7c16f48ae66c894c)
This PR is used for close #7946(Fixes #7946).

changelog: Add test for pattern_type_mismatch.

2 years agoAuto merge of #7993 - homersimpsons:patch-1, r=flip1995
bors [Wed, 1 Dec 2021 09:44:24 +0000 (09:44 +0000)]
Auto merge of #7993 - homersimpsons:patch-1, r=flip1995

`no_std_swap`: Fix typo in TODO

changelog: none

2 years ago`no_std_swap`: Remove obsolete TODO from test
homersimpsons [Thu, 18 Nov 2021 10:54:35 +0000 (11:54 +0100)]
`no_std_swap`: Remove obsolete TODO from test

2 years agoAdd test for pattern_type_mismatch.
surechen [Tue, 23 Nov 2021 14:04:13 +0000 (22:04 +0800)]
Add test for pattern_type_mismatch.
This issue has been fixed by [commit](https://github.com/rust-lang/rust-clippy/commit/8c1c763c2d5897c66f52bd5e7c16f48ae66c894c)
This PR is used for close #7946(Fixes #7946).

changelog: Add test for pattern_type_mismatch.

2 years agoAuto merge of #8032 - flip1995:new_templates, r=camsteffen
bors [Tue, 30 Nov 2021 17:20:46 +0000 (17:20 +0000)]
Auto merge of #8032 - flip1995:new_templates, r=camsteffen

Use new template forms for issue templates

GitHub has a new way to define issue templates. This gives an even more consistent formatting of our issues.

You can find (read-only) rendered versions [here](https://github.com/flip1995/rust-clippy/tree/new_templates/.github/ISSUE_TEMPLATE). If you want to try to fill out this kind of issue, you can do this in the [`cargo` Repo](https://github.com/rust-lang/cargo/issues/new/choose).

changelog: Better issue templates

2 years agoUse new template forms for issue templates
flip1995 [Thu, 25 Nov 2021 15:01:41 +0000 (16:01 +0100)]
Use new template forms for issue templates

GitHub has a new way to define issue templates. This gives an even more
consistent formatting of our issues.

2 years agoAuto merge of #8001 - Jarcho:unprefixed_strlen, r=giraffate
bors [Mon, 29 Nov 2021 01:03:48 +0000 (01:03 +0000)]
Auto merge of #8001 - Jarcho:unprefixed_strlen, r=giraffate

Improve `strlen_on_c_string`

fixes: #7436

changelog: lint `strlen_on_c_string` when used without a fully-qualified path
changelog: suggest removing the surrounding unsafe block for `strlen_on_c_string` when possible

2 years agoAuto merge of #8006 - togami2864:generalize-copied, r=camsteffen
bors [Sun, 28 Nov 2021 20:59:20 +0000 (20:59 +0000)]
Auto merge of #8006 - togami2864:generalize-copied, r=camsteffen

apply iter_cloned_collect to collect() using copied()

fix: #6703

changelog: apply `iter_cloned_collect` to `collect()` using`copied()`

2 years agoTake a LocalDefId in expect_*item.
Camille GILLOT [Wed, 20 Oct 2021 20:38:10 +0000 (22:38 +0200)]
Take a LocalDefId in expect_*item.

2 years agoapply iter_cloned_collect to copied()
togami2864 [Sat, 20 Nov 2021 09:53:15 +0000 (18:53 +0900)]
apply iter_cloned_collect to copied()

2 years agoAdd a note about type annotation on closure param
ThibsG [Sun, 28 Nov 2021 08:50:34 +0000 (09:50 +0100)]
Add a note about type annotation on closure param

2 years agoRewrite comment when handling special case for `ProjectionKind::Deref`
ThibsG [Sat, 27 Nov 2021 19:32:23 +0000 (20:32 +0100)]
Rewrite comment when handling special case for `ProjectionKind::Deref`

2 years agoAdd `Index` when checking projs in a call, rename some variables and remove unneeded...
ThibsG [Sat, 27 Nov 2021 18:22:19 +0000 (19:22 +0100)]
Add `Index` when checking projs in a call, rename some variables and remove unneeded statements

2 years agoOnly check for errors in predicate when skipping impl assembly
Aaron Hill [Fri, 26 Nov 2021 15:14:16 +0000 (09:14 -0600)]
Only check for errors in predicate when skipping impl assembly

Prior to PR #91205, checking for errors in the overall obligation
would check checking the `ParamEnv`, due to an incorrect
`super_visit_with` impl. With this bug fixed, we will now
bail out of impl candidate assembly if the `ParamEnv` contains
any error types.

In practice, this appears to be overly conservative - when an error
occurs early in compilation, we end up giving up early for some
predicates that we could have successfully evaluated without overflow.
By only checking for errors in the predicate itself, we avoid causing
additional spurious 'type annotations needed' errors after a 'real'
error has already occurred.

With this PR, the diagnostic changes caused by PR #91205 are reverted.

2 years agoAuto merge of #7995 - Alexendoo:needless_late_init, r=giraffate
bors [Sat, 27 Nov 2021 14:24:02 +0000 (14:24 +0000)]
Auto merge of #7995 - Alexendoo:needless_late_init, r=giraffate

Add `needless_late_init` lint

examples:

```rust
let a;
a = 1;
// to
let a = 1;
```
```rust
let b;
match 3 {
    0 => b = "zero",
    1 => b = "one",
    _ => b = "many",
}
// to
let b = match 3 {
    0 => "zero",
    1 => "one",
    _ => "many",
};
```
```rust
let c;
if true {
    c = 1;
} else {
    c = -1;
}
// to
let c = if true {
    1
} else {
    -1
};
```

changelog: Add [`needless_late_init`]

2 years agoAdd async/const fn tests for needless-late-init
Alex Macleod [Fri, 26 Nov 2021 14:16:48 +0000 (14:16 +0000)]
Add async/const fn tests for needless-late-init

+nits

2 years agoAuto merge of #8034 - togami2864:non-ascii-in-sigle-literal, r=llogiq
bors [Fri, 26 Nov 2021 11:03:54 +0000 (11:03 +0000)]
Auto merge of #8034 - togami2864:non-ascii-in-sigle-literal, r=llogiq

Non ascii in sigle literal

fix: #8013
changelog: `non_ascii_literal` warn against non-ASCII within `char`, not just `strings`

2 years agofix small nit
togami2864 [Fri, 26 Nov 2021 10:27:14 +0000 (19:27 +0900)]
fix small nit

2 years agoAuto merge of #91205 - Aaron1011:visit_param_env, r=lcnr
bors [Fri, 26 Nov 2021 09:55:06 +0000 (09:55 +0000)]
Auto merge of #91205 - Aaron1011:visit_param_env, r=lcnr

Visit `param_env` field in Obligation's `TypeFoldable` impl

This oversight appears to have gone unnoticed for a long time
without causing issues, but it should still be fixed.

2 years agofix doc
togami2864 [Fri, 26 Nov 2021 09:52:27 +0000 (18:52 +0900)]
fix doc

2 years agofix stderr
togami2864 [Fri, 26 Nov 2021 09:49:14 +0000 (18:49 +0900)]
fix stderr

2 years agomake non_ascii_literal to catch char
togami2864 [Fri, 26 Nov 2021 09:42:41 +0000 (18:42 +0900)]
make non_ascii_literal to catch char

2 years agoadd test suit
togami2864 [Fri, 26 Nov 2021 09:34:07 +0000 (18:34 +0900)]
add test suit

2 years agoVisit `param_env` field in Obligation's `TypeFoldable` impl
Aaron Hill [Wed, 24 Nov 2021 23:20:52 +0000 (17:20 -0600)]
Visit `param_env` field in Obligation's `TypeFoldable` impl

This oversight appears to have gone unnoticed for a long time
without causing issues, but it should still be fixed.

2 years agoFix clippy test
Esteban Kuber [Thu, 25 Nov 2021 18:39:32 +0000 (18:39 +0000)]
Fix clippy test

2 years agoUpdate tests for type_complexity lint
Maybe Waffle [Thu, 25 Nov 2021 09:47:29 +0000 (12:47 +0300)]
Update tests for type_complexity lint

2 years agoIgnore associated types in traits when considering type complexity
Maybe Waffle [Thu, 25 Nov 2021 08:50:57 +0000 (11:50 +0300)]
Ignore associated types in traits when considering type complexity

2 years agoAuto merge of #8028 - dswij:8016, r=flip1995
bors [Thu, 25 Nov 2021 08:10:55 +0000 (08:10 +0000)]
Auto merge of #8028 - dswij:8016, r=flip1995

Add more descriptive help info for `needless_question_mark`

closes #8016

changelog: [`needless_question_mark`] help suggestion now explains what should be changed

2 years agoAdd more descriptive help info for `needless_question_mark`
Dharma Saputra Wijaya [Thu, 25 Nov 2021 01:10:50 +0000 (09:10 +0800)]
Add more descriptive help info for `needless_question_mark`

2 years agoRun rustfix for `strlen_on_c_strings` tests
Jason Newcomb [Wed, 24 Nov 2021 21:06:13 +0000 (16:06 -0500)]
Run rustfix for `strlen_on_c_strings` tests

2 years agoAdd `needless_late_init` lint
Alex Macleod [Thu, 18 Nov 2021 13:54:49 +0000 (13:54 +0000)]
Add `needless_late_init` lint

2 years agoAuto merge of #8025 - flip1995:rustup, r=flip1995
bors [Tue, 23 Nov 2021 10:27:12 +0000 (10:27 +0000)]
Auto merge of #8025 - flip1995:rustup, r=flip1995

Rustup

Re-sync, because I didn't get to syncing things back to rustc.

r? `@ghost`

changelog: none

2 years agoBump nightly version -> 2021-11-23
flip1995 [Tue, 23 Nov 2021 10:22:49 +0000 (11:22 +0100)]
Bump nightly version -> 2021-11-23

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Tue, 23 Nov 2021 10:22:34 +0000 (11:22 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agoAuto merge of #7980 - dswij:7870, r=xFrednet
bors [Tue, 23 Nov 2021 08:20:57 +0000 (08:20 +0000)]
Auto merge of #7980 - dswij:7870, r=xFrednet

Fix FP on `if_then_some_else_none` when there is early return

closes #7870

changelog: [`if_then_some_else_none`] now does not fire when there is early return

2 years agoFix FP on `if_then_some_else_none` when there is early return
dswij [Tue, 16 Nov 2021 05:39:52 +0000 (13:39 +0800)]
Fix FP on `if_then_some_else_none` when there is early return

2 years agoAuto merge of #8007 - birkenfeld:octal_escapes, r=xFrednet
bors [Mon, 22 Nov 2021 20:29:53 +0000 (20:29 +0000)]
Auto merge of #8007 - birkenfeld:octal_escapes, r=xFrednet

Add new lint `octal_escapes`

This checks for sequences in strings that would be octal character
escapes in C, but are not supported in Rust.  It suggests either
to use the `\x00` escape, or an equivalent hex escape if the octal
was intended.

Fixes #7981

---

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

changelog: Add new lint [`octal_escapes`], which checks for literals like `"\033[0m"`.

2 years agooctal_escapes: note on print!() format strings
Georg Brandl [Mon, 22 Nov 2021 20:02:03 +0000 (21:02 +0100)]
octal_escapes: note on print!() format strings

2 years agooctal_escapes: emit only one lint for all cases found each literal
Georg Brandl [Mon, 22 Nov 2021 17:18:16 +0000 (18:18 +0100)]
octal_escapes: emit only one lint for all cases found each literal

2 years ago`octal_escapes`: updates from review, fix byte string prefix
Georg Brandl [Sun, 21 Nov 2021 15:06:19 +0000 (16:06 +0100)]
`octal_escapes`: updates from review, fix byte string prefix

2 years agoAuto merge of #7989 - couchand:2021-11/toolchain-missing-components, r=flip1995
bors [Mon, 22 Nov 2021 09:48:06 +0000 (09:48 +0000)]
Auto merge of #7989 - couchand:2021-11/toolchain-missing-components, r=flip1995

Add missing components to rust-toolchain file

Somehow these basic components are missing from the toolchain file...

changelog: none

2 years agoAuto merge of #8009 - xFrednet:8004-suboptimal-flops-in-const, r=giraffate
bors [Mon, 22 Nov 2021 00:01:49 +0000 (00:01 +0000)]
Auto merge of #8009 - xFrednet:8004-suboptimal-flops-in-const, r=giraffate

Allow `suboptimal_flops` in const functions

This PR allows `clippy::suboptimal_flops` in constant functions. The check also effects the `clippy::imprecise_flops` lint logic. However, this doesn't have any effects as all functions checked for are not const and can therefore not be found in such functions.

---

changelog: [`suboptimal_flops`]: No longer triggers in constant functions

Closes: rust-lang/rust-clippy#8004
2 years agoAuto merge of #7997 - surechen:Fixes_7915, r=giraffate
bors [Sun, 21 Nov 2021 23:48:24 +0000 (23:48 +0000)]
Auto merge of #7997 - surechen:Fixes_7915, r=giraffate

Fixes shadow_same's false positive for #7915

Fix shadow_same's false positive for async function's params(Fixes #7915):

Example Code:
```rust
#![deny(clippy::shadow_same)]

pub async fn foo(_a: i32) {
}
```
Output:
```
error: `_a` is shadowed by itself in `_a
```

Hir:
```rust
pub async fn foo(_a: i32)
 ->
     /*impl Trait*/ #[lang = "from_generator"](move |mut _task_context|
                                                   {
                                                       let _a = _a;
                                                       { let _t = { }; _t }
                                                   })
```

Skip checking async function's params.

changelog: Fix shadow_same's false positive for async function's params

2 years agoclippy: Fix pattern_type_mismatch for loop
Cameron Steffen [Fri, 19 Nov 2021 18:23:52 +0000 (12:23 -0600)]
clippy: Fix pattern_type_mismatch for loop

2 years agoFix Clippy with changed for loop desugar
Cameron Steffen [Wed, 27 Oct 2021 14:48:06 +0000 (09:48 -0500)]
Fix Clippy with changed for loop desugar

2 years agoFixes #7915
surechen [Fri, 19 Nov 2021 08:46:34 +0000 (16:46 +0800)]
Fixes #7915

Fix shadow_same's positive false for async function's params:

Example Code:
```rust
#![deny(clippy::shadow_same)]

pub async fn foo(_a: i32) {
}
```
Output:
```
error: `_a` is shadowed by itself in `_a
```

Hir:
```rust
pub async fn foo(_a: i32)
 ->
     /*impl Trait*/ #[lang = "from_generator"](move |mut _task_context|
                                                   {
                                                       let _a = _a;
                                                       { let _t = { }; _t }
                                                   })
```

Skip checking async function's params.

changelog: Fix shadow_same's positive false for async function's params

2 years agoAuto merge of #8011 - birkenfeld:double_backticks, r=xFrednet
bors [Sat, 20 Nov 2021 17:50:50 +0000 (17:50 +0000)]
Auto merge of #8011 - birkenfeld:double_backticks, r=xFrednet

Avoid inline hints with double backticks for `doc-markdown`

The easiest route here was to ensure that the suggestion is always shown on
its own line, where no additional backticks are added by the diagnostic formatter.

Fixes #8002

---

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

changelog: Avoid inline hints with double backticks for `doc-markdown`

2 years agoAvoid inline hints with double backticks for `doc-markdown`
Georg Brandl [Sat, 20 Nov 2021 17:13:24 +0000 (18:13 +0100)]
Avoid inline hints with double backticks for `doc-markdown`