///
/// **Why is this bad?** This can always be rewritten with `&` and `*`.
///
- /// **Known problems:** None.
+ /// **Known problems:**
+ /// - `mem::transmute` in statics and constants is stable from Rust 1.46.0,
+ /// while dereferencing raw pointer is not stable yet.
+ /// If you need to do this in those places,
+ /// you would have to use `transmute` instead.
///
/// **Example:**
/// ```rust,ignore
let from_ty = cx.typeck_results().expr_ty(&args[0]);
let to_ty = cx.typeck_results().expr_ty(e);
- match (&from_ty.kind, &to_ty.kind) {
+ match (&from_ty.kind(), &to_ty.kind()) {
_ if from_ty == to_ty => span_lint(
cx,
USELESS_TRANSMUTE,
&format!("transmute from a `{}` to a `char`", from_ty),
|diag| {
let arg = sugg::Sugg::hir(cx, &args[0], "..");
- let arg = if let ty::Int(_) = from_ty.kind {
+ let arg = if let ty::Int(_) = from_ty.kind() {
arg.as_ty(ast::UintTy::U32.name_str())
} else {
arg
},
(ty::Ref(_, ty_from, from_mutbl), ty::Ref(_, ty_to, to_mutbl)) => {
if_chain! {
- if let (&ty::Slice(slice_ty), &ty::Str) = (&ty_from.kind, &ty_to.kind);
- if let ty::Uint(ast::UintTy::U8) = slice_ty.kind;
+ if let (&ty::Slice(slice_ty), &ty::Str) = (&ty_from.kind(), &ty_to.kind());
+ if let ty::Uint(ast::UintTy::U8) = slice_ty.kind();
if from_mutbl == to_mutbl;
then {
let postfix = if *from_mutbl == Mutability::Mut {
&format!("transmute from a `{}` to a `{}`", from_ty, to_ty),
|diag| {
let arg = sugg::Sugg::hir(cx, &args[0], "..");
- let arg = if let ty::Int(int_ty) = from_ty.kind {
+ let arg = if let ty::Int(int_ty) = from_ty.kind() {
arg.as_ty(format!(
"u{}",
int_ty.bit_width().map_or_else(|| "size".to_string(), |v| v.to_string())
arg = sugg::Sugg::NonParen(format!("{}.to_bits()", arg.maybe_par()).into());
// cast the result of `to_bits` if `to_ty` is signed
- arg = if let ty::Int(int_ty) = to_ty.kind {
+ arg = if let ty::Int(int_ty) = to_ty.kind() {
arg.as_ty(int_ty.name_str().to_string())
} else {
arg