Move has_drop to the utils module.

This commit is contained in:
Chris Emerson
2017-09-19 21:38:35 +01:00
parent f680eb164d
commit 9a0a8a0010
2 changed files with 10 additions and 10 deletions

View File

@@ -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)