Skip to content

Commit

Permalink
Rename collapsable_if fix suggestion to "collapse nested if block"
Browse files Browse the repository at this point in the history
The name "try" is confusing when shown as quick fix by rust-analyzer
  • Loading branch information
bjorn3 committed Jul 13, 2020
1 parent fa4a737 commit ff796b6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions clippy_lints/src/collapsible_if.rs
Expand Up @@ -115,7 +115,7 @@ fn check_collapsible_maybe_if_let(cx: &EarlyContext<'_>, else_: &ast::Expr) {
COLLAPSIBLE_IF,
block.span,
"this `else { if .. }` block can be collapsed",
"try",
"collapse nested if block",
snippet_block_with_applicability(cx, else_.span, "..", Some(block.span), &mut applicability).into_owned(),
applicability,
);
Expand All @@ -142,7 +142,7 @@ fn check_collapsible_no_if_let(cx: &EarlyContext<'_>, expr: &ast::Expr, check: &
let rhs = Sugg::ast(cx, check_inner, "..");
diag.span_suggestion(
expr.span,
"try",
"collapse nested if block",
format!(
"if {} {}",
lhs.and(&rhs),
Expand Down
14 changes: 7 additions & 7 deletions tests/ui/collapsible_else_if.stderr
Expand Up @@ -10,7 +10,7 @@ LL | | }
| |_____^
|
= note: `-D clippy::collapsible-if` implied by `-D warnings`
help: try
help: collapse nested if block
|
LL | } else if y == "world" {
LL | println!("world!")
Expand All @@ -28,7 +28,7 @@ LL | | }
LL | | }
| |_____^
|
help: try
help: collapse nested if block
|
LL | } else if let Some(42) = Some(42) {
LL | println!("world!")
Expand All @@ -48,7 +48,7 @@ LL | | }
LL | | }
| |_____^
|
help: try
help: collapse nested if block
|
LL | } else if y == "world" {
LL | println!("world")
Expand All @@ -71,7 +71,7 @@ LL | | }
LL | | }
| |_____^
|
help: try
help: collapse nested if block
|
LL | } else if let Some(42) = Some(42) {
LL | println!("world")
Expand All @@ -94,7 +94,7 @@ LL | | }
LL | | }
| |_____^
|
help: try
help: collapse nested if block
|
LL | } else if let Some(42) = Some(42) {
LL | println!("world")
Expand All @@ -117,7 +117,7 @@ LL | | }
LL | | }
| |_____^
|
help: try
help: collapse nested if block
|
LL | } else if x == "hello" {
LL | println!("world")
Expand All @@ -140,7 +140,7 @@ LL | | }
LL | | }
| |_____^
|
help: try
help: collapse nested if block
|
LL | } else if let Some(42) = Some(42) {
LL | println!("world")
Expand Down
14 changes: 7 additions & 7 deletions tests/ui/collapsible_if.stderr
Expand Up @@ -9,7 +9,7 @@ LL | | }
| |_____^
|
= note: `-D clippy::collapsible-if` implied by `-D warnings`
help: try
help: collapse nested if block
|
LL | if x == "hello" && y == "world" {
LL | println!("Hello world!");
Expand All @@ -26,7 +26,7 @@ LL | | }
LL | | }
| |_____^
|
help: try
help: collapse nested if block
|
LL | if (x == "hello" || x == "world") && (y == "world" || y == "hello") {
LL | println!("Hello world!");
Expand All @@ -43,7 +43,7 @@ LL | | }
LL | | }
| |_____^
|
help: try
help: collapse nested if block
|
LL | if x == "hello" && x == "world" && (y == "world" || y == "hello") {
LL | println!("Hello world!");
Expand All @@ -60,7 +60,7 @@ LL | | }
LL | | }
| |_____^
|
help: try
help: collapse nested if block
|
LL | if (x == "hello" || x == "world") && y == "world" && y == "hello" {
LL | println!("Hello world!");
Expand All @@ -77,7 +77,7 @@ LL | | }
LL | | }
| |_____^
|
help: try
help: collapse nested if block
|
LL | if x == "hello" && x == "world" && y == "world" && y == "hello" {
LL | println!("Hello world!");
Expand All @@ -94,7 +94,7 @@ LL | | }
LL | | }
| |_____^
|
help: try
help: collapse nested if block
|
LL | if 42 == 1337 && 'a' != 'A' {
LL | println!("world!")
Expand All @@ -111,7 +111,7 @@ LL | | }
LL | | }
| |_____^
|
help: try
help: collapse nested if block
|
LL | if x == "hello" && y == "world" { // Collapsible
LL | println!("Hello world!");
Expand Down

0 comments on commit ff796b6

Please sign in to comment.