about summary refs log tree commit diff
path: root/clippy_lints/src/format.rs
diff options
context:
space:
mode:
authormcarton <cartonmartin+git@gmail.com>2018-10-02 23:55:25 +0200
committermcarton <cartonmartin+git@gmail.com>2018-10-02 23:57:22 +0200
commit7eebd5b20c215c4baa98a1ac569e543712451c33 (patch)
tree4cd88805d7540e9ed3919fa2b5e0dd089a4a5e69 /clippy_lints/src/format.rs
parentd18c7b272245f41cea9303ca62beb9ca64615251 (diff)
downloadrust-7eebd5b20c215c4baa98a1ac569e543712451c33.tar.gz
rust-7eebd5b20c215c4baa98a1ac569e543712451c33.zip
Ignore `format!` with precision in `USELESS_FORMAT`
Diffstat (limited to 'clippy_lints/src/format.rs')
-rw-r--r--clippy_lints/src/format.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/clippy_lints/src/format.rs b/clippy_lints/src/format.rs
index 2eb95ebffbf..2d40150bc8e 100644
--- a/clippy_lints/src/format.rs
+++ b/clippy_lints/src/format.rs
@@ -47,7 +47,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
                 return;
             }
             match expr.node {
-
                 // `format!("{}", foo)` expansion
                 ExprKind::Call(ref fun, ref args) => {
                     if_chain! {
@@ -162,9 +161,12 @@ fn check_unformatted(expr: &Expr) -> bool {
         if let ExprKind::Struct(_, ref fields, _) = exprs[0].node;
         if let Some(format_field) = fields.iter().find(|f| f.ident.name == "format");
         if let ExprKind::Struct(_, ref fields, _) = format_field.expr.node;
-        if let Some(align_field) = fields.iter().find(|f| f.ident.name == "width");
-        if let ExprKind::Path(ref qpath) = align_field.expr.node;
-        if last_path_segment(qpath).ident.name == "Implied";
+        if let Some(width_field) = fields.iter().find(|f| f.ident.name == "width");
+        if let ExprKind::Path(ref width_qpath) = width_field.expr.node;
+        if last_path_segment(width_qpath).ident.name == "Implied";
+        if let Some(precision_field) = fields.iter().find(|f| f.ident.name == "precision");
+        if let ExprKind::Path(ref precision_path) = precision_field.expr.node;
+        if last_path_segment(precision_path).ident.name == "Implied";
         then {
             return true;
         }