Use Option::map_or

This commit is contained in:
Dale Wijnand 2018-08-06 15:42:08 +02:00
parent b18a3c5b60
commit 7a5ede677b
No known key found for this signature in database
GPG Key ID: 4F256E3D151DF5EF

View File

@ -37,10 +37,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MemForget {
if match_def_path(cx.tcx, def_id, &paths::MEM_FORGET) {
let forgot_ty = cx.tables.expr_ty(&args[0]);
if match forgot_ty.ty_adt_def() {
Some(def) => def.has_dtor(cx.tcx),
_ => false,
} {
if forgot_ty.ty_adt_def().map_or(false, |def| def.has_dtor(cx.tcx)) {
span_lint(cx, MEM_FORGET, e.span, "usage of mem::forget on Drop type");
}
}