Commit Graph

13147 Commits

Author SHA1 Message Date
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
ThibsG
a8e7fed172 Add a note about type annotation on closure param 2021-11-28 10:22:15 +01:00
ThibsG
917fdb11e4 Rewrite comment when handling special case for ProjectionKind::Deref 2021-11-27 20:32:50 +01:00
ThibsG
c5ce7ff6d9 Add Index when checking projs in a call, rename some variables and remove unneeded statements 2021-11-27 19:22:19 +01: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
Maybe Waffle
40a6c519b4 Update tests for type_complexity lint 2021-11-25 12:47:29 +03:00
Maybe Waffle
063f8aa094 Ignore associated types in traits when considering type complexity 2021-11-25 12:08:18 +03: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
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