Skip to content

Commit 36c5b9f

Browse files
committed
head expression -> scrutinee + similar fixes
1 parent e43f99c commit 36c5b9f

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

src/librustc/hir/intravisit.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1011,22 +1011,22 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
10111011
visitor.visit_expr(subexpression);
10121012
visitor.visit_ty(typ)
10131013
}
1014-
ExprKind::If(ref head_expression, ref if_block, ref optional_else) => {
1015-
visitor.visit_expr(head_expression);
1014+
ExprKind::If(ref scrutinee, ref if_block, ref optional_else) => {
1015+
visitor.visit_expr(scrutinee);
10161016
visitor.visit_expr(if_block);
10171017
walk_list!(visitor, visit_expr, optional_else);
10181018
}
1019-
ExprKind::While(ref subexpression, ref block, ref opt_label) => {
1019+
ExprKind::While(ref scrutinee, ref block, ref opt_label) => {
10201020
walk_list!(visitor, visit_label, opt_label);
1021-
visitor.visit_expr(subexpression);
1021+
visitor.visit_expr(scrutinee);
10221022
visitor.visit_block(block);
10231023
}
10241024
ExprKind::Loop(ref block, ref opt_label, _) => {
10251025
walk_list!(visitor, visit_label, opt_label);
10261026
visitor.visit_block(block);
10271027
}
1028-
ExprKind::Match(ref subexpression, ref arms, _) => {
1029-
visitor.visit_expr(subexpression);
1028+
ExprKind::Match(ref scrutinee, ref arms, _) => {
1029+
visitor.visit_expr(scrutinee);
10301030
walk_list!(visitor, visit_arm, arms);
10311031
}
10321032
ExprKind::Closure(_, ref function_declaration, body, _fn_decl_span, _gen) => {

src/librustc_lint/unused.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,10 @@ impl EarlyLintPass for UnusedParens {
355355
let (value, msg, followed_by_block) = match e.node {
356356
If(ref cond, ..) => (cond, "`if` condition", true),
357357
While(ref cond, ..) => (cond, "`while` condition", true),
358-
IfLet(_, ref cond, ..) => (cond, "`if let` head expression", true),
359-
WhileLet(_, ref cond, ..) => (cond, "`while let` head expression", true),
360-
ForLoop(_, ref cond, ..) => (cond, "`for` head expression", true),
361-
Match(ref head, _) => (head, "`match` head expression", true),
358+
IfLet(_, ref cond, ..) => (cond, "`if let` scrutinee", true),
359+
WhileLet(_, ref cond, ..) => (cond, "`while let` scrutinee", true),
360+
ForLoop(_, ref cond, ..) => (cond, "`for` scrutinee", true),
361+
Match(ref head, _) => (head, "`match` scrutinee", true),
362362
Ret(Some(ref value)) => (value, "`return` value", false),
363363
Assign(_, ref value) => (value, "assigned value", false),
364364
AssignOp(.., ref value) => (value, "assigned value", false),

src/test/ui/lint/lint-unnecessary-parens.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ fn main() {
1919

2020
if (true) {} //~ ERROR unnecessary parentheses around `if` condition
2121
while (true) {} //~ ERROR unnecessary parentheses around `while` condition
22-
match (true) { //~ ERROR unnecessary parentheses around `match` head expression
22+
match (true) { //~ ERROR unnecessary parentheses around `match` scrutinee
2323
_ => {}
2424
}
25-
if let 1 = (1) {} //~ ERROR unnecessary parentheses around `if let` head expression
26-
while let 1 = (2) {} //~ ERROR unnecessary parentheses around `while let` head expression
25+
if let 1 = (1) {} //~ ERROR unnecessary parentheses around `if let` scrutinee
26+
while let 1 = (2) {} //~ ERROR unnecessary parentheses around `while let` scrutinee
2727
let v = X { y: false };
2828
// struct lits needs parens, so these shouldn't warn.
2929
if (v == X { y: true }) {}

src/test/ui/lint/lint-unnecessary-parens.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ error: unnecessary parentheses around `while` condition
3434
LL | while (true) {}
3535
| ^^^^^^ help: remove these parentheses
3636

37-
error: unnecessary parentheses around `match` head expression
37+
error: unnecessary parentheses around `match` scrutinee
3838
--> $DIR/lint-unnecessary-parens.rs:22:11
3939
|
4040
LL | match (true) {
4141
| ^^^^^^ help: remove these parentheses
4242

43-
error: unnecessary parentheses around `if let` head expression
43+
error: unnecessary parentheses around `if let` scrutinee
4444
--> $DIR/lint-unnecessary-parens.rs:25:16
4545
|
4646
LL | if let 1 = (1) {}
4747
| ^^^ help: remove these parentheses
4848

49-
error: unnecessary parentheses around `while let` head expression
49+
error: unnecessary parentheses around `while let` scrutinee
5050
--> $DIR/lint-unnecessary-parens.rs:26:19
5151
|
5252
LL | while let 1 = (2) {}

0 commit comments

Comments
 (0)