summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/transmute_ptr_to_ptr.txt
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/src/docs/transmute_ptr_to_ptr.txt')
-rw-r--r--src/tools/clippy/src/docs/transmute_ptr_to_ptr.txt21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/transmute_ptr_to_ptr.txt b/src/tools/clippy/src/docs/transmute_ptr_to_ptr.txt
new file mode 100644
index 000000000..65777db98
--- /dev/null
+++ b/src/tools/clippy/src/docs/transmute_ptr_to_ptr.txt
@@ -0,0 +1,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) };
+``` \ No newline at end of file