1 use super::WRONG_TRANSMUTE;
2 use crate::utils::span_lint;
4 use rustc_lint::LateContext;
5 use rustc_middle::ty::{self, Ty};
7 /// Checks for `wrong_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::Float(_) | ty::Char, ty::Ref(..) | ty::RawPtr(_)) => {
16 &format!("transmute from a `{}` to a pointer", from_ty),