diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index c2265eeb30d74..47fb66828c2a3 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -1011,22 +1011,22 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) { visitor.visit_expr(subexpression); visitor.visit_ty(typ) } - ExprKind::If(ref head_expression, ref if_block, ref optional_else) => { - visitor.visit_expr(head_expression); + ExprKind::If(ref scrutinee, ref if_block, ref optional_else) => { + visitor.visit_expr(scrutinee); visitor.visit_expr(if_block); walk_list!(visitor, visit_expr, optional_else); } - ExprKind::While(ref subexpression, ref block, ref opt_label) => { + ExprKind::While(ref scrutinee, ref block, ref opt_label) => { walk_list!(visitor, visit_label, opt_label); - visitor.visit_expr(subexpression); + visitor.visit_expr(scrutinee); visitor.visit_block(block); } ExprKind::Loop(ref block, ref opt_label, _) => { walk_list!(visitor, visit_label, opt_label); visitor.visit_block(block); } - ExprKind::Match(ref subexpression, ref arms, _) => { - visitor.visit_expr(subexpression); + ExprKind::Match(ref scrutinee, ref arms, _) => { + visitor.visit_expr(scrutinee); walk_list!(visitor, visit_arm, arms); } ExprKind::Closure(_, ref function_declaration, body, _fn_decl_span, _gen) => { diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index d41d97f58bcbe..9ead0a22c7fc6 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -355,10 +355,10 @@ impl EarlyLintPass for UnusedParens { let (value, msg, followed_by_block) = match e.node { If(ref cond, ..) => (cond, "`if` condition", true), While(ref cond, ..) => (cond, "`while` condition", true), - IfLet(_, ref cond, ..) => (cond, "`if let` head expression", true), - WhileLet(_, ref cond, ..) => (cond, "`while let` head expression", true), - ForLoop(_, ref cond, ..) => (cond, "`for` head expression", true), - Match(ref head, _) => (head, "`match` head expression", true), + IfLet(_, ref cond, ..) => (cond, "`if let` scrutinee", true), + WhileLet(_, ref cond, ..) => (cond, "`while let` scrutinee", true), + ForLoop(_, ref cond, ..) => (cond, "`for` scrutinee", true), + Match(ref head, _) => (head, "`match` scrutinee", true), Ret(Some(ref value)) => (value, "`return` value", false), Assign(_, ref value) => (value, "assigned value", false), AssignOp(.., ref value) => (value, "assigned value", false), diff --git a/src/test/ui/lint/lint-unnecessary-parens.rs b/src/test/ui/lint/lint-unnecessary-parens.rs index dc74d69bd8d54..59d5f7174f29f 100644 --- a/src/test/ui/lint/lint-unnecessary-parens.rs +++ b/src/test/ui/lint/lint-unnecessary-parens.rs @@ -19,11 +19,11 @@ fn main() { if (true) {} //~ ERROR unnecessary parentheses around `if` condition while (true) {} //~ ERROR unnecessary parentheses around `while` condition - match (true) { //~ ERROR unnecessary parentheses around `match` head expression + match (true) { //~ ERROR unnecessary parentheses around `match` scrutinee _ => {} } - if let 1 = (1) {} //~ ERROR unnecessary parentheses around `if let` head expression - while let 1 = (2) {} //~ ERROR unnecessary parentheses around `while let` head expression + if let 1 = (1) {} //~ ERROR unnecessary parentheses around `if let` scrutinee + while let 1 = (2) {} //~ ERROR unnecessary parentheses around `while let` scrutinee let v = X { y: false }; // struct lits needs parens, so these shouldn't warn. if (v == X { y: true }) {} diff --git a/src/test/ui/lint/lint-unnecessary-parens.stderr b/src/test/ui/lint/lint-unnecessary-parens.stderr index fe2ee38eb42a3..2533063a4bd16 100644 --- a/src/test/ui/lint/lint-unnecessary-parens.stderr +++ b/src/test/ui/lint/lint-unnecessary-parens.stderr @@ -34,19 +34,19 @@ error: unnecessary parentheses around `while` condition LL | while (true) {} | ^^^^^^ help: remove these parentheses -error: unnecessary parentheses around `match` head expression +error: unnecessary parentheses around `match` scrutinee --> $DIR/lint-unnecessary-parens.rs:22:11 | LL | match (true) { | ^^^^^^ help: remove these parentheses -error: unnecessary parentheses around `if let` head expression +error: unnecessary parentheses around `if let` scrutinee --> $DIR/lint-unnecessary-parens.rs:25:16 | LL | if let 1 = (1) {} | ^^^ help: remove these parentheses -error: unnecessary parentheses around `while let` head expression +error: unnecessary parentheses around `while let` scrutinee --> $DIR/lint-unnecessary-parens.rs:26:19 | LL | while let 1 = (2) {}