Skip to content

Commit 20ec2ce

Browse files
committed
Add test case for blocks with semicolon inside and outside a block
1 parent f62eab4 commit 20ec2ce

5 files changed

+14
-3
lines changed

clippy_lints/src/semicolon_block.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ use rustc_span::Span;
88
declare_clippy_lint! {
99
/// ### What it does
1010
///
11-
/// Suggests moving the semicolon from a block inside of the block to its kast expression.
11+
/// Suggests moving the semicolon after a block to the inside of the block, after its last
12+
/// expression.
1213
///
1314
/// ### Why is this bad?
1415
///
15-
/// For consistency it's best to have the semicolon inside/outside the block. Either way is fine and this lint suggests inside the block.
16+
/// For consistency it's best to have the semicolon inside/outside the block. Either way is fine
17+
/// and this lint suggests inside the block.
1618
/// Take a look at `semicolon_outside_block` for the other alternative.
1719
///
1820
/// ### Example
@@ -40,7 +42,8 @@ declare_clippy_lint! {
4042
///
4143
/// ### Why is this bad?
4244
///
43-
/// For consistency it's best to have the semicolon inside/outside the block. Either way is fine and this lint suggests outside the block.
45+
/// For consistency it's best to have the semicolon inside/outside the block. Either way is fine
46+
/// and this lint suggests outside the block.
4447
/// Take a look at `semicolon_inside_block` for the other alternative.
4548
///
4649
/// ### Example

tests/ui/semicolon_inside_block.fixed

+2
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,7 @@ fn main() {
7979
unit_fn_block()
8080
};
8181

82+
{ unit_fn_block(); };
83+
8284
unit_fn_block()
8385
}

tests/ui/semicolon_inside_block.rs

+2
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,7 @@ fn main() {
7979
unit_fn_block()
8080
};
8181

82+
{ unit_fn_block(); };
83+
8284
unit_fn_block()
8385
}

tests/ui/semicolon_outside_block.fixed

+2
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,7 @@ fn main() {
7979
unit_fn_block()
8080
};
8181

82+
{ unit_fn_block(); };
83+
8284
unit_fn_block()
8385
}

tests/ui/semicolon_outside_block.rs

+2
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,7 @@ fn main() {
7979
unit_fn_block()
8080
};
8181

82+
{ unit_fn_block(); };
83+
8284
unit_fn_block()
8385
}

0 commit comments

Comments
 (0)