Closed
Description
Summary
Following the suggestion of match_single_binding
would put two semicolons after a statement.
This is wrong-ish (it would cause rustc to emit "warning: unnecessary trailing semicolon").
Reproducer
I tried clippy_driver
on this code:
fn _f(r: Option<u32>) {
let _t = match r {
x => {
match x {
Some(_) => { println!("Some"); },
None => { println!("None"); }
}
},
};
}
fn main(){}
I got:
warning: this let-binding has unit value
--> ulm.rs:2:5
|
2 | / let _t = match r {
3 | | x => {
4 | | match x {
5 | | Some(_) => { println!("Some"); },
... |
8 | | },
9 | | };
| |______^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value
= note: `#[warn(clippy::let_unit_value)]` on by default
help: omit the `let` binding
|
2 ~ match r {
3 + x => {
4 + match x {
5 + Some(_) => { println!("Some"); },
6 + None => { println!("None"); }
7 + }
8 + },
9 + };
|
warning: this match could be written as a `let` statement
--> ulm.rs:2:5
|
2 | / let _t = match r {
3 | | x => {
4 | | match x {
5 | | Some(_) => { println!("Some"); },
... |
8 | | },
9 | | };
| |______^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_single_binding
= note: `#[warn(clippy::match_single_binding)]` on by default
help: consider using a `let` statement
|
2 ~ let x = r;
3 + let _t = match x {
4 + Some(_) => { println!("Some"); },
5 + None => { println!("None"); }
6 + };;
|
warning: 2 warnings emitted
In the final suggestion, the final semicolon should be removed.
Version
rustc 1.66.0-nightly (bed4ad65b 2022-10-25)
binary: rustc
commit-hash: bed4ad65bf7a1cef39e3d66b3670189581b3b073
commit-date: 2022-10-25
host: x86_64-apple-darwin
release: 1.66.0-nightly
LLVM version: 15.0.2
Additional Labels
No response