Skip to content

Commit 55a4664

Browse files
committed
StmtKind
1 parent 6291ef7 commit 55a4664

23 files changed

+66
-66
lines changed

clippy_lints/src/attrs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ fn is_relevant_trait(tcx: TyCtxt, item: &TraitItem) -> bool {
234234
fn is_relevant_block(tcx: TyCtxt, tables: &ty::TypeckTables, block: &Block) -> bool {
235235
if let Some(stmt) = block.stmts.first() {
236236
match stmt.node {
237-
StmtDecl(_, _) => true,
238-
StmtExpr(ref expr, _) | StmtSemi(ref expr, _) => is_relevant_expr(tcx, tables, expr),
237+
StmtKind::Decl(_, _) => true,
238+
StmtKind::Expr(ref expr, _) | StmtKind::Semi(ref expr, _) => is_relevant_expr(tcx, tables, expr),
239239
}
240240
} else {
241241
block.expr.as_ref().map_or(false, |e| is_relevant_expr(tcx, tables, e))

clippy_lints/src/escape.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
110110
if let Categorization::Rvalue(..) = cmt.cat {
111111
let id = map.hir_to_node_id(cmt.hir_id);
112112
if let Some(NodeStmt(st)) = map.find(map.get_parent_node(id)) {
113-
if let StmtDecl(ref decl, _) = st.node {
113+
if let StmtKind::Decl(ref decl, _) = st.node {
114114
if let DeclLocal(ref loc) = decl.node {
115115
if let Some(ref ex) = loc.init {
116116
if let ExprKind::Box(..) = ex.node {

clippy_lints/src/eval_order_dependence.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EvalOrderDependence {
8282
}
8383
fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) {
8484
match stmt.node {
85-
StmtExpr(ref e, _) | StmtSemi(ref e, _) => DivergenceVisitor { cx }.maybe_walk_expr(e),
86-
StmtDecl(ref d, _) => if let DeclLocal(ref local) = d.node {
85+
StmtKind::Expr(ref e, _) | StmtKind::Semi(ref e, _) => DivergenceVisitor { cx }.maybe_walk_expr(e),
86+
StmtKind::Decl(ref d, _) => if let DeclLocal(ref local) = d.node {
8787
if let Local {
8888
init: Some(ref e), ..
8989
} = **local
@@ -262,8 +262,8 @@ fn check_expr<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, expr: &'tcx Expr) -> St
262262

263263
fn check_stmt<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, stmt: &'tcx Stmt) -> StopEarly {
264264
match stmt.node {
265-
StmtExpr(ref expr, _) | StmtSemi(ref expr, _) => check_expr(vis, expr),
266-
StmtDecl(ref decl, _) => {
265+
StmtKind::Expr(ref expr, _) | StmtKind::Semi(ref expr, _) => check_expr(vis, expr),
266+
StmtKind::Decl(ref decl, _) => {
267267
// If the declaration is of a local variable, check its initializer
268268
// expression if it has one. Otherwise, keep going.
269269
let local = match decl.node {

clippy_lints/src/let_if_seq.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq {
6565
while let Some(stmt) = it.next() {
6666
if_chain! {
6767
if let Some(expr) = it.peek();
68-
if let hir::StmtDecl(ref decl, _) = stmt.node;
68+
if let hir::StmtKind::Decl(ref decl, _) = stmt.node;
6969
if let hir::DeclLocal(ref decl) = decl.node;
7070
if let hir::PatKind::Binding(mode, canonical_id, ident, None) = decl.pat.node;
71-
if let hir::StmtExpr(ref if_, _) = expr.node;
71+
if let hir::StmtKind::Expr(ref if_, _) = expr.node;
7272
if let hir::ExprKind::If(ref cond, ref then, ref else_) = if_.node;
7373
if !used_in_expr(cx, canonical_id, cond);
7474
if let hir::ExprKind::Block(ref then, _) = then.node;
@@ -163,7 +163,7 @@ fn check_assign<'a, 'tcx>(
163163
if_chain! {
164164
if block.expr.is_none();
165165
if let Some(expr) = block.stmts.iter().last();
166-
if let hir::StmtSemi(ref expr, _) = expr.node;
166+
if let hir::StmtKind::Semi(ref expr, _) = expr.node;
167167
if let hir::ExprKind::Assign(ref var, ref value) = expr.node;
168168
if let hir::ExprKind::Path(ref qpath) = var.node;
169169
if let Def::Local(local_id) = cx.tables.qpath_def(qpath, var.hir_id);

clippy_lints/src/loops.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
511511
}
512512

513513
fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) {
514-
if let StmtSemi(ref expr, _) = stmt.node {
514+
if let StmtKind::Semi(ref expr, _) = stmt.node {
515515
if let ExprKind::MethodCall(ref method, _, ref args) = expr.node {
516516
if args.len() == 1 && method.ident.name == "collect" && match_trait_method(cx, expr, &paths::ITERATOR) {
517517
span_lint(
@@ -584,8 +584,8 @@ fn never_loop_block(block: &Block, main_loop_id: NodeId) -> NeverLoopResult {
584584

585585
fn stmt_to_expr(stmt: &Stmt) -> Option<&Expr> {
586586
match stmt.node {
587-
StmtSemi(ref e, ..) | StmtExpr(ref e, ..) => Some(e),
588-
StmtDecl(ref d, ..) => decl_to_expr(d),
587+
StmtKind::Semi(ref e, ..) | StmtKind::Expr(ref e, ..) => Some(e),
588+
StmtKind::Decl(ref d, ..) => decl_to_expr(d),
589589
}
590590
}
591591

@@ -859,8 +859,8 @@ fn get_indexed_assignments<'a, 'tcx>(
859859
stmts
860860
.iter()
861861
.map(|stmt| match stmt.node {
862-
Stmt_::StmtDecl(..) => None,
863-
Stmt_::StmtExpr(ref e, _node_id) | Stmt_::StmtSemi(ref e, _node_id) => Some(get_assignment(cx, e, var)),
862+
StmtKind::Decl(..) => None,
863+
StmtKind::Expr(ref e, _node_id) | StmtKind::Semi(ref e, _node_id) => Some(get_assignment(cx, e, var)),
864864
})
865865
.chain(
866866
expr.as_ref()
@@ -1809,7 +1809,7 @@ fn extract_expr_from_first_stmt(block: &Block) -> Option<&Expr> {
18091809
if block.stmts.is_empty() {
18101810
return None;
18111811
}
1812-
if let StmtDecl(ref decl, _) = block.stmts[0].node {
1812+
if let StmtKind::Decl(ref decl, _) = block.stmts[0].node {
18131813
if let DeclLocal(ref local) = decl.node {
18141814
if let Some(ref expr) = local.init {
18151815
Some(expr)
@@ -1829,8 +1829,8 @@ fn extract_first_expr(block: &Block) -> Option<&Expr> {
18291829
match block.expr {
18301830
Some(ref expr) if block.stmts.is_empty() => Some(expr),
18311831
None if !block.stmts.is_empty() => match block.stmts[0].node {
1832-
StmtExpr(ref expr, _) | StmtSemi(ref expr, _) => Some(expr),
1833-
StmtDecl(..) => None,
1832+
StmtKind::Expr(ref expr, _) | StmtKind::Semi(ref expr, _) => Some(expr),
1833+
StmtKind::Decl(..) => None,
18341834
},
18351835
_ => None,
18361836
}

clippy_lints/src/map_unit_fn.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc::hir;
22
use rustc::lint::*;
33
use rustc::ty;
4-
use rustc_errors::{Applicability};
4+
use rustc_errors::Applicability;
55
use syntax::codemap::Span;
66
use crate::utils::{in_macro, iter_input_pats, match_type, method_chain_args, snippet, span_lint_and_then};
77
use crate::utils::paths;
@@ -131,9 +131,9 @@ fn reduce_unit_expression<'a>(cx: &LateContext, expr: &'a hir::Expr) -> Option<S
131131
// If block only contains statements,
132132
// reduce `{ X; }` to `X` or `X;`
133133
match inner_stmt.node {
134-
hir::StmtDecl(ref d, _) => Some(d.span),
135-
hir::StmtExpr(ref e, _) => Some(e.span),
136-
hir::StmtSemi(_, _) => Some(inner_stmt.span),
134+
hir::StmtKind::Decl(ref d, _) => Some(d.span),
135+
hir::StmtKind::Expr(ref e, _) => Some(e.span),
136+
hir::StmtKind::Semi(_, _) => Some(inner_stmt.span),
137137
}
138138
},
139139
_ => {
@@ -247,7 +247,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
247247
return;
248248
}
249249

250-
if let hir::StmtSemi(ref expr, _) = stmt.node {
250+
if let hir::StmtKind::Semi(ref expr, _) = stmt.node {
251251
if let hir::ExprKind::MethodCall(_, _, _) = expr.node {
252252
if let Some(arglists) = method_chain_args(expr, &["map"]) {
253253
lint_map_unit_fn(cx, stmt, expr, arglists[0]);

clippy_lints/src/methods.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ fn lint_clone_on_copy(cx: &LateContext, expr: &hir::Expr, arg: &hir::Expr, arg_t
11391139
_ => {},
11401140
}
11411141
hir::map::NodeStmt(stmt) => {
1142-
if let hir::StmtDecl(ref decl, _) = stmt.node {
1142+
if let hir::StmtKind::Decl(ref decl, _) = stmt.node {
11431143
if let hir::DeclLocal(ref loc) = decl.node {
11441144
if let hir::PatKind::Ref(..) = loc.pat.node {
11451145
// let ref y = *x borrows x, let ref y = x.clone() does not

clippy_lints/src/misc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
269269

270270
fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, s: &'tcx Stmt) {
271271
if_chain! {
272-
if let StmtDecl(ref d, _) = s.node;
272+
if let StmtKind::Decl(ref d, _) = s.node;
273273
if let DeclLocal(ref l) = d.node;
274274
if let PatKind::Binding(an, _, i, None) = l.pat.node;
275275
if let Some(ref init) = l.init;
@@ -303,7 +303,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
303303
}
304304
};
305305
if_chain! {
306-
if let StmtSemi(ref expr, _) = s.node;
306+
if let StmtKind::Semi(ref expr, _) = s.node;
307307
if let ExprKind::Binary(ref binop, ref a, ref b) = expr.node;
308308
if binop.node == BinOpKind::And || binop.node == BinOpKind::Or;
309309
if let Some(sugg) = Sugg::hir_opt(cx, a);

clippy_lints/src/needless_bool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ enum Expression {
184184
fn fetch_bool_block(block: &Block) -> Expression {
185185
match (&*block.stmts, block.expr.as_ref()) {
186186
(&[], Some(e)) => fetch_bool_expr(&**e),
187-
(&[ref e], None) => if let StmtSemi(ref e, _) = e.node {
187+
(&[ref e], None) => if let StmtKind::Semi(ref e, _) = e.node {
188188
if let ExprKind::Ret(_) = e.node {
189189
fetch_bool_expr(&**e)
190190
} else {

clippy_lints/src/needless_pass_by_value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ impl<'a, 'tcx> MovedVariablesCtxt<'a, 'tcx> {
350350
map::Node::NodeStmt(s) => {
351351
// `let <pat> = x;`
352352
if_chain! {
353-
if let StmtDecl(ref decl, _) = s.node;
353+
if let StmtKind::Decl(ref decl, _) = s.node;
354354
if let DeclLocal(ref local) = decl.node;
355355
then {
356356
self.spans_need_deref

0 commit comments

Comments
 (0)