about summary refs log tree commit diff
path: root/src/docs/forget_ref.txt
diff options
context:
space:
mode:
Diffstat (limited to 'src/docs/forget_ref.txt')
-rw-r--r--src/docs/forget_ref.txt15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/docs/forget_ref.txt b/src/docs/forget_ref.txt
new file mode 100644
index 00000000000..874fb878606
--- /dev/null
+++ b/src/docs/forget_ref.txt
@@ -0,0 +1,15 @@
+### What it does
+Checks for calls to `std::mem::forget` with a reference
+instead of an owned value.
+
+### Why is this bad?
+Calling `forget` on a reference will only forget the
+reference itself, which is a no-op. It will not forget the underlying
+referenced
+value, which is likely what was intended.
+
+### Example
+```
+let x = Box::new(1);
+std::mem::forget(&x) // Should have been forget(x), x will still be dropped
+```
\ No newline at end of file