Skip to content

Commit c19ca03

Browse files
committed
Linting
1 parent 92e35b2 commit c19ca03

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

clippy_lints/src/matches.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ use crate::utils::paths;
33
use crate::utils::sugg::Sugg;
44
use crate::utils::usage::is_unused;
55
use crate::utils::{
6-
span_lint_and_help, span_lint_and_note,
7-
expr_block, in_macro, is_allowed, is_expn_of, is_wild, match_qpath, match_type, multispan_sugg, remove_blocks,
8-
snippet, snippet_block, snippet_with_applicability, span_lint_and_sugg, span_lint_and_then,
6+
expr_block, get_arg_name, in_macro, is_allowed, is_expn_of, is_refutable, is_wild, match_qpath, match_type,
7+
match_var, multispan_sugg, remove_blocks, snippet, snippet_block, snippet_with_applicability, span_lint_and_help,
8+
span_lint_and_note, span_lint_and_sugg, span_lint_and_then, walk_ptrs_ty,
99
};
1010
use if_chain::if_chain;
1111
use rustc::lint::in_external_macro;
@@ -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-
}
835-
// Do we need to add ';' to suggestion ?
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+
};
836836
if let ExprKind::Block(block, _) = &arms[0].body.kind {
837+
// Do we need to add ';' to suggestion ?
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)