Skip to content

Commit 5a9a2b2

Browse files
committed
Clarify drawback pertaining to dropping const items.
1 parent db54fa9 commit 5a9a2b2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

text/1440-drop-types-in-const.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Allow types with destructors to be used in `static` items, `const` items, and `c
1111
# Motivation
1212
[motivation]: #motivation
1313

14-
Some of the collection types do not allocate any memory when constructed empty (most notably `Vec`). With the change to make leaking safe, the restriction on `static` items with destructors
14+
Some of the collection types do not allocate any memory when constructed empty (most notably `Vec`). With the change to make leaking safe, the restriction on `static` or `const` items with destructors
1515
is no longer required to be a hard error (as it is safe and accepted that these destructors may never run).
1616

1717
Allowing types with destructors to be directly used in `const` functions and stored in `static`s or `const`s will remove the need to have
@@ -57,7 +57,7 @@ const fn sample(_v: Vec<u8>) -> usize {
5757

5858
Destructors do not run on `static` items (by design), so this can lead to unexpected behavior when a type's destructor has effects outside the program (e.g. a RAII temporary folder handle, which deletes the folder on drop). However, this can already happen using the `lazy_static` crate.
5959

60-
Destructors _will_ run on `const` items at runtime, which can lead to unexpected behavior when a type's destructor has effects outside the program.
60+
A `const` item's destructor _will_ run at each point where the `const` item is used. If a `const` item is never used, its destructor will never run. These behaviors may be unexpected.
6161

6262
# Alternatives
6363
[alternatives]: #alternatives

0 commit comments

Comments
 (0)