You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: text/0000-drop-types-in-const.md
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@
6
6
# Summary
7
7
[summary]: #summary
8
8
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.
10
10
11
11
# Motivation
12
12
[motivation]: #motivation
@@ -20,17 +20,17 @@ runtime-initialisation for global variables.
20
20
# Detailed design
21
21
[design]: #detailed-design
22
22
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).
29
29
30
30
# Drawbacks
31
31
[drawbacks]: #drawbacks
32
32
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.
0 commit comments