@@ -120,6 +120,13 @@ restrictions described there are needed because we want `const` to behave the
120
120
same as copying the ` const ` initializer everywhere the constant is used; we need
121
121
the same property when promoting expressions. But we need more.
122
122
123
+ Note that there is no point in doing additional dynamic checks here. The entire point of
124
+ the promotion restrictions is to avoid failing compilation for code that would
125
+ have been fine without promotion. The best a dynamic check could do is tell us
126
+ after the fact that we should not have promoted something, but then it is
127
+ already too late -- and the dynamic checks for that are exactly the ones we are
128
+ already doing for constants and statics.
129
+
123
130
### Panics
124
131
125
132
Promotion is not allowed to throw away side effects. This includes panicking.
@@ -153,9 +160,6 @@ earlier version of miri used to panic on arithmetic overflow even in release
153
160
mode. This breaks promotion, because now promoting code that would work (and
154
161
could not panic!) at run-time leads to a compile-time CTFE error.
155
162
156
- * Dynamic check.* The Miri engine already dynamically detects panics, but the
157
- main point of promoteds is ruling them out statically.
158
-
159
163
### Const safety
160
164
161
165
We have explained what happens when evaluating a promoted panics, but what about
@@ -202,9 +206,6 @@ way when working with const-safe arguments.
202
206
For this reason, only ` const fn ` that were explicitly marked with the
203
207
` #[rustc_promotable] ` attribute are subject to promotion.
204
208
205
- * Dynamic check.* The Miri engine already dynamically detects const safety
206
- violations, but the main point of promoteds is ruling them out statically.
207
-
208
209
### Drop
209
210
210
211
Expressions returning "needs drop" types can never be promoted. If such an
0 commit comments