From 20ec2ceab8450e1a0611fbc54a17a03ffc0bd39b Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 5 Dec 2022 11:02:10 +0100 Subject: [PATCH] Add test case for blocks with semicolon inside and outside a block --- clippy_lints/src/semicolon_block.rs | 9 ++++++--- tests/ui/semicolon_inside_block.fixed | 2 ++ tests/ui/semicolon_inside_block.rs | 2 ++ tests/ui/semicolon_outside_block.fixed | 2 ++ tests/ui/semicolon_outside_block.rs | 2 ++ 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/clippy_lints/src/semicolon_block.rs b/clippy_lints/src/semicolon_block.rs index d3cab68137c..8f1d1490e1f 100644 --- a/clippy_lints/src/semicolon_block.rs +++ b/clippy_lints/src/semicolon_block.rs @@ -8,11 +8,13 @@ use rustc_span::Span; declare_clippy_lint! { /// ### What it does /// - /// Suggests moving the semicolon from a block inside of the block to its kast expression. + /// Suggests moving the semicolon after a block to the inside of the block, after its last + /// expression. /// /// ### Why is this bad? /// - /// For consistency it's best to have the semicolon inside/outside the block. Either way is fine and this lint suggests inside the block. + /// For consistency it's best to have the semicolon inside/outside the block. Either way is fine + /// and this lint suggests inside the block. /// Take a look at `semicolon_outside_block` for the other alternative. /// /// ### Example @@ -40,7 +42,8 @@ declare_clippy_lint! { /// /// ### Why is this bad? /// - /// For consistency it's best to have the semicolon inside/outside the block. Either way is fine and this lint suggests outside the block. + /// For consistency it's best to have the semicolon inside/outside the block. Either way is fine + /// and this lint suggests outside the block. /// Take a look at `semicolon_inside_block` for the other alternative. /// /// ### Example diff --git a/tests/ui/semicolon_inside_block.fixed b/tests/ui/semicolon_inside_block.fixed index 4cd112dd5e1..42e97e1ca35 100644 --- a/tests/ui/semicolon_inside_block.fixed +++ b/tests/ui/semicolon_inside_block.fixed @@ -79,5 +79,7 @@ fn main() { unit_fn_block() }; + { unit_fn_block(); }; + unit_fn_block() } diff --git a/tests/ui/semicolon_inside_block.rs b/tests/ui/semicolon_inside_block.rs index 7512125c051..f40848f702e 100644 --- a/tests/ui/semicolon_inside_block.rs +++ b/tests/ui/semicolon_inside_block.rs @@ -79,5 +79,7 @@ fn main() { unit_fn_block() }; + { unit_fn_block(); }; + unit_fn_block() } diff --git a/tests/ui/semicolon_outside_block.fixed b/tests/ui/semicolon_outside_block.fixed index 5bc18faaad8..091eaa7518e 100644 --- a/tests/ui/semicolon_outside_block.fixed +++ b/tests/ui/semicolon_outside_block.fixed @@ -79,5 +79,7 @@ fn main() { unit_fn_block() }; + { unit_fn_block(); }; + unit_fn_block() } diff --git a/tests/ui/semicolon_outside_block.rs b/tests/ui/semicolon_outside_block.rs index 0a429323876..7ce46431fac 100644 --- a/tests/ui/semicolon_outside_block.rs +++ b/tests/ui/semicolon_outside_block.rs @@ -79,5 +79,7 @@ fn main() { unit_fn_block() }; + { unit_fn_block(); }; + unit_fn_block() }