]> git.lizzy.rs Git - rust.git/commitdiff
Reintroduce #768 so we can publish
authorOliver Schneider <git-no-reply-9879165716479413131@oli-obk.de>
Fri, 7 Apr 2017 09:21:39 +0000 (11:21 +0200)
committerOliver Schneider <git-no-reply-9879165716479413131@oli-obk.de>
Fri, 7 Apr 2017 09:21:39 +0000 (11:21 +0200)
clippy_lints/src/panic.rs
tests/ui/panic.stderr

index 8db7de30f7c2e96fd996920afbee03c2eea5bf04..9c1c6beec4f667958d15a6cde5e0913dee0872b7 100644 (file)
@@ -42,7 +42,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
             let ExprPath(ref qpath) = fun.node,
             match_def_path(cx.tcx, resolve_node(cx, qpath, fun.id).def_id(), &paths::BEGIN_PANIC),
             let ExprLit(ref lit) = params[0].node,
-            is_direct_expn_of(params[0].span, "panic").is_some(),
+            is_direct_expn_of(expr.span, "panic").is_some(),
             let LitKind::Str(ref string, _) = lit.node,
             let Some(par) = string.as_str().find('{'),
             string.as_str()[par..].contains('}')
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..451a5db6441a93807d8c67ab7157973718c9be98 100644 (file)
@@ -0,0 +1,34 @@
+error: you probably are missing some parameter in your format string
+ --> $DIR/panic.rs:8:16
+  |
+8 |         panic!("{}");
+  |                ^^^^
+  |
+note: lint level defined here
+ --> $DIR/panic.rs:4:9
+  |
+4 | #![deny(panic_params)]
+  |         ^^^^^^^^^^^^
+
+error: you probably are missing some parameter in your format string
+  --> $DIR/panic.rs:10:16
+   |
+10 |         panic!("{:?}");
+   |                ^^^^^^
+
+error: you probably are missing some parameter in your format string
+  --> $DIR/panic.rs:12:23
+   |
+12 |         assert!(true, "here be missing values: {}");
+   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: you probably are missing some parameter in your format string
+  --> $DIR/panic.rs:22:5
+   |
+22 |     assert!("foo bar".contains(&format!("foo {}", "bar")));
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: this error originates in a macro outside of the current crate
+
+error: aborting due to 4 previous errors
+