New lint: unnecessary_semicolon

This commit is contained in:
Samuel Tardieu 2024-09-18 14:25:33 +02:00
parent e692cd4b30
commit 51b0107d28
7 changed files with 148 additions and 0 deletions

View file

@ -0,0 +1,32 @@
#![warn(clippy::unnecessary_semicolon)]
#![feature(postfix_match)]
fn no_lint(mut x: u32) -> Option<u32> {
Some(())?;
{
let y = 3;
dbg!(x + y)
};
{
let (mut a, mut b) = (10, 20);
(a, b) = (b + 1, a + 1);
}
Some(0)
}
fn main() {
let mut a = 3;
if a == 2 {
println!("This is weird");
}
//~^ ERROR: unnecessary semicolon
a.match {
3 => println!("three"),
_ => println!("not three"),
}
//~^ ERROR: unnecessary semicolon
}

View file

@ -0,0 +1,32 @@
#![warn(clippy::unnecessary_semicolon)]
#![feature(postfix_match)]
fn no_lint(mut x: u32) -> Option<u32> {
Some(())?;
{
let y = 3;
dbg!(x + y)
};
{
let (mut a, mut b) = (10, 20);
(a, b) = (b + 1, a + 1);
}
Some(0)
}
fn main() {
let mut a = 3;
if a == 2 {
println!("This is weird");
};
//~^ ERROR: unnecessary semicolon
a.match {
3 => println!("three"),
_ => println!("not three"),
};
//~^ ERROR: unnecessary semicolon
}

View file

@ -0,0 +1,17 @@
error: unnecessary semicolon
--> tests/ui/unnecessary_semicolon.rs:24:6
|
LL | };
| ^ help: remove
|
= note: `-D clippy::unnecessary-semicolon` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::unnecessary_semicolon)]`
error: unnecessary semicolon
--> tests/ui/unnecessary_semicolon.rs:30:6
|
LL | };
| ^ help: remove
error: aborting due to 2 previous errors