You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/destructors.md
+6-2
Original file line number
Diff line number
Diff line change
@@ -345,10 +345,13 @@ let x = (&temp()).use_temp(); // ERROR
345
345
346
346
## Not running destructors
347
347
348
-
Not running destructors in Rust is safe even if it has a type that isn't
349
-
`'static`.[`std::mem::ManuallyDrop`] provides a wrapper to prevent a
348
+
[`std::mem::forget`] can be used to prevent the destructor of a variable from being run,
349
+
and[`std::mem::ManuallyDrop`] provides a wrapper to prevent a
350
350
variable or field from being dropped automatically.
351
351
352
+
> Note: Preventing a destructor from being run via [`std::mem::forget`] or other means is safe even if it has a type that isn't `'static`.
353
+
> Besides the places where destructors are guaranteed to run as defined by this document, types may *not* safely rely on a destructor being run for soundness.
0 commit comments