@@ -13,6 +13,7 @@ called in constants contexts, with constant arguments.
13
13
As it is right now, ` UnsafeCell ` is a stabilization and safety hazard: the field
14
14
it is supposed to be wrapping is public. This is only done out of the necessity
15
15
to initialize static items containing atomics, mutexes, etc. - for example:
16
+
16
17
``` rust
17
18
#[lang= " unsafe_cell" ]
18
19
struct UnsafeCell <T > { pub value : T }
@@ -46,9 +47,17 @@ for such features.
46
47
47
48
The design should be as simple as it can be, while keeping enough functionality
48
49
to solve the issues mentioned above.
49
- The intention is to have something usable at 1.0 without limiting what we can
50
- in the future. Compile-time pure constants (the existing ` const ` items) with
51
- added parametrization over types and values (arguments) should suffice.
50
+
51
+ The intention of this RFC is to introduce a minimal change that
52
+ enables safe abstraction resembling the kind of code that one writes
53
+ outside of a constant. Compile-time pure constants (the existing
54
+ ` const ` items) with added parametrization over types and values
55
+ (arguments) should suffice.
56
+
57
+ This RFC explicitly does not introduce a general CTFE mechanism. In
58
+ particular, conditional branching and virtual dispatch are still not
59
+ supported in constant expressions, which imposes a severe limitation
60
+ on what one can express.
52
61
53
62
# Detailed design
54
63
@@ -171,9 +180,6 @@ after 1.0.
171
180
172
181
# Alternatives
173
182
174
- * Not do anything for 1.0. This would result in some APIs being crippled and
175
- serious backwards compatibility issues - ` UnsafeCell ` 's ` value ` field cannot
176
- simply be removed later.
177
183
* While not an alternative, but rather a potential extension, I want to point
178
184
out there is only way I could make ` const fn ` s work with traits (in an untested
179
185
design, that is): qualify trait implementations and bounds with ` const ` .
@@ -214,3 +220,9 @@ algorithm that can handle *at least* tail recursion.
214
220
Also, there is no way to actually write a recursive ` const fn ` at this moment,
215
221
because no control flow primitives are implemented for constants, but that
216
222
cannot be taken for granted, at least ` if ` /` else ` should eventually work.
223
+
224
+ # History
225
+
226
+ - This RFC was accepted on 2015-04-06. The primary concerns raised in
227
+ the discussion concerned CTFE, and whether the ` const fn ` strategy
228
+ locks us into an undesirable plan there.
0 commit comments