Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibsG committed Jan 26, 2020
1 parent c6f51fa commit 81c5cd6
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions clippy_lints/src/matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -828,15 +828,16 @@ fn check_match_single_binding(cx: &LateContext<'_, '_>, ex: &Expr<'_>, arms: &[A
let matched_vars = ex.span;
let bind_names = arms[0].pat.span;
let match_body = remove_blocks(&arms[0].body);
let mut snippet_body = snippet_block(cx, match_body.span, "..").to_owned().to_string();
if match_body.span.from_expansion() {
snippet_body = Sugg::hir_with_macro_callsite(cx, match_body, "..").to_string();
}
// Do we need to add ';' to suggestion ?
let mut snippet_body = if match_body.span.from_expansion() {
Sugg::hir_with_macro_callsite(cx, match_body, "..").to_string()
} else {
snippet_block(cx, match_body.span, "..").to_owned().to_string()
};
if let ExprKind::Block(block, _) = &arms[0].body.kind {
// Do we need to add ';' to suggestion ?
if block.stmts.len() == 1 {
if let StmtKind::Semi(_) = block.stmts.get(0).unwrap().kind {
if !snippet_body.starts_with("{") && !snippet_body.ends_with("}") {
if !snippet_body.starts_with('{') && !snippet_body.ends_with('}') {
snippet_body.push(';');
}
}
Expand Down

0 comments on commit 81c5cd6

Please sign in to comment.