Skip to content

Commit 0eee11b

Browse files
committed
Add tests for panic and todo, fix test order for panic
1 parent 283cce3 commit 0eee11b

File tree

5 files changed

+33
-3
lines changed

5 files changed

+33
-3
lines changed

clippy_lints/src/panic_unimplemented.rs

-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PanicUnimplemented {
119119
let span = get_outer_span(expr);
120120
span_lint(cx, PANIC, span,
121121
"`panic` should not be present in production code");
122-
//} else {
123122
match_panic(params, expr, cx);
124123
}
125124
}

tests/ui/panic.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#![warn(clippy::panic)]
2+
#![allow(clippy::assertions_on_constants)]
3+
4+
fn panic() {
5+
let a = 2;
6+
panic!();
7+
let b = a + 2;
8+
}
9+
10+
fn main() {
11+
panic();
12+
}

tests/ui/panic.stderr

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: `panic` should not be present in production code
2+
--> $DIR/panic.rs:6:5
3+
|
4+
LL | panic!();
5+
| ^^^^^^^^^
6+
|
7+
= note: `-D clippy::panic` implied by `-D warnings`
8+
9+
error: aborting due to previous error
10+

tests/ui/panic_unimplemented.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![warn(clippy::panic_params, clippy::unimplemented, clippy::unreachable)]
1+
#![warn(clippy::panic_params, clippy::unimplemented, clippy::unreachable, clippy::todo)]
22
#![allow(clippy::assertions_on_constants)]
33
fn missing() {
44
if true {
@@ -78,4 +78,5 @@ fn main() {
7878
ok_escaped();
7979
unimplemented();
8080
unreachable();
81+
todo();
8182
}

tests/ui/panic_unimplemented.stderr

+9-1
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,13 @@ LL | unreachable!();
4040
|
4141
= note: `-D clippy::unreachable` implied by `-D warnings`
4242

43-
error: aborting due to 6 previous errors
43+
error: `todo` should not be present in production code
44+
--> $DIR/panic_unimplemented.rs:67:5
45+
|
46+
LL | todo!();
47+
| ^^^^^^^^
48+
|
49+
= note: `-D clippy::todo` implied by `-D warnings`
50+
51+
error: aborting due to 7 previous errors
4452

0 commit comments

Comments
 (0)