From 9a0a8a0010e0da18d664e8895a3d73b784f026b8 Mon Sep 17 00:00:00 2001 From: Chris Emerson Date: Tue, 19 Sep 2017 21:38:35 +0100 Subject: [PATCH] Move has_drop to the utils module. --- clippy_lints/src/no_effect.rs | 11 +---------- clippy_lints/src/utils/mod.rs | 9 +++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/clippy_lints/src/no_effect.rs b/clippy_lints/src/no_effect.rs index 230c811935cc..f5543821949a 100644 --- a/clippy_lints/src/no_effect.rs +++ b/clippy_lints/src/no_effect.rs @@ -1,7 +1,7 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::hir::def::Def; use rustc::hir::{BiAnd, BiOr, BlockCheckMode, Expr, Expr_, Stmt, StmtSemi, UnsafeSource}; -use utils::{in_macro, snippet_opt, span_lint, span_lint_and_sugg}; +use utils::{in_macro, snippet_opt, span_lint, span_lint_and_sugg, has_drop}; use std::ops::Deref; /// **What it does:** Checks for statements which have no effect. @@ -40,15 +40,6 @@ declare_lint! { "outer expressions with no effect" } -/// Check whether this type implements Drop. -fn has_drop(cx: &LateContext, expr: &Expr) -> bool { - let struct_ty = cx.tables.expr_ty(expr); - match struct_ty.ty_adt_def() { - Some(def) => def.has_dtor(cx.tcx), - _ => false, - } -} - fn has_no_effect(cx: &LateContext, expr: &Expr) -> bool { if in_macro(expr.span) { return false; diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index ec0521ce4f2d..cf0aaf6dbaa2 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -358,6 +358,15 @@ pub fn implements_trait<'a, 'tcx>( }) } +/// Check whether this type implements Drop. +pub fn has_drop(cx: &LateContext, expr: &Expr) -> bool { + let struct_ty = cx.tables.expr_ty(expr); + match struct_ty.ty_adt_def() { + Some(def) => def.has_dtor(cx.tcx), + _ => false, + } +} + /// Resolve the definition of a node from its `HirId`. pub fn resolve_node(cx: &LateContext, qpath: &QPath, id: HirId) -> def::Def { cx.tables.qpath_def(qpath, id)