From bab327c725bf084d0ec5c27527588b71b0a1ab1d Mon Sep 17 00:00:00 2001 From: Bastian Kauschke Date: Tue, 31 Mar 2020 18:42:54 +0200 Subject: [PATCH] update unused_braces wording --- src/librustc_lint/unused.rs | 23 +++++++++---------- src/test/ui/lint/lint-unnecessary-parens.rs | 6 ++--- .../ui/lint/lint-unnecessary-parens.stderr | 6 ++--- src/test/ui/lint/unused_braces.stderr | 2 +- ...nused_parens_remove_json_suggestion.stderr | 4 ++-- 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 67e86c480a30f..51f91aa6fb792 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -327,11 +327,11 @@ enum UnusedDelimsCtx { AssignedValue, IfCond, WhileCond, - ForHeadExpr, - MatchHeadExpr, + ForIterExpr, + MatchScrutineeExpr, ReturnValue, BlockRetValue, - LetHeadExpr, + LetScrutineeExpr, ArrayLenExpr, AnonConst, } @@ -344,11 +344,11 @@ impl From for &'static str { UnusedDelimsCtx::AssignedValue => "assigned value", UnusedDelimsCtx::IfCond => "`if` condition", UnusedDelimsCtx::WhileCond => "`while` condition", - UnusedDelimsCtx::ForHeadExpr => "`for` head expression", - UnusedDelimsCtx::MatchHeadExpr => "`match` head expression", + UnusedDelimsCtx::ForIterExpr => "`for` iterator expression", + UnusedDelimsCtx::MatchScrutineeExpr => "`match` scrutinee expression", UnusedDelimsCtx::ReturnValue => "`return` value", UnusedDelimsCtx::BlockRetValue => "block return value", - UnusedDelimsCtx::LetHeadExpr => "`let` head expression", + UnusedDelimsCtx::LetScrutineeExpr => "`let` scrutinee expression", UnusedDelimsCtx::ArrayLenExpr | UnusedDelimsCtx::AnonConst => "const expression", } } @@ -399,7 +399,6 @@ trait UnusedDelimLint { self.emit_unused_delims(cx, value.span, &expr_text, ctx.into(), keep_space); } - /// emits a lint fn emit_unused_delims( &self, cx: &EarlyContext<'_>, @@ -471,12 +470,12 @@ trait UnusedDelimLint { } ForLoop(_, ref cond, ref block, ..) => { - (cond, UnusedDelimsCtx::ForHeadExpr, true, None, Some(block.span.lo())) + (cond, UnusedDelimsCtx::ForIterExpr, true, None, Some(block.span.lo())) } Match(ref head, _) => { let left = e.span.lo() + rustc_span::BytePos(5); - (head, UnusedDelimsCtx::MatchHeadExpr, true, Some(left), None) + (head, UnusedDelimsCtx::MatchScrutineeExpr, true, Some(left), None) } Ret(Some(ref value)) => { @@ -597,7 +596,7 @@ impl UnusedDelimLint for UnusedParens { self.check_unused_delims_expr( cx, expr, - UnusedDelimsCtx::LetHeadExpr, + UnusedDelimsCtx::LetScrutineeExpr, followed_by_block, None, None, @@ -732,7 +731,7 @@ impl EarlyLintPass for UnusedParens { declare_lint! { pub(super) UNUSED_BRACES, Warn, - "suggests removing `{` and `}` in case they are not necessary" + "unnecessary braces around an expression" } declare_lint_pass!(UnusedBraces => [UNUSED_BRACES]); @@ -804,7 +803,7 @@ impl UnusedDelimLint for UnusedBraces { self.check_unused_delims_expr( cx, expr, - UnusedDelimsCtx::LetHeadExpr, + UnusedDelimsCtx::LetScrutineeExpr, followed_by_block, None, None, diff --git a/src/test/ui/lint/lint-unnecessary-parens.rs b/src/test/ui/lint/lint-unnecessary-parens.rs index 5ce1f57608132..623cd04d9bce3 100644 --- a/src/test/ui/lint/lint-unnecessary-parens.rs +++ b/src/test/ui/lint/lint-unnecessary-parens.rs @@ -48,11 +48,11 @@ fn main() { if (true) {} //~ ERROR unnecessary parentheses around `if` condition while (true) {} //~ ERROR unnecessary parentheses around `while` condition //~^ WARN denote infinite loops with - match (true) { //~ ERROR unnecessary parentheses around `match` head expression + match (true) { //~ ERROR unnecessary parentheses around `match` scrutinee expression _ => {} } - if let 1 = (1) {} //~ ERROR unnecessary parentheses around `let` head expression - while let 1 = (2) {} //~ ERROR unnecessary parentheses around `let` head expression + if let 1 = (1) {} //~ ERROR unnecessary parentheses around `let` scrutinee expression + while let 1 = (2) {} //~ ERROR unnecessary parentheses around `let` scrutinee expression 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 8858c95327322..15184ba36ae85 100644 --- a/src/test/ui/lint/lint-unnecessary-parens.stderr +++ b/src/test/ui/lint/lint-unnecessary-parens.stderr @@ -72,19 +72,19 @@ LL | while (true) {} | = note: `#[warn(while_true)]` on by default -error: unnecessary parentheses around `match` head expression +error: unnecessary parentheses around `match` scrutinee expression --> $DIR/lint-unnecessary-parens.rs:51:11 | LL | match (true) { | ^^^^^^ help: remove these parentheses -error: unnecessary parentheses around `let` head expression +error: unnecessary parentheses around `let` scrutinee expression --> $DIR/lint-unnecessary-parens.rs:54:16 | LL | if let 1 = (1) {} | ^^^ help: remove these parentheses -error: unnecessary parentheses around `let` head expression +error: unnecessary parentheses around `let` scrutinee expression --> $DIR/lint-unnecessary-parens.rs:55:19 | LL | while let 1 = (2) {} diff --git a/src/test/ui/lint/unused_braces.stderr b/src/test/ui/lint/unused_braces.stderr index add0611eac29e..72f425ffc3e01 100644 --- a/src/test/ui/lint/unused_braces.stderr +++ b/src/test/ui/lint/unused_braces.stderr @@ -22,7 +22,7 @@ note: the lint level is defined here LL | #![warn(unused_braces, unused_parens)] | ^^^^^^^^^^^^^ -warning: unnecessary braces around `let` head expression +warning: unnecessary braces around `let` scrutinee expression --> $DIR/unused_braces.rs:11:16 | LL | if let 7 = { 7 } { diff --git a/src/test/ui/lint/unused_parens_remove_json_suggestion.stderr b/src/test/ui/lint/unused_parens_remove_json_suggestion.stderr index c3bf77a3a6f2d..5fb67fd7c95a3 100644 --- a/src/test/ui/lint/unused_parens_remove_json_suggestion.stderr +++ b/src/test/ui/lint/unused_parens_remove_json_suggestion.stderr @@ -46,14 +46,14 @@ LL | while(true && false) { | ^^^^^^^^^^^^^^^ help: remove these parentheses "} -{"message":"unnecessary parentheses around `for` head expression","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":987,"byte_end":995,"line_start":44,"line_end":44,"column_start":18,"column_end":26,"is_primary":true,"text":[{"text":" for _ in (0 .. 3){ +{"message":"unnecessary parentheses around `for` iterator expression","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":987,"byte_end":995,"line_start":44,"line_end":44,"column_start":18,"column_end":26,"is_primary":true,"text":[{"text":" for _ in (0 .. 3){ --> $DIR/unused_parens_remove_json_suggestion.rs:44:18 | LL | for _ in (0 .. 3){ | ^^^^^^^^ help: remove these parentheses "} -{"message":"unnecessary parentheses around `for` head expression","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":1088,"byte_end":1096,"line_start":49,"line_end":49,"column_start":14,"column_end":22,"is_primary":true,"text":[{"text":" for _ in (0 .. 3) { +{"message":"unnecessary parentheses around `for` iterator expression","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":1088,"byte_end":1096,"line_start":49,"line_end":49,"column_start":14,"column_end":22,"is_primary":true,"text":[{"text":" for _ in (0 .. 3) { --> $DIR/unused_parens_remove_json_suggestion.rs:49:14 | LL | for _ in (0 .. 3) {