Skip to content

Commit f1e905f

Browse files
committed
Reintroduce #768 so we can publish
1 parent 3052000 commit f1e905f

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

clippy_lints/src/panic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
4242
let ExprPath(ref qpath) = fun.node,
4343
match_def_path(cx.tcx, resolve_node(cx, qpath, fun.id).def_id(), &paths::BEGIN_PANIC),
4444
let ExprLit(ref lit) = params[0].node,
45-
is_direct_expn_of(params[0].span, "panic").is_some(),
45+
is_direct_expn_of(expr.span, "panic").is_some(),
4646
let LitKind::Str(ref string, _) = lit.node,
4747
let Some(par) = string.as_str().find('{'),
4848
string.as_str()[par..].contains('}')

tests/ui/panic.stderr

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
error: you probably are missing some parameter in your format string
2+
--> $DIR/panic.rs:8:16
3+
|
4+
8 | panic!("{}");
5+
| ^^^^
6+
|
7+
note: lint level defined here
8+
--> $DIR/panic.rs:4:9
9+
|
10+
4 | #![deny(panic_params)]
11+
| ^^^^^^^^^^^^
12+
13+
error: you probably are missing some parameter in your format string
14+
--> $DIR/panic.rs:10:16
15+
|
16+
10 | panic!("{:?}");
17+
| ^^^^^^
18+
19+
error: you probably are missing some parameter in your format string
20+
--> $DIR/panic.rs:12:23
21+
|
22+
12 | assert!(true, "here be missing values: {}");
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24+
25+
error: you probably are missing some parameter in your format string
26+
--> $DIR/panic.rs:22:5
27+
|
28+
22 | assert!("foo bar".contains(&format!("foo {}", "bar")));
29+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
30+
|
31+
= note: this error originates in a macro outside of the current crate
32+
33+
error: aborting due to 4 previous errors
34+

0 commit comments

Comments
 (0)