Update tests for exit

This commit is contained in:
Heinz N. Gies 2019-10-29 21:34:00 +01:00
parent abdf027df3
commit 5e6017d193
5 changed files with 32 additions and 6 deletions

View file

@ -6,15 +6,10 @@ fn not_main() {
}
}
fn also_not_main() {
std::process::exit(3);
}
fn main() {
if true {
std::process::exit(2);
};
also_not_main();
not_main();
std::process::exit(1);
}

10
tests/ui/exit1.stderr Normal file
View file

@ -0,0 +1,10 @@
error: usage of `process::exit`
--> $DIR/exit1.rs:5:9
|
LL | std::process::exit(4);
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D clippy::exit` implied by `-D warnings`
error: aborting due to previous error

13
tests/ui/exit2.rs Normal file
View file

@ -0,0 +1,13 @@
#[warn(clippy::exit)]
fn also_not_main() {
std::process::exit(3);
}
fn main() {
if true {
std::process::exit(2);
};
also_not_main();
std::process::exit(1);
}

View file

@ -1,5 +1,5 @@
error: usage of `process::exit`
--> $DIR/exit.rs:3:5
--> $DIR/exit2.rs:4:5
|
LL | std::process::exit(3);
| ^^^^^^^^^^^^^^^^^^^^^

8
tests/ui/exit3.rs Normal file
View file

@ -0,0 +1,8 @@
#[warn(clippy::exit)]
fn main() {
if true {
std::process::exit(2);
};
std::process::exit(1);
}