1 use super::CROSSPOINTER_TRANSMUTE;
2 use clippy_utils::diagnostics::span_lint;
4 use rustc_lint::LateContext;
5 use rustc_middle::ty::{self, Ty};
7 /// Checks for `crosspointer_transmute` lint.
8 /// Returns `true` if it's triggered, otherwise returns `false`.
9 pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>, from_ty: Ty<'tcx>, to_ty: Ty<'tcx>) -> bool {
10 match (&from_ty.kind(), &to_ty.kind()) {
11 (ty::RawPtr(from_ptr), _) if from_ptr.ty == to_ty => {
14 CROSSPOINTER_TRANSMUTE,
17 "transmute from a type (`{}`) to the type that it points to (`{}`)",
23 (_, ty::RawPtr(to_ptr)) if to_ptr.ty == from_ty => {
26 CROSSPOINTER_TRANSMUTE,
29 "transmute from a type (`{}`) to a pointer to that type (`{}`)",