blob: 65777db98618640fc51882194a9859fa45945979 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
### What it does
Checks for transmutes from a pointer to a pointer, or
from a reference to a reference.
### Why is this bad?
Transmutes are dangerous, and these can instead be
written as casts.
### Example
```
let ptr = &1u32 as *const u32;
unsafe {
// pointer-to-pointer transmute
let _: *const f32 = std::mem::transmute(ptr);
// ref-ref transmute
let _: &f32 = std::mem::transmute(&1u32);
}
// These can be respectively written:
let _ = ptr as *const f32;
let _ = unsafe{ &*(&1u32 as *const u32 as *const f32) };
```
|