Commit Graph

13015 Commits

Author SHA1 Message Date
bors
4027594533 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
2021-11-22 09:48:06 +00:00
bors
5fbfdfa319 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
2021-11-22 00:01:49 +00:00
bors
de2208a351 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
2021-11-21 23:48:24 +00:00
Cameron Steffen
8c1c763c2d clippy: Fix pattern_type_mismatch for loop 2021-11-21 08:16:20 -06:00
Cameron Steffen
e58ffb88e6 Fix Clippy with changed for loop desugar 2021-11-21 08:16:09 -06:00
surechen
846c0bef07 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
2021-11-21 14:28:44 +08:00
bors
32048ebea3 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`
2021-11-20 17:50:50 +00:00
Georg Brandl
0c4055c283 Avoid inline hints with double backticks for doc-markdown 2021-11-20 18:13:24 +01:00
ThibsG
092fe209a6 Move deref closure builder to clippy_utils::sugg module 2021-11-20 15:48:21 +01:00
xFrednet
1c8085d705
Allow suboptimal_flops in const functions 2021-11-20 15:39:29 +01:00
bors
827fd501d0 Auto merge of #8000 - Jarcho:nightly_fmt, r=llogiq
Don't check for a nightly toolchain in fmt test

changelog: None
2021-11-20 14:06:17 +00:00
Georg Brandl
982124acfa 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.
2021-11-20 11:57:25 +01:00
togami2864
ec7364f227 add test suit 2021-11-20 18:49:30 +09:00
ThibsG
5ebede0c14 Fix full projection identifier + move applicability to MaybeIncorrect 2021-11-20 09:40:11 +01:00
ThibsG
1176b8e5e9 Handle closures with type annotations on args 2021-11-20 09:40:11 +01:00
ThibsG
2ff702cbb5 Rephrase the fn checking for a double ref, not only one 2021-11-20 09:40:11 +01:00
ThibsG
7221999181 Add tests with closure 2021-11-20 09:40:11 +01:00
ThibsG
abaaf744fd Add some notes about MethodCall cases 2021-11-20 09:40:11 +01:00
ThibsG
268ef407a6 Add test case for references bindings 2021-11-20 09:40:11 +01:00
ThibsG
90a72f506c Handle args taken by ref also for MethodCall 2021-11-20 09:40:11 +01:00
ThibsG
7a55407cc3 Fix suggestions when call functions involved taking by ref 2021-11-20 09:40:11 +01:00
ThibsG
6d1ccbf466 Correct suggestion when dereferencing enough, calling a function 2021-11-20 09:40:11 +01:00
ThibsG
ac45a83ad5 Handle multiple reference levels into binding type and add more tests 2021-11-20 09:40:11 +01:00
ThibsG
788c9ccc93 Applying refactoring for simplified code 2021-11-20 09:40:11 +01:00
ThibsG
91dd9c46de Handle other projection kinds 2021-11-20 09:40:11 +01:00
ThibsG
97783a8cb9 Return a struct and add applicability 2021-11-20 09:40:11 +01:00
ThibsG
d0dd797709 Build end of suggestion only once at the end of the process 2021-11-20 09:40:11 +01:00
ThibsG
9ab4b673eb Simplifying next_pos init 2021-11-20 09:40:11 +01:00
ThibsG
e24aba2c1a Use applicability for snippets 2021-11-20 09:40:11 +01:00
ThibsG
6dca4f261d Add some doc for search_is_some lint 2021-11-20 09:40:11 +01:00
ThibsG
ddcbac37ae Split tests (too long for CI) 2021-11-20 09:40:10 +01:00
ThibsG
b38f173aa3 Build suggestion within visitor + add more tests 2021-11-20 09:40:10 +01:00
ThibsG
5ed93af9c4 Use ExprUseVisitor and multipart suggestion to avoid iffy String replacement 2021-11-20 09:40:10 +01:00
ThibsG
f4c75cde5e Fix any() not taking reference in search_is_some lint 2021-11-20 09:40:10 +01:00
Jason Newcomb
0d1f1cec44 Remove surrounding unsafe block in strlen_on_c_strings when possible 2021-11-19 21:14:51 -05:00
Jason Newcomb
c443f8fb95 Fix strlen_on_c_strings when not used with a full path 2021-11-19 20:02:49 -05:00
Jason Newcomb
1429949f9f Don't check for a nightly toolchain in fmt test 2021-11-19 19:43:31 -05:00
bors
38bd2514ad Auto merge of #7984 - phansch:disallowed-type-rename, r=xFrednet
Pluralize `disallowed_type` lint

This was brought up in [Zulip] and is also mentioned in the lint naming
conventions. Since this is still a nursery lint, I think there shouldn't
be any problem in renaming it.

[Zulip]: rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/disallow_type.20vs.20disallowed-types

changelog: Rename nursery lint [`disallowed_type`] to [`disallowed_types`].
2021-11-19 13:39:08 +00:00
bors
0d283cc44c Auto merge of #7996 - togami2864:test-map-or-none, r=Manishearth
Add test case for RESULT_MAP_OR_INTO_OPTION

just added test case for RESULT_MAP_OR_INTO_OPTION.
changelog: none
2021-11-19 07:47:39 +00:00
togami2864
cd81bb9dc3 fix stderr 2021-11-19 16:17:17 +09:00
togami2864
abb7155387 add test case for result_map_or_into_option 2021-11-19 16:12:46 +09:00
bors
2776076efa Auto merge of #7977 - Jarcho:multi_needless_borrow, r=xFrednet
Improve `needless_borrow` lint

fixes: #5327
fixes: #1726
fixes: #1212

This is merging `needless_borrow` into the `dereference` pass in preparation for `explicit_auto_deref`. `explicit_auto_deref` needs to implement most of what `needless_borrow` implements in order to work.

There is a minor regression here where `let x: &str = &x.deref()` will trigger `needless_borrow` without triggering `explicit_deref_methods`. Removing the redundant borrow will cause `explicit_deref_methods` to trigger. This will be fixed when `explicit_auto_deref` is implemented.

changelog: Lint `needless_borrow` when a borrow is auto-derefed more than once
changelog: Lint `needless_borrow` in the trailing expression of a block for a match arm
2021-11-18 23:35:03 +00:00
Andrew Dona-Couch
0375d20e3f Add missing components to rust-toolchain file 2021-11-18 16:57:07 -05:00
flip1995
9b38fb7b71
Also pluralize disallowed_method(s) lint
To stay consistent with the sister lint disallowed_type, also rename the
disallowed_method lint to disallowed_methods.
2021-11-18 17:37:06 +01:00
Philipp Hansch
a0d81d1327
Pluralize disallowed_type lint filenames
This way they match up with the pluralized lint name as well.
2021-11-18 17:37:06 +01:00
Philipp Hansch
b7f18916fa
Pluralize disallowed_type lint
This was brought up in [Zulip] and is also mentioned in the lint naming
conventions. Since this is still a nursery lint, I think there shouldn't
be any problem in renaming it.

[Zulip]: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/disallow_type.20vs.20disallowed-types
2021-11-18 17:37:02 +01:00
bors
8dd1bce263 Auto merge of #7994 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2021-11-18 11:31:49 +00:00
flip1995
4bccd59a69
Bump nightly version -> 2021-11-18 2021-11-18 12:22:22 +01:00
flip1995
731dfde267
Merge remote-tracking branch 'upstream/master' into rustup 2021-11-18 12:22:00 +01:00
bors
8536647e61 Auto merge of #7992 - togami2864:fix-typo, r=giraffate
fix typo

just fixed typo

changelog: none
2021-11-18 08:46:52 +00:00