New lint: unnecessary_semicolon
This commit is contained in:
parent
e692cd4b30
commit
51b0107d28
7 changed files with 148 additions and 0 deletions
32
tests/ui/unnecessary_semicolon.fixed
Normal file
32
tests/ui/unnecessary_semicolon.fixed
Normal 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
|
||||
}
|
||||
32
tests/ui/unnecessary_semicolon.rs
Normal file
32
tests/ui/unnecessary_semicolon.rs
Normal 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
|
||||
}
|
||||
17
tests/ui/unnecessary_semicolon.stderr
Normal file
17
tests/ui/unnecessary_semicolon.stderr
Normal 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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue