Skip to content

Commit d400320

Browse files
committed
Replace detailed design with @eddyb's comments from rust-lang/rust#30667
1 parent c886a0a commit d400320

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@ runtime-initialisation for global variables.
2020
# Detailed design
2121
[design]: #detailed-design
2222

23-
- Remove the check for `Drop` types in constant expressions.
24-
- Add an error lint ensuring that `Drop` types are not dropped in a constant expression
25-
- This includes when another field is moved out of a struct/tuple, and unused arguments in constant functions.
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
2629

2730
# Drawbacks
2831
[drawbacks]: #drawbacks
2932

30-
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, or with `Option<DropType>` (which bypasses the existing checks).
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.
3134

3235
# Alternatives
3336
[alternatives]: #alternatives

0 commit comments

Comments
 (0)