Skip to content

Commit b93c3f6

Browse files
committed
Linting
1 parent c6f51fa commit b93c3f6

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

clippy_lints/src/matches.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -828,15 +828,16 @@ fn check_match_single_binding(cx: &LateContext<'_, '_>, ex: &Expr<'_>, arms: &[A
828828
let matched_vars = ex.span;
829829
let bind_names = arms[0].pat.span;
830830
let match_body = remove_blocks(&arms[0].body);
831-
let mut snippet_body = snippet_block(cx, match_body.span, "..").to_owned().to_string();
832-
if match_body.span.from_expansion() {
833-
snippet_body = Sugg::hir_with_macro_callsite(cx, match_body, "..").to_string();
834-
}
831+
let mut snippet_body = if match_body.span.from_expansion() {
832+
Sugg::hir_with_macro_callsite(cx, match_body, "..").to_string()
833+
} else {
834+
snippet_block(cx, match_body.span, "..").to_owned().to_string()
835+
};
835836
// Do we need to add ';' to suggestion ?
836837
if let ExprKind::Block(block, _) = &arms[0].body.kind {
837838
if block.stmts.len() == 1 {
838839
if let StmtKind::Semi(_) = block.stmts.get(0).unwrap().kind {
839-
if !snippet_body.starts_with("{") && !snippet_body.ends_with("}") {
840+
if !snippet_body.starts_with('{') && !snippet_body.ends_with('}') {
840841
snippet_body.push(';');
841842
}
842843
}

0 commit comments

Comments
 (0)