File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -345,10 +345,14 @@ let x = (&temp()).use_temp(); // ERROR
345345
346346## Not running destructors
347347
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
350350variable or field from being dropped automatically.
351351
352+ > Note: Preventing a destructor from being run via ` forget ` or other means is safe in Rust
353+ > even if it has a type that isn't ` 'static ` . This means that publicly exposed APIs cannot
354+ > rely on destructor being run for soundness.
355+
352356[ Assignment ] : expressions/operator-expr.md#assignment-expressions
353357[ binding modes ] : patterns.md#binding-modes
354358[ closure ] : types/closure.md
@@ -395,4 +399,5 @@ variable or field from being dropped automatically.
395399
396400[ `<T as std::ops::Drop>::drop` ] : ../std/ops/trait.Drop.html#tymethod.drop
397401[ `std::ptr::drop_in_place` ] : ../std/ptr/fn.drop_in_place.html
402+ [ `std::mem::forget` ] : ../std/mem/fn.forget.html
398403[ `std::mem::ManuallyDrop` ] : ../std/mem/struct.ManuallyDrop.html
You can’t perform that action at this time.
0 commit comments