From 8cf463fe935c9bf63c1eb4faae8fe2a081206cee Mon Sep 17 00:00:00 2001 From: csmoe <35686186+csmoe@users.noreply.github.com> Date: Thu, 12 Jul 2018 16:53:53 +0800 Subject: [PATCH] StmtKind --- clippy_lints/src/attrs.rs | 4 ++-- clippy_lints/src/escape.rs | 2 +- clippy_lints/src/eval_order_dependence.rs | 8 ++++---- clippy_lints/src/let_if_seq.rs | 6 +++--- clippy_lints/src/loops.rs | 16 ++++++++-------- clippy_lints/src/map_unit_fn.rs | 10 +++++----- clippy_lints/src/methods.rs | 2 +- clippy_lints/src/misc.rs | 4 ++-- clippy_lints/src/needless_bool.rs | 2 +- clippy_lints/src/needless_pass_by_value.rs | 2 +- clippy_lints/src/no_effect.rs | 2 +- clippy_lints/src/question_mark.rs | 2 +- clippy_lints/src/shadow.rs | 4 ++-- clippy_lints/src/swap.rs | 10 +++++----- clippy_lints/src/unused_io_amount.rs | 2 +- clippy_lints/src/utils/author.rs | 12 ++++++------ clippy_lints/src/utils/higher.rs | 4 ++-- clippy_lints/src/utils/hir_utils.rs | 16 ++++++++-------- clippy_lints/src/utils/inspector.rs | 4 ++-- tests/ui/author.stdout | 2 +- tests/ui/author/call.stdout | 2 +- tests/ui/author/for_loop.stdout | 12 ++++++------ tests/ui/author/matches.stout | 4 ++-- 23 files changed, 66 insertions(+), 66 deletions(-) diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index 4418ba630701..0523e4d46807 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -234,8 +234,8 @@ fn is_relevant_trait(tcx: TyCtxt, item: &TraitItem) -> bool { fn is_relevant_block(tcx: TyCtxt, tables: &ty::TypeckTables, block: &Block) -> bool { if let Some(stmt) = block.stmts.first() { match stmt.node { - StmtDecl(_, _) => true, - StmtExpr(ref expr, _) | StmtSemi(ref expr, _) => is_relevant_expr(tcx, tables, expr), + StmtKind::Decl(_, _) => true, + StmtKind::Expr(ref expr, _) | StmtKind::Semi(ref expr, _) => is_relevant_expr(tcx, tables, expr), } } else { block.expr.as_ref().map_or(false, |e| is_relevant_expr(tcx, tables, e)) diff --git a/clippy_lints/src/escape.rs b/clippy_lints/src/escape.rs index 70055b13f9bd..0ca6808b12d7 100644 --- a/clippy_lints/src/escape.rs +++ b/clippy_lints/src/escape.rs @@ -110,7 +110,7 @@ fn consume_pat(&mut self, consume_pat: &Pat, cmt: &cmt_<'tcx>, _: ConsumeMode) { if let Categorization::Rvalue(..) = cmt.cat { let id = map.hir_to_node_id(cmt.hir_id); if let Some(NodeStmt(st)) = map.find(map.get_parent_node(id)) { - if let StmtDecl(ref decl, _) = st.node { + if let StmtKind::Decl(ref decl, _) = st.node { if let DeclLocal(ref loc) = decl.node { if let Some(ref ex) = loc.init { if let ExprKind::Box(..) = ex.node { diff --git a/clippy_lints/src/eval_order_dependence.rs b/clippy_lints/src/eval_order_dependence.rs index 250ae92ea591..d2ac597b6c58 100644 --- a/clippy_lints/src/eval_order_dependence.rs +++ b/clippy_lints/src/eval_order_dependence.rs @@ -82,8 +82,8 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { } fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) { match stmt.node { - StmtExpr(ref e, _) | StmtSemi(ref e, _) => DivergenceVisitor { cx }.maybe_walk_expr(e), - StmtDecl(ref d, _) => if let DeclLocal(ref local) = d.node { + StmtKind::Expr(ref e, _) | StmtKind::Semi(ref e, _) => DivergenceVisitor { cx }.maybe_walk_expr(e), + StmtKind::Decl(ref d, _) => if let DeclLocal(ref local) = d.node { if let Local { init: Some(ref e), .. } = **local @@ -262,8 +262,8 @@ fn check_expr<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, expr: &'tcx Expr) -> St fn check_stmt<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, stmt: &'tcx Stmt) -> StopEarly { match stmt.node { - StmtExpr(ref expr, _) | StmtSemi(ref expr, _) => check_expr(vis, expr), - StmtDecl(ref decl, _) => { + StmtKind::Expr(ref expr, _) | StmtKind::Semi(ref expr, _) => check_expr(vis, expr), + StmtKind::Decl(ref decl, _) => { // If the declaration is of a local variable, check its initializer // expression if it has one. Otherwise, keep going. let local = match decl.node { diff --git a/clippy_lints/src/let_if_seq.rs b/clippy_lints/src/let_if_seq.rs index 44f197f73331..8661e9eec90d 100644 --- a/clippy_lints/src/let_if_seq.rs +++ b/clippy_lints/src/let_if_seq.rs @@ -65,10 +65,10 @@ fn check_block(&mut self, cx: &LateContext<'a, 'tcx>, block: &'tcx hir::Block) { while let Some(stmt) = it.next() { if_chain! { if let Some(expr) = it.peek(); - if let hir::StmtDecl(ref decl, _) = stmt.node; + if let hir::StmtKind::Decl(ref decl, _) = stmt.node; if let hir::DeclLocal(ref decl) = decl.node; if let hir::PatKind::Binding(mode, canonical_id, ident, None) = decl.pat.node; - if let hir::StmtExpr(ref if_, _) = expr.node; + if let hir::StmtKind::Expr(ref if_, _) = expr.node; if let hir::ExprKind::If(ref cond, ref then, ref else_) = if_.node; if !used_in_expr(cx, canonical_id, cond); if let hir::ExprKind::Block(ref then, _) = then.node; @@ -163,7 +163,7 @@ fn check_assign<'a, 'tcx>( if_chain! { if block.expr.is_none(); if let Some(expr) = block.stmts.iter().last(); - if let hir::StmtSemi(ref expr, _) = expr.node; + if let hir::StmtKind::Semi(ref expr, _) = expr.node; if let hir::ExprKind::Assign(ref var, ref value) = expr.node; if let hir::ExprKind::Path(ref qpath) = var.node; if let Def::Local(local_id) = cx.tables.qpath_def(qpath, var.hir_id); diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index 5095ddfda258..936d4f6f4cd5 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -511,7 +511,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { } fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) { - if let StmtSemi(ref expr, _) = stmt.node { + if let StmtKind::Semi(ref expr, _) = stmt.node { if let ExprKind::MethodCall(ref method, _, ref args) = expr.node { if args.len() == 1 && method.ident.name == "collect" && match_trait_method(cx, expr, &paths::ITERATOR) { span_lint( @@ -584,8 +584,8 @@ fn never_loop_block(block: &Block, main_loop_id: NodeId) -> NeverLoopResult { fn stmt_to_expr(stmt: &Stmt) -> Option<&Expr> { match stmt.node { - StmtSemi(ref e, ..) | StmtExpr(ref e, ..) => Some(e), - StmtDecl(ref d, ..) => decl_to_expr(d), + StmtKind::Semi(ref e, ..) | StmtKind::Expr(ref e, ..) => Some(e), + StmtKind::Decl(ref d, ..) => decl_to_expr(d), } } @@ -859,8 +859,8 @@ fn get_assignment<'a, 'tcx>( stmts .iter() .map(|stmt| match stmt.node { - Stmt_::StmtDecl(..) => None, - Stmt_::StmtExpr(ref e, _node_id) | Stmt_::StmtSemi(ref e, _node_id) => Some(get_assignment(cx, e, var)), + StmtKind::Decl(..) => None, + StmtKind::Expr(ref e, _node_id) | StmtKind::Semi(ref e, _node_id) => Some(get_assignment(cx, e, var)), }) .chain( expr.as_ref() @@ -1809,7 +1809,7 @@ fn extract_expr_from_first_stmt(block: &Block) -> Option<&Expr> { if block.stmts.is_empty() { return None; } - if let StmtDecl(ref decl, _) = block.stmts[0].node { + if let StmtKind::Decl(ref decl, _) = block.stmts[0].node { if let DeclLocal(ref local) = decl.node { if let Some(ref expr) = local.init { Some(expr) @@ -1829,8 +1829,8 @@ fn extract_first_expr(block: &Block) -> Option<&Expr> { match block.expr { Some(ref expr) if block.stmts.is_empty() => Some(expr), None if !block.stmts.is_empty() => match block.stmts[0].node { - StmtExpr(ref expr, _) | StmtSemi(ref expr, _) => Some(expr), - StmtDecl(..) => None, + StmtKind::Expr(ref expr, _) | StmtKind::Semi(ref expr, _) => Some(expr), + StmtKind::Decl(..) => None, }, _ => None, } diff --git a/clippy_lints/src/map_unit_fn.rs b/clippy_lints/src/map_unit_fn.rs index 598160bb3efc..8df573e4c725 100644 --- a/clippy_lints/src/map_unit_fn.rs +++ b/clippy_lints/src/map_unit_fn.rs @@ -1,7 +1,7 @@ use rustc::hir; use rustc::lint::*; use rustc::ty; -use rustc_errors::{Applicability}; +use rustc_errors::Applicability; use syntax::codemap::Span; use crate::utils::{in_macro, iter_input_pats, match_type, method_chain_args, snippet, span_lint_and_then}; use crate::utils::paths; @@ -131,9 +131,9 @@ fn reduce_unit_expression<'a>(cx: &LateContext, expr: &'a hir::Expr) -> Option Some(d.span), - hir::StmtExpr(ref e, _) => Some(e.span), - hir::StmtSemi(_, _) => Some(inner_stmt.span), + hir::StmtKind::Decl(ref d, _) => Some(d.span), + hir::StmtKind::Expr(ref e, _) => Some(e.span), + hir::StmtKind::Semi(_, _) => Some(inner_stmt.span), } }, _ => { @@ -247,7 +247,7 @@ fn check_stmt(&mut self, cx: &LateContext, stmt: &hir::Stmt) { return; } - if let hir::StmtSemi(ref expr, _) = stmt.node { + if let hir::StmtKind::Semi(ref expr, _) = stmt.node { if let hir::ExprKind::MethodCall(_, _, _) = expr.node { if let Some(arglists) = method_chain_args(expr, &["map"]) { lint_map_unit_fn(cx, stmt, expr, arglists[0]); diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index e2a1ee44f2cb..d341dc21779f 100644 --- a/clippy_lints/src/methods.rs +++ b/clippy_lints/src/methods.rs @@ -1139,7 +1139,7 @@ fn lint_clone_on_copy(cx: &LateContext, expr: &hir::Expr, arg: &hir::Expr, arg_t _ => {}, } hir::map::NodeStmt(stmt) => { - if let hir::StmtDecl(ref decl, _) = stmt.node { + if let hir::StmtKind::Decl(ref decl, _) = stmt.node { if let hir::DeclLocal(ref loc) = decl.node { if let hir::PatKind::Ref(..) = loc.pat.node { // let ref y = *x borrows x, let ref y = x.clone() does not diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index 64443301dfc4..c76ece55e2bc 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -269,7 +269,7 @@ fn check_fn( fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, s: &'tcx Stmt) { if_chain! { - if let StmtDecl(ref d, _) = s.node; + if let StmtKind::Decl(ref d, _) = s.node; if let DeclLocal(ref l) = d.node; if let PatKind::Binding(an, _, i, None) = l.pat.node; if let Some(ref init) = l.init; @@ -303,7 +303,7 @@ fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, s: &'tcx Stmt) { } }; if_chain! { - if let StmtSemi(ref expr, _) = s.node; + if let StmtKind::Semi(ref expr, _) = s.node; if let ExprKind::Binary(ref binop, ref a, ref b) = expr.node; if binop.node == BinOpKind::And || binop.node == BinOpKind::Or; if let Some(sugg) = Sugg::hir_opt(cx, a); diff --git a/clippy_lints/src/needless_bool.rs b/clippy_lints/src/needless_bool.rs index db019bdce889..2fd5ff9a2464 100644 --- a/clippy_lints/src/needless_bool.rs +++ b/clippy_lints/src/needless_bool.rs @@ -184,7 +184,7 @@ enum Expression { fn fetch_bool_block(block: &Block) -> Expression { match (&*block.stmts, block.expr.as_ref()) { (&[], Some(e)) => fetch_bool_expr(&**e), - (&[ref e], None) => if let StmtSemi(ref e, _) = e.node { + (&[ref e], None) => if let StmtKind::Semi(ref e, _) = e.node { if let ExprKind::Ret(_) = e.node { fetch_bool_expr(&**e) } else { diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index a4f8f585223f..5a44431e1a37 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -350,7 +350,7 @@ fn non_moving_pat(&mut self, matched_pat: &Pat, cmt: &mc::cmt_<'tcx>) { map::Node::NodeStmt(s) => { // `let = x;` if_chain! { - if let StmtDecl(ref decl, _) = s.node; + if let StmtKind::Decl(ref decl, _) = s.node; if let DeclLocal(ref local) = decl.node; then { self.spans_need_deref diff --git a/clippy_lints/src/no_effect.rs b/clippy_lints/src/no_effect.rs index 7dc2ab734dca..5180ff348778 100644 --- a/clippy_lints/src/no_effect.rs +++ b/clippy_lints/src/no_effect.rs @@ -97,7 +97,7 @@ fn get_lints(&self) -> LintArray { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) { - if let StmtSemi(ref expr, _) = stmt.node { + if let StmtKind::Semi(ref expr, _) = stmt.node { if has_no_effect(cx, expr) { span_lint(cx, NO_EFFECT, stmt.span, "statement with no effect"); } else if let Some(reduced) = reduce_expression(cx, expr) { diff --git a/clippy_lints/src/question_mark.rs b/clippy_lints/src/question_mark.rs index e6d231af1483..b8e7a2646c48 100644 --- a/clippy_lints/src/question_mark.rs +++ b/clippy_lints/src/question_mark.rs @@ -113,7 +113,7 @@ fn return_expression(block: &Block) -> Option> { if_chain! { if block.stmts.len() == 1; if let Some(expr) = block.stmts.iter().last(); - if let StmtSemi(ref expr, _) = expr.node; + if let StmtKind::Semi(ref expr, _) = expr.node; if let ExprKind::Ret(ref ret_expr) = expr.node; if let &Some(ref ret_expr) = ret_expr; diff --git a/clippy_lints/src/shadow.rs b/clippy_lints/src/shadow.rs index 23971395c2f1..d400e5bf7a79 100644 --- a/clippy_lints/src/shadow.rs +++ b/clippy_lints/src/shadow.rs @@ -110,8 +110,8 @@ fn check_block<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, block: &'tcx Block, binding let len = bindings.len(); for stmt in &block.stmts { match stmt.node { - StmtDecl(ref decl, _) => check_decl(cx, decl, bindings), - StmtExpr(ref e, _) | StmtSemi(ref e, _) => check_expr(cx, e, bindings), + StmtKind::Decl(ref decl, _) => check_decl(cx, decl, bindings), + StmtKind::Expr(ref e, _) | StmtKind::Semi(ref e, _) => check_expr(cx, e, bindings), } } if let Some(ref o) = block.expr { diff --git a/clippy_lints/src/swap.rs b/clippy_lints/src/swap.rs index 55ad4f40e10e..6ce7b4802508 100644 --- a/clippy_lints/src/swap.rs +++ b/clippy_lints/src/swap.rs @@ -61,17 +61,17 @@ fn check_manual_swap(cx: &LateContext, block: &Block) { for w in block.stmts.windows(3) { if_chain! { // let t = foo(); - if let StmtDecl(ref tmp, _) = w[0].node; + if let StmtKind::Decl(ref tmp, _) = w[0].node; if let DeclLocal(ref tmp) = tmp.node; if let Some(ref tmp_init) = tmp.init; if let PatKind::Binding(_, _, ident, None) = tmp.pat.node; // foo() = bar(); - if let StmtSemi(ref first, _) = w[1].node; + if let StmtKind::Semi(ref first, _) = w[1].node; if let ExprKind::Assign(ref lhs1, ref rhs1) = first.node; // bar() = t; - if let StmtSemi(ref second, _) = w[2].node; + if let StmtKind::Semi(ref second, _) = w[2].node; if let ExprKind::Assign(ref lhs2, ref rhs2) = second.node; if let ExprKind::Path(QPath::Resolved(None, ref rhs2)) = rhs2.node; if rhs2.segments.len() == 1; @@ -145,8 +145,8 @@ fn check_for_slice<'a>( fn check_suspicious_swap(cx: &LateContext, block: &Block) { for w in block.stmts.windows(2) { if_chain! { - if let StmtSemi(ref first, _) = w[0].node; - if let StmtSemi(ref second, _) = w[1].node; + if let StmtKind::Semi(ref first, _) = w[0].node; + if let StmtKind::Semi(ref second, _) = w[1].node; if !differing_macro_contexts(first.span, second.span); if let ExprKind::Assign(ref lhs0, ref rhs0) = first.node; if let ExprKind::Assign(ref lhs1, ref rhs1) = second.node; diff --git a/clippy_lints/src/unused_io_amount.rs b/clippy_lints/src/unused_io_amount.rs index e699253efaa3..649a10333710 100644 --- a/clippy_lints/src/unused_io_amount.rs +++ b/clippy_lints/src/unused_io_amount.rs @@ -40,7 +40,7 @@ fn get_lints(&self) -> LintArray { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedIoAmount { fn check_stmt(&mut self, cx: &LateContext, s: &hir::Stmt) { let expr = match s.node { - hir::StmtSemi(ref expr, _) | hir::StmtExpr(ref expr, _) => &**expr, + hir::StmtKind::Semi(ref expr, _) | hir::StmtKind::Expr(ref expr, _) => &**expr, _ => return, }; diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs index a20901b1504b..eccb8e53583d 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -592,9 +592,9 @@ fn visit_stmt(&mut self, s: &Stmt) { let current = format!("{}.node", self.current); match s.node { // Could be an item or a local (let) binding: - StmtDecl(ref decl, _) => { + StmtKind::Decl(ref decl, _) => { let decl_pat = self.next("decl"); - println!("StmtDecl(ref {}, _) = {}", decl_pat, current); + println!("StmtKind::Decl(ref {}, _) = {}", decl_pat, current); print!(" if let Decl_::"); let current = format!("{}.node", decl_pat); match decl.node { @@ -619,17 +619,17 @@ fn visit_stmt(&mut self, s: &Stmt) { } // Expr without trailing semi-colon (must have unit type): - StmtExpr(ref e, _) => { + StmtKind::Expr(ref e, _) => { let e_pat = self.next("e"); - println!("StmtExpr(ref {}, _) = {}", e_pat, current); + println!("StmtKind::Expr(ref {}, _) = {}", e_pat, current); self.current = e_pat; self.visit_expr(e); }, // Expr with trailing semi-colon (may have any type): - StmtSemi(ref e, _) => { + StmtKind::Semi(ref e, _) => { let e_pat = self.next("e"); - println!("StmtSemi(ref {}, _) = {}", e_pat, current); + println!("StmtKind::Semi(ref {}, _) = {}", e_pat, current); self.current = e_pat; self.visit_expr(e); }, diff --git a/clippy_lints/src/utils/higher.rs b/clippy_lints/src/utils/higher.rs index 75b7fd9e2fe3..72b39000ce5f 100644 --- a/clippy_lints/src/utils/higher.rs +++ b/clippy_lints/src/utils/higher.rs @@ -191,9 +191,9 @@ pub fn for_loop(expr: &hir::Expr) -> Option<(&hir::Pat, &hir::Expr, &hir::Expr)> if let hir::ExprKind::Loop(ref block, _, _) = arms[0].body.node; if block.expr.is_none(); if let [ _, _, ref let_stmt, ref body ] = *block.stmts; - if let hir::StmtDecl(ref decl, _) = let_stmt.node; + if let hir::StmtKind::Decl(ref decl, _) = let_stmt.node; if let hir::DeclLocal(ref decl) = decl.node; - if let hir::StmtExpr(ref expr, _) = body.node; + if let hir::StmtKind::Expr(ref expr, _) = body.node; then { return Some((&*decl.pat, &iterargs[0], expr)); } diff --git a/clippy_lints/src/utils/hir_utils.rs b/clippy_lints/src/utils/hir_utils.rs index 4fec24b3489b..2cec0b2da082 100644 --- a/clippy_lints/src/utils/hir_utils.rs +++ b/clippy_lints/src/utils/hir_utils.rs @@ -43,14 +43,14 @@ pub fn ignore_fn(self) -> Self { /// Check whether two statements are the same. pub fn eq_stmt(&mut self, left: &Stmt, right: &Stmt) -> bool { match (&left.node, &right.node) { - (&StmtDecl(ref l, _), &StmtDecl(ref r, _)) => { + (&StmtKind::Decl(ref l, _), &StmtKind::Decl(ref r, _)) => { if let (&DeclLocal(ref l), &DeclLocal(ref r)) = (&l.node, &r.node) { both(&l.ty, &r.ty, |l, r| self.eq_ty(l, r)) && both(&l.init, &r.init, |l, r| self.eq_expr(l, r)) } else { false } }, - (&StmtExpr(ref l, _), &StmtExpr(ref r, _)) | (&StmtSemi(ref l, _), &StmtSemi(ref r, _)) => { + (&StmtKind::Expr(ref l, _), &StmtKind::Expr(ref r, _)) | (&StmtKind::Semi(ref l, _), &StmtKind::Semi(ref r, _)) => { self.eq_expr(l, r) }, _ => false, @@ -613,8 +613,8 @@ pub fn hash_path(&mut self, p: &Path) { pub fn hash_stmt(&mut self, b: &Stmt) { match b.node { - StmtDecl(ref decl, _) => { - let c: fn(_, _) -> _ = StmtDecl; + StmtKind::Decl(ref decl, _) => { + let c: fn(_, _) -> _ = StmtKind::Decl; c.hash(&mut self.s); if let DeclLocal(ref local) = decl.node { @@ -623,13 +623,13 @@ pub fn hash_stmt(&mut self, b: &Stmt) { } } }, - StmtExpr(ref expr, _) => { - let c: fn(_, _) -> _ = StmtExpr; + StmtKind::Expr(ref expr, _) => { + let c: fn(_, _) -> _ = StmtKind::Expr; c.hash(&mut self.s); self.hash_expr(expr); }, - StmtSemi(ref expr, _) => { - let c: fn(_, _) -> _ = StmtSemi; + StmtKind::Semi(ref expr, _) => { + let c: fn(_, _) -> _ = StmtKind::Semi; c.hash(&mut self.s); self.hash_expr(expr); }, diff --git a/clippy_lints/src/utils/inspector.rs b/clippy_lints/src/utils/inspector.rs index 3143da08da92..1faab3720286 100644 --- a/clippy_lints/src/utils/inspector.rs +++ b/clippy_lints/src/utils/inspector.rs @@ -122,8 +122,8 @@ fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx hir::Stmt) { return; } match stmt.node { - hir::StmtDecl(ref decl, _) => print_decl(cx, decl), - hir::StmtExpr(ref e, _) | hir::StmtSemi(ref e, _) => print_expr(cx, e, 0), + hir::StmtKind::Decl(ref decl, _) => print_decl(cx, decl), + hir::StmtKind::Expr(ref e, _) | hir::StmtKind::Semi(ref e, _) => print_expr(cx, e, 0), } } // fn check_foreign_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx diff --git a/tests/ui/author.stdout b/tests/ui/author.stdout index 10b7348b4b5b..4b97e546ad33 100644 --- a/tests/ui/author.stdout +++ b/tests/ui/author.stdout @@ -1,5 +1,5 @@ if_chain! { - if let Stmt_::StmtDecl(ref decl, _) = stmt.node + if let StmtKind::Decl(ref decl, _) = stmt.node if let Decl_::DeclLocal(ref local) = decl.node; if let Some(ref init) = local.init if let ExprKind::Cast(ref expr, ref cast_ty) = init.node; diff --git a/tests/ui/author/call.stdout b/tests/ui/author/call.stdout index fe90d66ad047..c04909c78dd9 100644 --- a/tests/ui/author/call.stdout +++ b/tests/ui/author/call.stdout @@ -1,5 +1,5 @@ if_chain! { - if let Stmt_::StmtDecl(ref decl, _) = stmt.node + if let StmtKind::Decl(ref decl, _) = stmt.node if let Decl_::DeclLocal(ref local) = decl.node; if let Some(ref init) = local.init if let ExprKind::Call(ref func, ref args) = init.node; diff --git a/tests/ui/author/for_loop.stdout b/tests/ui/author/for_loop.stdout index dc506b22798b..7c2213b9c49d 100644 --- a/tests/ui/author/for_loop.stdout +++ b/tests/ui/author/for_loop.stdout @@ -1,6 +1,6 @@ if_chain! { if let ExprKind::Block(ref block) = expr.node; - if let Stmt_::StmtDecl(ref decl, _) = block.node + if let StmtKind::Decl(ref decl, _) = block.node if let Decl_::DeclLocal(ref local) = decl.node; if let Some(ref init) = local.init if let ExprKind::Match(ref expr, ref arms, MatchSource::ForLoopDesugar) = init.node; @@ -14,11 +14,11 @@ if_chain! { // unimplemented: field checks if arms.len() == 1; if let ExprKind::Loop(ref body, ref label, LoopSource::ForLoop) = arms[0].body.node; - if let Stmt_::StmtDecl(ref decl1, _) = body.node + if let StmtKind::Decl(ref decl1, _) = body.node if let Decl_::DeclLocal(ref local1) = decl1.node; if let PatKind::Binding(BindingAnnotation::Mutable, _, name, None) = local1.pat.node; if name.node.as_str() == "__next"; - if let Stmt_::StmtExpr(ref e, _) = local1.pat.node + if let StmtKind::Expr(ref e, _) = local1.pat.node if let ExprKind::Match(ref expr1, ref arms1, MatchSource::ForLoopDesugar) = e.node; if let ExprKind::Call(ref func1, ref args1) = expr1.node; if let ExprKind::Path(ref path2) = func1.node; @@ -42,16 +42,16 @@ if_chain! { if arms1[1].pats.len() == 1; if let PatKind::Path(ref path7) = arms1[1].pats[0].node; if match_qpath(path7, &["{{root}}", "std", "option", "Option", "None"]); - if let Stmt_::StmtDecl(ref decl2, _) = path7.node + if let StmtKind::Decl(ref decl2, _) = path7.node if let Decl_::DeclLocal(ref local2) = decl2.node; if let Some(ref init1) = local2.init if let ExprKind::Path(ref path8) = init1.node; if match_qpath(path8, &["__next"]); if let PatKind::Binding(BindingAnnotation::Unannotated, _, name1, None) = local2.pat.node; if name1.node.as_str() == "y"; - if let Stmt_::StmtExpr(ref e1, _) = local2.pat.node + if let StmtKind::Expr(ref e1, _) = local2.pat.node if let ExprKind::Block(ref block1) = e1.node; - if let Stmt_::StmtDecl(ref decl3, _) = block1.node + if let StmtKind::Decl(ref decl3, _) = block1.node if let Decl_::DeclLocal(ref local3) = decl3.node; if let Some(ref init2) = local3.init if let ExprKind::Path(ref path9) = init2.node; diff --git a/tests/ui/author/matches.stout b/tests/ui/author/matches.stout index f314f7b2e251..63d669d4a7d4 100644 --- a/tests/ui/author/matches.stout +++ b/tests/ui/author/matches.stout @@ -1,5 +1,5 @@ if_chain! { - if let Stmt_::StmtDecl(ref decl, _) = stmt.node + if let StmtKind::Decl(ref decl, _) = stmt.node if let Decl_::DeclLocal(ref local) = decl.node; if let Some(ref init) = local.init if let ExprKind::Match(ref expr, ref arms, MatchSource::Normal) = init.node; @@ -13,7 +13,7 @@ if_chain! { if let ExprKind::Lit(ref lit2) = lit_expr.node; if let LitKind::Int(16, _) = lit2.node; if let ExprKind::Block(ref block) = arms[1].body.node; - if let Stmt_::StmtDecl(ref decl1, _) = block.node + if let StmtKind::Decl(ref decl1, _) = block.node if let Decl_::DeclLocal(ref local1) = decl1.node; if let Some(ref init1) = local1.init if let ExprKind::Lit(ref lit3) = init1.node;