1 use super::TRANSMUTE_PTR_TO_PTR;
2 use clippy_utils::diagnostics::span_lint_and_then;
3 use clippy_utils::sugg;
4 use rustc_errors::Applicability;
6 use rustc_lint::LateContext;
7 use rustc_middle::ty::{self, Ty};
9 /// Checks for `transmute_ptr_to_ptr` lint.
10 /// Returns `true` if it's triggered, otherwise returns `false`.
11 pub(super) fn check<'tcx>(
12 cx: &LateContext<'tcx>,
16 args: &'tcx [Expr<'_>],
18 match (&from_ty.kind(), &to_ty.kind()) {
19 (ty::RawPtr(_), ty::RawPtr(to_ty)) => {
24 "transmute from a pointer to a pointer",
26 if let Some(arg) = sugg::Sugg::hir_opt(cx, &args[0]) {
27 let sugg = arg.as_ty(cx.tcx.mk_ptr(*to_ty));
28 diag.span_suggestion(e.span, "try", sugg.to_string(), Applicability::Unspecified);