summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/transmute_ptr_to_ref.txt
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/src/docs/transmute_ptr_to_ref.txt')
-rw-r--r--src/tools/clippy/src/docs/transmute_ptr_to_ref.txt21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/transmute_ptr_to_ref.txt b/src/tools/clippy/src/docs/transmute_ptr_to_ref.txt
new file mode 100644
index 000000000..aca550f50
--- /dev/null
+++ b/src/tools/clippy/src/docs/transmute_ptr_to_ref.txt
@@ -0,0 +1,21 @@
+### What it does
+Checks for transmutes from a pointer to a reference.
+
+### Why is this bad?
+This can always be rewritten with `&` and `*`.
+
+### 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
+```
+unsafe {
+ let _: &T = std::mem::transmute(p); // where p: *const T
+}
+
+// can be written:
+let _: &T = &*p;
+``` \ No newline at end of file