First version of the lint
This commit is contained in:
parent
a507c27660
commit
eb9c6698ee
5 changed files with 98 additions and 0 deletions
18
tests/ui/semicolon_if_nothing_returned.rs
Normal file
18
tests/ui/semicolon_if_nothing_returned.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#![warn(clippy::semicolon_if_nothing_returned)]
|
||||
|
||||
fn get_unit() {}
|
||||
|
||||
// the functions below trigger the lint
|
||||
fn main() {
|
||||
println!("Hello")
|
||||
}
|
||||
|
||||
fn hello() {
|
||||
get_unit()
|
||||
}
|
||||
|
||||
// this is fine
|
||||
fn print_sum(a: i32, b: i32) {
|
||||
println!("{}", a + b);
|
||||
assert_eq!(true, false);
|
||||
}
|
||||
17
tests/ui/semicolon_if_nothing_returned.stderr
Normal file
17
tests/ui/semicolon_if_nothing_returned.stderr
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
error: add `;` to terminate block
|
||||
--> $DIR/semicolon_if_nothing_returned.rs:7:5
|
||||
|
|
||||
LL | println!("Hello")
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::semicolon-if-nothing-returned` implied by `-D warnings`
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: add `;` to terminate block
|
||||
--> $DIR/semicolon_if_nothing_returned.rs:11:5
|
||||
|
|
||||
LL | get_unit()
|
||||
| ^^^^^^^^^^ help: add `;`: `get_unit();`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue