Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename collapsable_if fix suggestion to "collapse nested if block" #5732

Merged
merged 1 commit into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions clippy_lints/src/collapsible_if.rs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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