Skip to content

Commit

Permalink
simplify MaybeUninit.uninit().assume_init() lint
Browse files Browse the repository at this point in the history
  • Loading branch information
esamudera committed Jun 11, 2020
1 parent e91ed62 commit a62ae7c
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions clippy_lints/src/mem_replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit a62ae7c

Please sign in to comment.