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):
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"
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.
[..]/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:
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
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".
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`
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.
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.
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)
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.
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:
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`]``
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).
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).
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).
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
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.
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
};
```
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"`.
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
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`