@@ -66,12 +66,15 @@ Currently, non-`Copy` array initialization is treated as an implicit context,
66
66
because the code could compile even without promotion (namely, if the result
67
67
type is ` Copy ` ).
68
68
69
- The distinction between these two determines whether calls to arbitrary `const
70
- fn` s (those without ` #[ rustc_promotable] `) are promotable (see below). See
71
- [ rust-lang/const-eval #19 ] ( https://github.com/rust-lang/const-eval/issues/19 )
72
- for a thorough discussion of this. At present, this is the only difference
73
- between implicit and explicit contexts. The requirements for promotion in an
74
- implicit context are a superset of the ones in an explicit context.
69
+ CTFE of implicitly promoted code must never fail to evaluate except of the
70
+ run-time code also would have failed. This means we cannot permit calling
71
+ arbitrary ` const fn ` , as we cannot predict if they are going to perform an
72
+ [ "unconst" operation] ( const_safety.md ) . Thus, only functions marked
73
+ ` #[rustc_promotable] ` are implicitly promotable (see below). See
74
+ [ rust-lang/const-eval #19 ] ( https://github.com/rust-lang/const-eval/issues/19 ) for
75
+ a thorough discussion of this. At present, this is the only difference between
76
+ implicit and explicit contexts. The requirements for promotion in an implicit
77
+ context are a superset of the ones in an explicit context.
75
78
76
79
[ warn-rfc ] : https://github.com/rust-lang/rfcs/blob/master/text/1229-compile-time-asserts.md
77
80
@@ -204,7 +207,8 @@ not have decided to promote. It is the responsibility of `foo` to not fail this
204
207
way when working with const-safe arguments.
205
208
206
209
For this reason, only ` const fn ` that were explicitly marked with the
207
- ` #[rustc_promotable] ` attribute are subject to promotion.
210
+ ` #[rustc_promotable] ` attribute are subject to promotion. Those functions must
211
+ be manually reviewed to never raise CTFE errors.
208
212
209
213
### Drop
210
214
0 commit comments