Skip to content

Commit 2ca58e7

Browse files
committed
Auto merge of #5732 - bjorn3:patch-1, r=flip1995
Rename collapsable_if fix suggestion to "collapse nested if block" The name "try" is confusing when shown as quick fix by rust-analyzer changelog: Rename `collapsable_if` fix suggestion to "collapse nested if block"
2 parents 12df638 + ff796b6 commit 2ca58e7

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

clippy_lints/src/collapsible_if.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ fn check_collapsible_maybe_if_let(cx: &EarlyContext<'_>, else_: &ast::Expr) {
115115
COLLAPSIBLE_IF,
116116
block.span,
117117
"this `else { if .. }` block can be collapsed",
118-
"try",
118+
"collapse nested if block",
119119
snippet_block_with_applicability(cx, else_.span, "..", Some(block.span), &mut applicability).into_owned(),
120120
applicability,
121121
);
@@ -142,7 +142,7 @@ fn check_collapsible_no_if_let(cx: &EarlyContext<'_>, expr: &ast::Expr, check: &
142142
let rhs = Sugg::ast(cx, check_inner, "..");
143143
diag.span_suggestion(
144144
expr.span,
145-
"try",
145+
"collapse nested if block",
146146
format!(
147147
"if {} {}",
148148
lhs.and(&rhs),

tests/ui/collapsible_else_if.stderr

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ LL | | }
1010
| |_____^
1111
|
1212
= note: `-D clippy::collapsible-if` implied by `-D warnings`
13-
help: try
13+
help: collapse nested if block
1414
|
1515
LL | } else if y == "world" {
1616
LL | println!("world!")
@@ -28,7 +28,7 @@ LL | | }
2828
LL | | }
2929
| |_____^
3030
|
31-
help: try
31+
help: collapse nested if block
3232
|
3333
LL | } else if let Some(42) = Some(42) {
3434
LL | println!("world!")
@@ -48,7 +48,7 @@ LL | | }
4848
LL | | }
4949
| |_____^
5050
|
51-
help: try
51+
help: collapse nested if block
5252
|
5353
LL | } else if y == "world" {
5454
LL | println!("world")
@@ -71,7 +71,7 @@ LL | | }
7171
LL | | }
7272
| |_____^
7373
|
74-
help: try
74+
help: collapse nested if block
7575
|
7676
LL | } else if let Some(42) = Some(42) {
7777
LL | println!("world")
@@ -94,7 +94,7 @@ LL | | }
9494
LL | | }
9595
| |_____^
9696
|
97-
help: try
97+
help: collapse nested if block
9898
|
9999
LL | } else if let Some(42) = Some(42) {
100100
LL | println!("world")
@@ -117,7 +117,7 @@ LL | | }
117117
LL | | }
118118
| |_____^
119119
|
120-
help: try
120+
help: collapse nested if block
121121
|
122122
LL | } else if x == "hello" {
123123
LL | println!("world")
@@ -140,7 +140,7 @@ LL | | }
140140
LL | | }
141141
| |_____^
142142
|
143-
help: try
143+
help: collapse nested if block
144144
|
145145
LL | } else if let Some(42) = Some(42) {
146146
LL | println!("world")

tests/ui/collapsible_if.stderr

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | | }
99
| |_____^
1010
|
1111
= note: `-D clippy::collapsible-if` implied by `-D warnings`
12-
help: try
12+
help: collapse nested if block
1313
|
1414
LL | if x == "hello" && y == "world" {
1515
LL | println!("Hello world!");
@@ -26,7 +26,7 @@ LL | | }
2626
LL | | }
2727
| |_____^
2828
|
29-
help: try
29+
help: collapse nested if block
3030
|
3131
LL | if (x == "hello" || x == "world") && (y == "world" || y == "hello") {
3232
LL | println!("Hello world!");
@@ -43,7 +43,7 @@ LL | | }
4343
LL | | }
4444
| |_____^
4545
|
46-
help: try
46+
help: collapse nested if block
4747
|
4848
LL | if x == "hello" && x == "world" && (y == "world" || y == "hello") {
4949
LL | println!("Hello world!");
@@ -60,7 +60,7 @@ LL | | }
6060
LL | | }
6161
| |_____^
6262
|
63-
help: try
63+
help: collapse nested if block
6464
|
6565
LL | if (x == "hello" || x == "world") && y == "world" && y == "hello" {
6666
LL | println!("Hello world!");
@@ -77,7 +77,7 @@ LL | | }
7777
LL | | }
7878
| |_____^
7979
|
80-
help: try
80+
help: collapse nested if block
8181
|
8282
LL | if x == "hello" && x == "world" && y == "world" && y == "hello" {
8383
LL | println!("Hello world!");
@@ -94,7 +94,7 @@ LL | | }
9494
LL | | }
9595
| |_____^
9696
|
97-
help: try
97+
help: collapse nested if block
9898
|
9999
LL | if 42 == 1337 && 'a' != 'A' {
100100
LL | println!("world!")
@@ -111,7 +111,7 @@ LL | | }
111111
LL | | }
112112
| |_____^
113113
|
114-
help: try
114+
help: collapse nested if block
115115
|
116116
LL | if x == "hello" && y == "world" { // Collapsible
117117
LL | println!("Hello world!");

0 commit comments

Comments
 (0)