From a62ae7ca9dc9f8a37727da7a1714f2c9c1cb8837 Mon Sep 17 00:00:00 2001 From: Ericko Samudera Date: Fri, 12 Jun 2020 00:55:24 +0700 Subject: [PATCH] simplify MaybeUninit.uninit().assume_init() lint --- clippy_lints/src/mem_replace.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/clippy_lints/src/mem_replace.rs b/clippy_lints/src/mem_replace.rs index 74d6e64a1a4a..e2672e02b36d 100644 --- a/clippy_lints/src/mem_replace.rs +++ b/clippy_lints/src/mem_replace.rs @@ -137,15 +137,9 @@ fn check_replace_option_with_none(cx: &LateContext<'_, '_>, src: &Expr<'_>, dest fn check_replace_with_uninit(cx: &LateContext<'_, '_>, src: &Expr<'_>, dest: &Expr<'_>, expr_span: Span) { if_chain! { - // check if replacement is `maybe_uninit::uninit().assume_init()`: - if let ExprKind::MethodCall(method_path, _, method_args) = src.kind; - if method_path.ident.name == sym!(assume_init); - if !method_args.is_empty(); - if let ExprKind::Call(ref repl_func, ref repl_args) = method_args[0].kind; - if repl_args.is_empty(); - if let ExprKind::Path(ref repl_func_qpath) = repl_func.kind; - if let Some(repl_def_id) = cx.tables.qpath_res(repl_func_qpath, repl_func.hir_id).opt_def_id(); - if cx.tcx.is_diagnostic_item(sym::maybe_uninit_uninit, repl_def_id); + // check if replacement is mem::MaybeUninit::uninit().assume_init() + if let Some(method_def_id) = cx.tables.type_dependent_def_id(src.hir_id); + if cx.tcx.is_diagnostic_item(sym::assume_init, method_def_id); then { let mut applicability = Applicability::MachineApplicable; span_lint_and_sugg(