From 8d8ba14371f78aeb822487f2edf028cc006c549c Mon Sep 17 00:00:00 2001
From: flip1995 <hello@philkrones.com>
Date: Fri, 27 Sep 2019 18:01:04 +0200
Subject: [PATCH] Fix author lint

---
 clippy_lints/src/utils/author.rs |  6 ++---
 tests/ui/author.stdout           |  2 +-
 tests/ui/author/blocks.rs        |  2 +-
 tests/ui/author/blocks.stderr    | 16 --------------
 tests/ui/author/for_loop.stdout  |  8 +++----
 tests/ui/author/matches.rs       |  2 +-
 tests/ui/author/matches.stderr   | 17 --------------
 tests/ui/author/matches.stdout   | 33 +++++++++++++++++++++++++++
 tests/ui/author/matches.stout    | 38 --------------------------------
 9 files changed, 43 insertions(+), 81 deletions(-)
 delete mode 100644 tests/ui/author/blocks.stderr
 delete mode 100644 tests/ui/author/matches.stderr
 create mode 100644 tests/ui/author/matches.stdout
 delete mode 100644 tests/ui/author/matches.stout

diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs
index 664bcc5a744..f36570904c0 100644
--- a/clippy_lints/src/utils/author.rs
+++ b/clippy_lints/src/utils/author.rs
@@ -38,7 +38,7 @@ declare_clippy_lint! {
     ///     if let ExprKind::Binary(BinOp::Eq, ref left, ref right) = cond.kind,
     ///     if let ExprKind::Path(ref path) = left.kind,
     ///     if let ExprKind::Lit(ref lit) = right.kind,
-    ///     if let LitKind::Int(42, _) = lit.kind,
+    ///     if let LitKind::Int(42, _) = lit.node,
     ///     then {
     ///         // report your lint here
     ///     }
@@ -401,7 +401,7 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
                 let obj_pat = self.next("object");
                 let field_name_pat = self.next("field_name");
                 println!("Field(ref {}, ref {}) = {};", obj_pat, field_name_pat, current);
-                println!("    if {}.kind.as_str() == {:?}", field_name_pat, field_ident.as_str());
+                println!("    if {}.as_str() == {:?}", field_name_pat, field_ident.as_str());
                 self.current = obj_pat;
                 self.visit_expr(object);
             },
@@ -532,7 +532,7 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
                 } else {
                     println!("Binding({}, _, {}, None) = {};", anno_pat, name_pat, current);
                 }
