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: promotion.md
+34-35
Original file line number
Diff line number
Diff line change
@@ -44,41 +44,7 @@ attribute, introduced in
44
44
specify these parameters and (aggressively, see below) try to promote the
45
45
corresponding arguments.
46
46
47
-
## Implicit and explicit promotion
48
-
49
-
On top of what applies to [consts](const.md), promoteds suffer from the additional issue that *the user did not ask for them to be evaluated at compile-time*.
50
-
Thus, if CTFE fails but the code would have worked fine at run-time, we broke the user's code for no good reason.
51
-
Even if we are sure we found an error in the user's code, we are only allowed to [emit a warning, not a hard error][warn-rfc].
52
-
We call this *implicit* promotion, and we have to be very conservative with what can and cannot be implicitly promoted.
53
-
54
-
CTFE of implicitly promoted code must never fail to evaluate except if the
55
-
run-time code also would have failed. This means we cannot permit calling
Lifetime extension is also responsible for making code like this work:
84
50
@@ -108,6 +74,39 @@ the "enclosing scope", similar to how `let x = &mut x;` creates a reference
108
74
whose lifetime lasts for the enclosing scope. This is decided during MIR
109
75
building already, and does not involve lifetime extension.
110
76
77
+
## Implicit and explicit promotion
78
+
79
+
On top of what applies to [consts](const.md), promoteds suffer from the additional issue that *the user did not ask for them to be evaluated at compile-time*.
80
+
Thus, if CTFE fails but the code would have worked fine at run-time, we broke the user's code for no good reason.
81
+
Even if we are sure we found an error in the user's code, we are only allowed to [emit a warning, not a hard error][warn-rfc].
82
+
We call this *implicit* promotion, and we have to be very conservative with what can and cannot be implicitly promoted.
83
+
84
+
CTFE of implicitly promoted code must never fail to evaluate except if the
85
+
run-time code also would have failed. This means we cannot permit calling
0 commit comments