mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-04 04:39:16 +00:00
Move has_drop to the utils module.
This commit is contained in:
parent
f680eb164d
commit
9a0a8a0010
@ -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;
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user