-                println!("    if {}.kind.as_str() == \"{}\";", name_pat, ident.as_str());
+                println!("    if {}.as_str() == \"{}\";", name_pat, ident.as_str());
             },
             PatKind::Struct(ref path, ref fields, ignore) => {
                 let path_pat = self.next("path");
diff --git a/tests/ui/author.stdout b/tests/ui/author.stdout
index 72f27d89309..211d11c7c1a 100644
--- a/tests/ui/author.stdout
+++ b/tests/ui/author.stdout
@@ -7,7 +7,7 @@ if_chain! {
     if let ExprKind::Lit(ref lit) = expr.kind;
     if let LitKind::Int(69, _) = lit.node;
     if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = local.pat.kind;
-    if name.kind.as_str() == "x";
+    if name.as_str() == "x";
     then {
         // report your lint here
     }
diff --git a/tests/ui/author/blocks.rs b/tests/ui/author/blocks.rs
index cabb0cc8c32..6034762d130 100644
--- a/tests/ui/author/blocks.rs
+++ b/tests/ui/author/blocks.rs
@@ -1,5 +1,5 @@
 #![feature(stmt_expr_attributes)]
-#![allow(redundant_semicolon)]
+#![allow(redundant_semicolon, clippy::no_effect)]
 
 #[rustfmt::skip]
 fn main() {
diff --git a/tests/ui/author/blocks.stderr b/tests/ui/author/blocks.stderr
deleted file mode 100644
index 1766663344c..00000000000
--- a/tests/ui/author/blocks.stderr
+++ /dev/null
@@ -1,16 +0,0 @@
-error: statement with no effect
-  --> $DIR/blocks.rs:8:9
-   |
-LL |         ;;;;
-   |         ^^^^
-   |
-   = note: `-D clippy::no-effect` implied by `-D warnings`
-
-error: statement with no effect
-  --> $DIR/blocks.rs:15:5
-   |
-LL |     -x;
-   |     ^^^
-
-error: aborting due to 2 previous errors
-
diff --git a/tests/ui/author/for_loop.stdout b/tests/ui/author/for_loop.stdout
index eb724dda88b..0ad5834cd90 100644
--- a/tests/ui/author/for_loop.stdout
+++ b/tests/ui/author/for_loop.stdout
@@ -15,7 +15,7 @@ if_chain! {
     if body.stmts.len() == 4;
     if let StmtKind::Local(ref local) = body.stmts[0].kind;
     if let PatKind::Binding(BindingAnnotation::Mutable, _, name, None) = local.pat.kind;
-    if name.kind.as_str() == "__next";
+    if name.as_str() == "__next";
     if let StmtKind::Expr(ref e, _) = body.stmts[1].kind
     if let ExprKind::Match(ref expr2, ref arms1, MatchSource::ForLoopDesugar) = e.kind;
     if let ExprKind::Call(ref func1, ref args1) = expr2.kind;
@@ -43,7 +43,7 @@ if_chain! {
     if let ExprKind::Path(ref path8) = init.kind;
     if match_qpath(path8, &["__next"]);
     if let PatKind::Binding(BindingAnnotation::Unannotated, _, name1, None) = local1.pat.kind;
-    if name1.kind.as_str() == "y";
+    if name1.as_str() == "y";
     if let StmtKind::Expr(ref e1, _) = body.stmts[3].kind
     if let ExprKind::Block(ref block) = e1.kind;
     if let Some(trailing_expr1) = &block.expr;
@@ -53,9 +53,9 @@ if_chain! {
     if let ExprKind::Path(ref path9) = init1.kind;
     if match_qpath(path9, &["y"]);
     if let PatKind::Binding(BindingAnnotation::Unannotated, _, name2, None) = local2.pat.kind;
-    if name2.kind.as_str() == "z";
+    if name2.as_str() == "z";
     if let PatKind::Binding(BindingAnnotation::Mutable, _, name3, None) = arms[0].pat.kind;
-    if name3.kind.as_str() == "iter";
+    if name3.as_str() == "iter";
     then {
         // report your lint here
     }
diff --git a/tests/ui/author/matches.rs b/tests/ui/author/matches.rs
index e6bf229103f..674e07ec2d3 100644
--- a/tests/ui/author/matches.rs
+++ b/tests/ui/author/matches.rs
@@ -1,4 +1,4 @@
-#![feature(tool_attributes)]
+#![allow(clippy::let_and_return)]
 
 fn main() {
     #[clippy::author]
diff --git a/tests/ui/author/matches.stderr b/tests/ui/author/matches.stderr
deleted file mode 100644
index 74d070dc4b2..00000000000
--- a/tests/ui/author/matches.stderr
+++ /dev/null
@@ -1,17 +0,0 @@
-error: returning the result of a let binding from a block
-  --> $DIR/matches.rs:9:13
-   |
-LL |             let x = 3;
-   |             ---------- unnecessary let binding
-LL |             x
-   |             ^
-   |
-   = note: `-D clippy::let-and-return` implied by `-D warnings`
-help: return the expression directly
-   |
-LL |             
-LL |             3
-   |
-
-error: aborting due to previous error
-
diff --git a/tests/ui/author/matches.stdout b/tests/ui/author/matches.stdout
new file mode 100644
index 00000000000..2e8f8227dca
--- /dev/null
+++ b/tests/ui/author/matches.stdout
@@ -0,0 +1,33 @@
+if_chain! {
+    if let StmtKind::Local(ref local) = stmt.kind;
+    if let Some(ref init) = local.init;
+    if let ExprKind::Match(ref expr, ref arms, MatchSource::Normal) = init.kind;
+    if let ExprKind::Lit(ref lit) = expr.kind;
+    if let LitKind::Int(42, _) = lit.node;
+    if arms.len() == 3;
+    if let ExprKind::Lit(ref lit1) = arms[0].body.kind;
+    if let LitKind::Int(5, _) = lit1.node;
+    if let PatKind::Lit(ref lit_expr) = arms[0].pat.kind
+    if let ExprKind::Lit(ref lit2) = lit_expr.kind;
+    if let LitKind::Int(16, _) = lit2.node;
+    if let ExprKind::Block(ref block) = arms[1].body.kind;
+    if let Some(trailing_expr) = &block.expr;
+    if block.stmts.len() == 1;
+    if let StmtKind::Local(ref local1) = block.stmts[0].kind;
+    if let Some(ref init1) = local1.init;
+    if let ExprKind::Lit(ref lit3) = init1.kind;
+    if let LitKind::Int(3, _) = lit3.node;
+    if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = local1.pat.kind;
+    if name.as_str() == "x";
+    if let PatKind::Lit(ref lit_expr1) = arms[1].pat.kind
+    if let ExprKind::Lit(ref lit4) = lit_expr1.kind;
+    if let LitKind::Int(17, _) = lit4.node;
+    if let ExprKind::Lit(ref lit5) = arms[2].body.kind;
+    if let LitKind::Int(1, _) = lit5.node;
+    if let PatKind::Wild = arms[2].pat.kind;
+    if let PatKind::Binding(BindingAnnotation::Unannotated, _, name1, None) = local.pat.kind;
+    if name1.as_str() == "a";
+    then {
+        // report your lint here
+    }
+}
diff --git a/tests/ui/author/matches.stout b/tests/ui/author/matches.stout
deleted file mode 100644
index a83754125fb..00000000000
--- a/tests/ui/author/matches.stout
+++ /dev/null
@@ -1,38 +0,0 @@
-if_chain! {
-    if let StmtKind::Decl(ref decl, _) = stmt.kind
-    if let DeclKind::Local(ref local) = decl.kind;
-    if let Some(ref init) = local.init;
-    if let ExprKind::Match(ref expr, ref arms, MatchSource::Normal) = init.kind;
-    if let ExprKind::Lit(ref lit) = expr.kind;
-    if let LitKind::Int(42, _) = lit.kind;
-    if arms.len() == 3;
-    if let ExprKind::Lit(ref lit1) = arms[0].body.kind;
-    if let LitKind::Int(5, _) = lit1.kind;
-    if arms[0].pats.len() == 1;
-    if let PatKind::Lit(ref lit_expr) = arms[0].pats[0].kind
-    if let ExprKind::Lit(ref lit2) = lit_expr.kind;
-    if let LitKind::Int(16, _) = lit2.kind;
-    if let ExprKind::Block(ref block) = arms[1].body.kind;
-    if let StmtKind::Decl(ref decl1, _) = block.kind
-    if let DeclKind::Local(ref local1) = decl1.kind;
-    if let Some(ref init1) = local1.init
-    if let ExprKind::Lit(ref lit3) = init1.kind;
-    if let LitKind::Int(3, _) = lit3.kind;
-    if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = local1.pat.kind;
-    if name.kind.as_str() == "x";
-    if let ExprKind::Path(ref path) = local1.pat.kind;
-    if match_qpath(path, &["x"]);
-    if arms[1].pats.len() == 1;
-    if let PatKind::Lit(ref lit_expr1) = arms[1].pats[0].kind
-    if let ExprKind::Lit(ref lit4) = lit_expr1.kind;
-    if let LitKind::Int(17, _) = lit4.kind;
-    if let ExprKind::Lit(ref lit5) = arms[2].body.kind;
-    if let LitKind::Int(1, _) = lit5.kind;
-    if arms[2].pats.len() == 1;
-    if let PatKind::Wild = arms[2].pats[0].kind;
-    if let PatKind::Binding(BindingAnnotation::Unannotated, _, name1, None) = local.pat.kind;
-    if name1.kind.as_str() == "a";
-    then {
-        // report your lint here
-    }
-}