Skip to content

Commit acbf2c4

Browse files
authored
Update promotion.md
1 parent 81d8e19 commit acbf2c4

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

promotion.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,19 @@ compile-time instead of run-time should not alter program behavior.
9797

9898
### 4. Drop
9999

100-
TODO: Fill this with information.
100+
Expressions containing types that implement `Drop` (or have a field implementing `Drop`)
101+
can never be promoted. If such an expression were promoted, the `Drop` impl would
102+
never get called on the value, even though the user did not explicitly request such
103+
behavior by using an explicit `const` or `static` item.
104+
105+
As expression promotion is essentially the silent insertion of a `static` item, and
106+
`static` items never have their `Drop` impl called, the `Drop` impl of the promoted
107+
value would never get called.
108+
109+
While it is sound to `std::mem::forget` any value and thus not call its `Drop` impl,
110+
it is unlikely to be the desired behavior in most cases and very likey to be confusing
111+
to the user. If such behavior is desired, the user can still use an explicit `static`
112+
or `const` item and refer to that.
101113

102114
## Open questions
103115

0 commit comments

Comments
 (0)