diff --git a/tests/ui/exit.rs b/tests/ui/exit1.rs similarity index 73% rename from tests/ui/exit.rs rename to tests/ui/exit1.rs index 0ad15faef77..4eac6eb7467 100644 --- a/tests/ui/exit.rs +++ b/tests/ui/exit1.rs @@ -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); } diff --git a/tests/ui/exit1.stderr b/tests/ui/exit1.stderr new file mode 100644 index 00000000000..a8d3956aa27 --- /dev/null +++ b/tests/ui/exit1.stderr @@ -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 + diff --git a/tests/ui/exit2.rs b/tests/ui/exit2.rs new file mode 100644 index 00000000000..4b693ed7083 --- /dev/null +++ b/tests/ui/exit2.rs @@ -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); +} diff --git a/tests/ui/exit.stderr b/tests/ui/exit2.stderr similarity index 89% rename from tests/ui/exit.stderr rename to tests/ui/exit2.stderr index 756cf883749..7263e156a9d 100644 --- a/tests/ui/exit.stderr +++ b/tests/ui/exit2.stderr @@ -1,5 +1,5 @@ error: usage of `process::exit` - --> $DIR/exit.rs:3:5 + --> $DIR/exit2.rs:4:5 | LL | std::process::exit(3); | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/exit3.rs b/tests/ui/exit3.rs new file mode 100644 index 00000000000..9dc0e1015a4 --- /dev/null +++ b/tests/ui/exit3.rs @@ -0,0 +1,8 @@ +#[warn(clippy::exit)] + +fn main() { + if true { + std::process::exit(2); + }; + std::process::exit(1); +}