Skip to content

Commit 3190e93

Browse files
committed
simplify
1 parent 2b6dc0c commit 3190e93

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

clippy_lints/src/implicit_reference_clone.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,10 @@ declare_lint_pass!(ImplicitReferenceClone => [IMPLICIT_REFERENCE_CLONE]);
3535
impl LateLintPass<'_> for ImplicitReferenceClone {
3636
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
3737
let Some(macro_call) = root_macro_call_first_node(cx, expr) else { return; };
38+
let Some(VecArgs::Repeat(elem, _)) = VecArgs::hir(cx, expr) else { return; };
39+
let Some(symbol) = new_reference_call(cx, elem) else { return; };
3840

39-
if let Some(VecArgs::Repeat(elem, _)) = VecArgs::hir(cx, expr) {
40-
let Some(symbol) = new_reference_call(cx, elem) else { return; };
41-
42-
yield_lint(cx, symbol, &macro_call);
43-
}
41+
yield_lint(cx, symbol, &macro_call);
4442
}
4543
}
4644

@@ -71,10 +69,7 @@ fn new_reference_call(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<Symbol> {
7169
if last_path_segment(func_path).ident.name == sym::new;
7270

7371
then {
74-
return match cx.tcx.get_diagnostic_name(def_id) {
75-
Some(symbol) if symbol == sym::Arc || symbol == sym::Rc => Some(symbol),
76-
_ => None
77-
};
72+
return cx.tcx.get_diagnostic_name(def_id).filter(|symbol| symbol == &sym::Arc || symbol == &sym::Rc);
7873
}
7974
}
8075

0 commit comments

Comments
 (0)