Commit graph

12879 commits

Author SHA1 Message Date
bors
392b0c5c25 Auto merge of #8057 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2021-12-02 09:36:28 +00:00
flip1995
ec57cc1455
Bump Clippy Version -> 0.1.59 2021-12-02 09:32:47 +00:00
flip1995
782b1a846e
Bump nightly version -> 2021-12-02 2021-12-02 09:32:38 +00:00
flip1995
abddd6c491
Merge remote-tracking branch 'upstream/master' into rustup 2021-12-02 09:32:09 +00:00
bors
8ad56c8fb7 Auto merge of #8049 - surechen:fixes_7946, r=flip1995
Add test for pattern_type_mismatch.

This issue has been fixed by [commit](8c1c763c2d)
This PR is used for close #7946(Fixes #7946).

changelog: Add test for pattern_type_mismatch.
2021-12-01 09:58:54 +00:00
bors
ecf931f5ac Auto merge of #7993 - homersimpsons:patch-1, r=flip1995
`no_std_swap`: Fix typo in TODO

changelog: none
2021-12-01 09:44:24 +00:00
homersimpsons
522f3f901f
no_std_swap: Remove obsolete TODO from test 2021-12-01 09:43:35 +00:00
surechen
bd63686e0f Add test for pattern_type_mismatch.
This issue has been fixed by [commit](8c1c763c2d)
This PR is used for close #7946(Fixes #7946).

changelog: Add test for pattern_type_mismatch.
2021-12-01 17:37:50 +08:00
bors
abaffa7217 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
2021-11-30 17:20:46 +00:00
flip1995
11002c7f77
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.
2021-11-30 17:19:48 +00:00
bors
908815ce98 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
2021-11-29 01:03:48 +00:00
bors
4e84dd121f 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()`
2021-11-28 20:59:20 +00:00
Camille GILLOT
56533d9e87 Take a LocalDefId in expect_*item. 2021-11-28 21:09:45 +01:00
togami2864
f51bbc7db9 apply iter_cloned_collect to copied() 2021-11-28 23:59:31 +09:00
Aaron Hill
3c8b644d0d 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.
2021-11-27 11:33:55 -06:00
bors
3720735f9a 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`]
2021-11-27 14:24:02 +00:00
Alex Macleod
d346ec94fe Add async/const fn tests for needless-late-init
+nits
2021-11-26 14:27:53 +00:00
bors
5a6169d7f6 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`
2021-11-26 11:03:54 +00:00
togami2864
cd8b72443d fix small nit 2021-11-26 19:27:14 +09:00
bors
6b997b6576 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.
2021-11-26 09:55:06 +00:00
togami2864
e6a6ed44b2 fix doc 2021-11-26 18:52:27 +09:00
togami2864
e8ef6ca5e3 fix stderr 2021-11-26 18:49:14 +09:00
togami2864
a745cc55f3 make non_ascii_literal to catch char 2021-11-26 18:42:41 +09:00
togami2864
140ba610e4 add test suit 2021-11-26 18:34:07 +09:00
Aaron Hill
9274ec5691 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.
2021-11-25 15:33:37 -06:00
Esteban Kuber
5fc61a24c4 Fix clippy test 2021-11-25 18:39:32 +00:00
bors
35b0f2438d 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
2021-11-25 08:10:55 +00:00
Dharma Saputra Wijaya
c0bad8bcab Add more descriptive help info for needless_question_mark 2021-11-25 14:01:14 +08:00
Jason Newcomb
a135347f5d Run rustfix for strlen_on_c_strings tests 2021-11-24 20:16:27 -05:00
Alex Macleod
3957244120 Add needless_late_init lint 2021-11-23 15:08:49 +00:00
bors
81f37a8150 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
2021-11-23 10:27:12 +00:00
flip1995
c46c8c58e9
Bump nightly version -> 2021-11-23 2021-11-23 11:22:49 +01:00
flip1995
5740230ec7
Merge remote-tracking branch 'upstream/master' into rustup 2021-11-23 11:22:34 +01:00
bors
d6c707db53 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
2021-11-23 08:20:57 +00:00
dswij
ec3d1c8ca3 Fix FP on if_then_some_else_none when there is early return 2021-11-23 10:11:30 +08:00
bors
57a8804ef9 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"`.
2021-11-22 20:29:53 +00:00
Georg Brandl
1210bb40d3 octal_escapes: note on print!() format strings 2021-11-22 21:02:03 +01:00
Georg Brandl
0bc25d04c6 octal_escapes: emit only one lint for all cases found each literal 2021-11-22 21:00:19 +01:00
Georg Brandl
850e7f533e octal_escapes: updates from review, fix byte string prefix 2021-11-22 18:02:17 +01:00
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
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