-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Description
Using the following flags
--force-warn clippy::match_single_binding
this code:
fn r#match() {
let val: () = match match match match match () {
() => ()
} {
() => ()
} {
() => ()
} {
() => ()
} {
() => ()
};
assert_eq!(val, ());
}
caused the following diagnostics:
Checking _a v0.1.0 (/tmp/icemaker_global_tempdir.DAwWpheccItk/icemaker_clippyfix_tempdir.zY2bBPDwHH24/_a)
warning: this match could be written as a `let` statement
--> src/lib.rs:2:5
|
2 | / let val: () = match match match match match () {
3 | | () => ()
4 | | } {
5 | | () => ()
... |
11 | | () => ()
12 | | };
| |______^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_single_binding
= note: requested on the command line with `--force-warn clippy::match-single-binding`
help: consider using a `let` statement
|
2 ~ let () = match match match match () {
3 + () => ()
4 + } {
5 + () => ()
6 + } {
7 + () => ()
8 + } {
9 + () => ()
10 + };
11 + let val = ();
|
warning: this match could be written as a `let` statement
--> src/lib.rs:2:25
|
2 | let val: () = match match match match match () {
| _________________________^
3 | | () => ()
4 | | } {
5 | | () => ()
... |
9 | | () => ()
10 | | } {
| |_____^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_single_binding
help: consider using a `let` statement
|
2 ~ let val: () = match let () = match match match () {
3 + () => ()
4 + } {
5 + () => ()
6 + } {
7 + () => ()
8 + };
9 ~ () {
|
warning: this match could be written as a `let` statement
--> src/lib.rs:2:31
|
2 | let val: () = match match match match match () {
| _______________________________^
3 | | () => ()
4 | | } {
5 | | () => ()
6 | | } {
7 | | () => ()
8 | | } {
| |_____^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_single_binding
help: consider using a `let` statement
|
2 ~ let val: () = match match let () = match match () {
3 + () => ()
4 + } {
5 + () => ()
6 + };
7 ~ () {
|
warning: this match could be written as a `let` statement
--> src/lib.rs:2:37
|
2 | let val: () = match match match match match () {
| _____________________________________^
3 | | () => ()
4 | | } {
5 | | () => ()
6 | | } {
| |_____^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_single_binding
help: consider using a `let` statement
|
2 ~ let val: () = match match match let () = match () {
3 + () => ()
4 + };
5 ~ () {
|
warning: this match could be written as a `let` statement
--> src/lib.rs:2:43
|
2 | let val: () = match match match match match () {
| ___________________________________________^
3 | | () => ()
4 | | } {
| |_____^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_single_binding
help: consider using a `let` statement
|
2 ~ let val: () = match match match match let () = ();
3 ~ () {
|
warning: `_a` (lib) generated 5 warnings
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.12s
However after applying these diagnostics, the resulting code:
fn r#match() {
let val: () = match match let () = ();
() {
() => ()
} {
() => ()
} {
() => ()
} {
() => ()
};
assert_eq!(val, ());
}
no longer compiled:
Checking _a v0.1.0 (/tmp/icemaker_global_tempdir.DAwWpheccItk/icemaker_clippyfix_tempdir.zY2bBPDwHH24/_a)
warning: failed to automatically apply fixes suggested by rustc to crate `_a`
after fixes were automatically applied the compiler reported errors within these files:
* src/lib.rs
This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust-clippy/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag
The following errors were reported:
error: expected expression, found `let` statement
--> src/lib.rs:2:28
|
2 | let val: () = match let () = ();
| ^^^
|
= note: only supported directly in conditions of `if` and `while` expressions
error: expected one of `.`, `?`, `{`, or an operator, found `;`
--> src/lib.rs:2:39
|
2 | let val: () = match let () = ();
| ----- ^ expected one of `.`, `?`, `{`, or an operator
| |
| while parsing this `match` expression
| help: try removing this `match`
error: aborting due to 2 previous errors
Original diagnostics will follow.
error: expected expression, found `let` statement
--> src/lib.rs:2:33
|
2 | let val: () = match match let () = ();
| ^^^
|
= note: only supported directly in conditions of `if` and `while` expressions
error: expected one of `.`, `?`, `{`, or an operator, found `;`
--> src/lib.rs:2:44
|
2 | let val: () = match match let () = ();
| ----- ----- ^ expected one of `.`, `?`, `{`, or an operator
| | |
| | while parsing this `match` expression
| | help: try removing this `match`
| while parsing this `match` expression
error: could not compile `_a` (lib test) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
warning: failed to automatically apply fixes suggested by rustc to crate `_a`
after fixes were automatically applied the compiler reported errors within these files:
* src/lib.rs
This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust-clippy/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag
The following errors were reported:
error: expected expression, found `let` statement
--> src/lib.rs:2:23
|
2 | let val: () = let () = ();
| ^^^
|
= note: only supported directly in conditions of `if` and `while` expressions
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `{`
--> src/lib.rs:3:8
|
3 | () {
| ^ expected one of `.`, `;`, `?`, `}`, or an operator
error: aborting due to 2 previous errors
Original diagnostics will follow.
error: expected expression, found `let` statement
--> src/lib.rs:2:28
|
2 | let val: () = match let () = ();
| ^^^
|
= note: only supported directly in conditions of `if` and `while` expressions
error: expected one of `.`, `?`, `{`, or an operator, found `;`
--> src/lib.rs:2:39
|
2 | let val: () = match let () = ();
| ----- ^ expected one of `.`, `?`, `{`, or an operator
| |
| while parsing this `match` expression
| help: try removing this `match`
error: could not compile `_a` (lib) due to 2 previous errors
Version:
rustc 1.90.0-nightly (d41e12f1f 2025-06-27)
binary: rustc
commit-hash: d41e12f1f4e4884c356f319b881921aa37040de5
commit-date: 2025-06-27
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.7
Metadata
Metadata
Assignees
Labels
No labels