Skip to content

Commit afea13f

Browse files
committed
Expand detailed design
1 parent d400320 commit afea13f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Summary
77
[summary]: #summary
88

9-
Allow types with destructors to be used in `const`/`static` items, as long as the destructor is never run during `const` evaluation.
9+
Allow types with destructors to be used in `static` items and in `cosnt` functions, as long as the destructor never needs to run in const context.
1010

1111
# Motivation
1212
[motivation]: #motivation
@@ -20,17 +20,17 @@ runtime-initialisation for global variables.
2020
# Detailed design
2121
[design]: #detailed-design
2222

23-
24-
- allow destructors in statics
25-
- optionally warn about the "potential leak"
26-
- allow instantiating structures that impl Drop in constant expressions
27-
- prevent const items from holding values with destructors, but allow const fn to return them
28-
- disallow constant expressions which would result in the Drop impl getting called, where they not in a constant context
23+
- Lift the restriction on types with destructors being used in statics.
24+
- (Optionally adding a lint that warn about the possibility of resource leak)
25+
- Alloc instantiating structures with destructors in constant expressions,
26+
- Continue to prevent `const` items from holding types with destructors.
27+
- Allow `const fn` to return types wth destructors.
28+
- Disallow constant expressions which would result in the destructor being called (if the code were run at runtime).
2929

3030
# Drawbacks
3131
[drawbacks]: #drawbacks
3232

33-
Destructors do not run on `static` items (by design), so this can lead to unexpected behavior when a side-effecting type is stored in a `static` (e.g. a RAII temporary folder handle). However, this can already happen using the `lazy_static` crate.
33+
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.
3434

3535
# Alternatives
3636
[alternatives]: #alternatives

0 commit comments

Comments
 (0)