forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#113417 - flip1995:clippy_beta_backport, r=Man…
…ishearth [beta] Clippy beta backport Backported PRs: - rust-lang/rust-clippy#10813 - rust-lang/rust-clippy#10865 - rust-lang/rust-clippy#10873 - rust-lang/rust-clippy#10992 Those address bugs, that were either introduced with 1.71 and that we would like to address before they get into stable or bugs that were introduced in 1.70 and that we would like to be fixed in 1.71 already. Detailed arguments for the backports of those PRs are in the PRs (mostly). r? `@Mark-Simulacrum`
- Loading branch information
Showing
15 changed files
with
164 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,42 @@ | ||
//@aux-build: proc_macros.rs | ||
#![allow(unused)] | ||
#![warn(clippy::let_with_type_underscore)] | ||
#![allow(clippy::let_unit_value)] | ||
#![allow(clippy::let_unit_value, clippy::needless_late_init)] | ||
|
||
extern crate proc_macros; | ||
|
||
fn func() -> &'static str { | ||
"" | ||
} | ||
|
||
#[rustfmt::skip] | ||
fn main() { | ||
// Will lint | ||
let x: _ = 1; | ||
let _: _ = 2; | ||
let x: _ = func(); | ||
let x: _; | ||
x = (); | ||
|
||
let x = 1; // Will not lint, Rust infers this to an integer before Clippy | ||
let x = func(); | ||
let x: Vec<_> = Vec::<u32>::new(); | ||
let x: [_; 1] = [1]; | ||
let x : _ = 1; | ||
|
||
// Do not lint from procedural macros | ||
proc_macros::with_span! { | ||
span | ||
let x: _ = (); | ||
// Late initialization | ||
let x: _; | ||
x = (); | ||
// Ensure weird formatting will not break it (hopefully) | ||
let x : _ = 1; | ||
let x | ||
: _ = 1; | ||
let x : | ||
_; | ||
x = (); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,63 @@ | ||
error: variable declared with type underscore | ||
--> $DIR/let_with_type_underscore.rs:11:5 | ||
--> $DIR/let_with_type_underscore.rs:15:5 | ||
| | ||
LL | let x: _ = 1; | ||
| ^^^^^^^^^^^^^ | ||
| | ||
help: remove the explicit type `_` declaration | ||
--> $DIR/let_with_type_underscore.rs:11:10 | ||
--> $DIR/let_with_type_underscore.rs:15:10 | ||
| | ||
LL | let x: _ = 1; | ||
| ^^^ | ||
= note: `-D clippy::let-with-type-underscore` implied by `-D warnings` | ||
|
||
error: variable declared with type underscore | ||
--> $DIR/let_with_type_underscore.rs:12:5 | ||
--> $DIR/let_with_type_underscore.rs:16:5 | ||
| | ||
LL | let _: _ = 2; | ||
| ^^^^^^^^^^^^^ | ||
| | ||
help: remove the explicit type `_` declaration | ||
--> $DIR/let_with_type_underscore.rs:12:10 | ||
--> $DIR/let_with_type_underscore.rs:16:10 | ||
| | ||
LL | let _: _ = 2; | ||
| ^^^ | ||
|
||
error: variable declared with type underscore | ||
--> $DIR/let_with_type_underscore.rs:13:5 | ||
--> $DIR/let_with_type_underscore.rs:17:5 | ||
| | ||
LL | let x: _ = func(); | ||
| ^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: remove the explicit type `_` declaration | ||
--> $DIR/let_with_type_underscore.rs:13:10 | ||
--> $DIR/let_with_type_underscore.rs:17:10 | ||
| | ||
LL | let x: _ = func(); | ||
| ^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
error: variable declared with type underscore | ||
--> $DIR/let_with_type_underscore.rs:18:5 | ||
| | ||
LL | let x: _; | ||
| ^^^^^^^^^ | ||
| | ||
help: remove the explicit type `_` declaration | ||
--> $DIR/let_with_type_underscore.rs:18:10 | ||
| | ||
LL | let x: _; | ||
| ^^^ | ||
|
||
error: variable declared with type underscore | ||
--> $DIR/let_with_type_underscore.rs:25:5 | ||
| | ||
LL | let x : _ = 1; | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
help: remove the explicit type `_` declaration | ||
--> $DIR/let_with_type_underscore.rs:25:10 | ||
| | ||
LL | let x : _ = 1; | ||
| ^^^^ | ||
|
||
error: aborting due to 5 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.