Skip to content

Commit bab327c

Browse files
committed
update unused_braces wording
1 parent bcf35b1 commit bab327c

5 files changed

+20
-21
lines changed

src/librustc_lint/unused.rs

+11-12
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,11 @@ enum UnusedDelimsCtx {
327327
AssignedValue,
328328
IfCond,
329329
WhileCond,
330-
ForHeadExpr,
331-
MatchHeadExpr,
330+
ForIterExpr,
331+
MatchScrutineeExpr,
332332
ReturnValue,
333333
BlockRetValue,
334-
LetHeadExpr,
334+
LetScrutineeExpr,
335335
ArrayLenExpr,
336336
AnonConst,
337337
}
@@ -344,11 +344,11 @@ impl From<UnusedDelimsCtx> for &'static str {
344344
UnusedDelimsCtx::AssignedValue => "assigned value",
345345
UnusedDelimsCtx::IfCond => "`if` condition",
346346
UnusedDelimsCtx::WhileCond => "`while` condition",
347-
UnusedDelimsCtx::ForHeadExpr => "`for` head expression",
348-
UnusedDelimsCtx::MatchHeadExpr => "`match` head expression",
347+
UnusedDelimsCtx::ForIterExpr => "`for` iterator expression",
348+
UnusedDelimsCtx::MatchScrutineeExpr => "`match` scrutinee expression",
349349
UnusedDelimsCtx::ReturnValue => "`return` value",
350350
UnusedDelimsCtx::BlockRetValue => "block return value",
351-
UnusedDelimsCtx::LetHeadExpr => "`let` head expression",
351+
UnusedDelimsCtx::LetScrutineeExpr => "`let` scrutinee expression",
352352
UnusedDelimsCtx::ArrayLenExpr | UnusedDelimsCtx::AnonConst => "const expression",
353353
}
354354
}
@@ -399,7 +399,6 @@ trait UnusedDelimLint {
399399
self.emit_unused_delims(cx, value.span, &expr_text, ctx.into(), keep_space);
400400
}
401401

402-
/// emits a lint
403402
fn emit_unused_delims(
404403
&self,
405404
cx: &EarlyContext<'_>,
@@ -471,12 +470,12 @@ trait UnusedDelimLint {
471470
}
472471

473472
ForLoop(_, ref cond, ref block, ..) => {
474-
(cond, UnusedDelimsCtx::ForHeadExpr, true, None, Some(block.span.lo()))
473+
(cond, UnusedDelimsCtx::ForIterExpr, true, None, Some(block.span.lo()))
475474
}
476475

477476
Match(ref head, _) => {
478477
let left = e.span.lo() + rustc_span::BytePos(5);
479-
(head, UnusedDelimsCtx::MatchHeadExpr, true, Some(left), None)
478+
(head, UnusedDelimsCtx::MatchScrutineeExpr, true, Some(left), None)
480479
}
481480

482481
Ret(Some(ref value)) => {
@@ -597,7 +596,7 @@ impl UnusedDelimLint for UnusedParens {
597596
self.check_unused_delims_expr(
598597
cx,
599598
expr,
600-
UnusedDelimsCtx::LetHeadExpr,
599+
UnusedDelimsCtx::LetScrutineeExpr,
601600
followed_by_block,
602601
None,
603602
None,
@@ -732,7 +731,7 @@ impl EarlyLintPass for UnusedParens {
732731
declare_lint! {
733732
pub(super) UNUSED_BRACES,
734733
Warn,
735-
"suggests removing `{` and `}` in case they are not necessary"
734+
"unnecessary braces around an expression"
736735
}
737736

738737
declare_lint_pass!(UnusedBraces => [UNUSED_BRACES]);
@@ -804,7 +803,7 @@ impl UnusedDelimLint for UnusedBraces {
804803
self.check_unused_delims_expr(
805804
cx,
806805
expr,
807-
UnusedDelimsCtx::LetHeadExpr,
806+
UnusedDelimsCtx::LetScrutineeExpr,
808807
followed_by_block,
809808
None,
810809
None,

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ fn main() {
4848
if (true) {} //~ ERROR unnecessary parentheses around `if` condition
4949
while (true) {} //~ ERROR unnecessary parentheses around `while` condition
5050
//~^ WARN denote infinite loops with
51-
match (true) { //~ ERROR unnecessary parentheses around `match` head expression
51+
match (true) { //~ ERROR unnecessary parentheses around `match` scrutinee expression
5252
_ => {}
5353
}
54-
if let 1 = (1) {} //~ ERROR unnecessary parentheses around `let` head expression
55-
while let 1 = (2) {} //~ ERROR unnecessary parentheses around `let` head expression
54+
if let 1 = (1) {} //~ ERROR unnecessary parentheses around `let` scrutinee expression
55+
while let 1 = (2) {} //~ ERROR unnecessary parentheses around `let` scrutinee expression
5656
let v = X { y: false };
5757
// struct lits needs parens, so these shouldn't warn.
5858
if (v == X { y: true }) {}

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,19 @@ LL | while (true) {}
7272
|
7373
= note: `#[warn(while_true)]` on by default
7474

75-
error: unnecessary parentheses around `match` head expression
75+
error: unnecessary parentheses around `match` scrutinee expression
7676
--> $DIR/lint-unnecessary-parens.rs:51:11
7777
|
7878
LL | match (true) {
7979
| ^^^^^^ help: remove these parentheses
8080

81-
error: unnecessary parentheses around `let` head expression
81+
error: unnecessary parentheses around `let` scrutinee expression
8282
--> $DIR/lint-unnecessary-parens.rs:54:16
8383
|
8484
LL | if let 1 = (1) {}
8585
| ^^^ help: remove these parentheses
8686

87-
error: unnecessary parentheses around `let` head expression
87+
error: unnecessary parentheses around `let` scrutinee expression
8888
--> $DIR/lint-unnecessary-parens.rs:55:19
8989
|
9090
LL | while let 1 = (2) {}

src/test/ui/lint/unused_braces.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ note: the lint level is defined here
2222
LL | #![warn(unused_braces, unused_parens)]
2323
| ^^^^^^^^^^^^^
2424

25-
warning: unnecessary braces around `let` head expression
25+
warning: unnecessary braces around `let` scrutinee expression
2626
--> $DIR/unused_braces.rs:11:16
2727
|
2828
LL | if let 7 = { 7 } {

src/test/ui/lint/unused_parens_remove_json_suggestion.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ LL | while(true && false) {
4646
| ^^^^^^^^^^^^^^^ help: remove these parentheses
4747

4848
"}
49-
{"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){
49+
{"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){
5050
--> $DIR/unused_parens_remove_json_suggestion.rs:44:18
5151
|
5252
LL | for _ in (0 .. 3){
5353
| ^^^^^^^^ help: remove these parentheses
5454

5555
"}
56-
{"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) {
56+
{"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) {
5757
--> $DIR/unused_parens_remove_json_suggestion.rs:49:14
5858
|
5959
LL | for _ in (0 .. 3) {

0 commit comments

Comments
 (0)