From f4eb6bd709cedf9e0b0baf904e06cbebcc884c64 Mon Sep 17 00:00:00 2001 From: Gabriel Goller Date: Thu, 15 Feb 2024 11:05:25 +0100 Subject: [PATCH 1/2] fix: documentation of `blocks_in_conditions` lint Updated documentation + example of `blocks_in_conditions` lint, which has been updated recently to include `match` statements as well. --- clippy_lints/src/blocks_in_conditions.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/clippy_lints/src/blocks_in_conditions.rs b/clippy_lints/src/blocks_in_conditions.rs index eae87db26c6f..62ef810f12b9 100644 --- a/clippy_lints/src/blocks_in_conditions.rs +++ b/clippy_lints/src/blocks_in_conditions.rs @@ -13,7 +13,7 @@ declare_clippy_lint! { /// ### What it does - /// Checks for `if` conditions that use blocks containing an + /// Checks for `if` and `match` conditions that use blocks containing an /// expression, statements or conditions that use closures with blocks. /// /// ### Why is this bad? @@ -25,6 +25,8 @@ /// if { true } { /* ... */ } /// /// if { let x = somefunc(); x } { /* ... */ } + /// + /// match { let e = somefunc(); e } { /* ... */ } /// ``` /// /// Use instead: @@ -34,6 +36,9 @@ /// /// let res = { let x = somefunc(); x }; /// if res { /* ... */ } + /// + /// let res = { let e = somefunc(); e }; + /// match res { /* ... */ } /// ``` #[clippy::version = "1.45.0"] pub BLOCKS_IN_CONDITIONS, From 183fade0ef7a5b98b81a9a054b6ff70d3cf3532b Mon Sep 17 00:00:00 2001 From: Gabriel Goller Date: Thu, 15 Feb 2024 11:44:22 +0100 Subject: [PATCH 2/2] fix: example in blocks_in_conditions lint Example in blocks_in_conditions lint didn't compile. --- clippy_lints/src/blocks_in_conditions.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/clippy_lints/src/blocks_in_conditions.rs b/clippy_lints/src/blocks_in_conditions.rs index 62ef810f12b9..2eb0dac97425 100644 --- a/clippy_lints/src/blocks_in_conditions.rs +++ b/clippy_lints/src/blocks_in_conditions.rs @@ -26,7 +26,10 @@ /// /// if { let x = somefunc(); x } { /* ... */ } /// - /// match { let e = somefunc(); e } { /* ... */ } + /// match { let e = somefunc(); e } { + /// // ... + /// # _ => {} + /// } /// ``` /// /// Use instead: @@ -38,7 +41,10 @@ /// if res { /* ... */ } /// /// let res = { let e = somefunc(); e }; - /// match res { /* ... */ } + /// match res { + /// // ... + /// # _ => {} + /// } /// ``` #[clippy::version = "1.45.0"] pub BLOCKS_IN_CONDITIONS,