use clippy_utils::diagnostics::span_lint;
use clippy_utils::is_hir_ty_cfg_dependant;
+use clippy_utils::ty::is_c_void;
use if_chain::if_chain;
use rustc_hir::{Expr, ExprKind, GenericArg};
use rustc_lint::LateContext;
use rustc_middle::ty::layout::LayoutOf;
use rustc_middle::ty::{self, Ty};
-use rustc_span::symbol::sym;
use super::CAST_PTR_ALIGNMENT;
}
}
}
-
-/// Check if the given type is either `core::ffi::c_void` or
-/// one of the platform specific `libc::<platform>::c_void` of libc.
-fn is_c_void(cx: &LateContext<'_>, ty: Ty<'_>) -> bool {
- if let ty::Adt(adt, _) = ty.kind() {
- let names = cx.get_def_path(adt.did);
-
- if names.is_empty() {
- return false;
- }
- if names[0] == sym::libc || names[0] == sym::core && *names.last().unwrap() == sym!(c_void) {
- return true;
- }
- }
- false
-}