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: src/const_eval.md
+7-20Lines changed: 7 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,16 +2,13 @@ r[const-eval]
2
2
# Constant evaluation
3
3
4
4
r[const-eval.general]
5
-
Constant evaluation is the process of computing the result of
6
-
[expressions] during compilation. Only a subset of all expressions
7
-
can be evaluated at compile-time.
5
+
Constant evaluation is the process of computing the result of [expressions] during compilation. Only a subset of all expressions can be evaluated at compile-time.
8
6
9
7
r[const-eval.const-expr]
10
8
## Constant expressions
11
9
12
10
r[const-eval.const-expr.general]
13
-
Certain forms of expressions, called constant expressions, can be evaluated at
14
-
compile time.
11
+
Certain forms of expressions, called constant expressions, can be evaluated at compile time.
15
12
16
13
r[const-eval.const-expr.const-context]
17
14
Expressions in a [const context] must be constant expressions.
Outside of const contexts, constant expressions *may* be, but are not guaranteed to be, evaluated at compile time.
24
21
25
22
r[const-eval.const-expr.error]
26
-
Behaviors such as out of bounds [array indexing] or [overflow] are compiler errors if the value
27
-
must be evaluated at compile time (i.e. in const contexts). Otherwise, these
28
-
behaviors are warnings, but will likely panic at run-time.
23
+
Behaviors such as out of bounds [array indexing] or [overflow] are compiler errors if the value must be evaluated at compile time (i.e. in const contexts). Otherwise, these behaviors are warnings, but will likely panic at run-time.
29
24
30
25
r[const-eval.const-expr.list]
31
-
The following expressions are constant expressions, so long as any operands are
32
-
also constant expressions and do not cause any [`Drop::drop`][destructors] calls
33
-
to be run.
26
+
The following expressions are constant expressions, so long as any operands are also constant expressions and do not cause any [`Drop::drop`][destructors] calls to be run.
*[Closure expressions] which don't capture variables from the environment.
80
72
81
73
r[const-eval.const-expr.builtin-arith-logic]
82
-
* Built-in [negation], [arithmetic], [logical], [comparison] or [lazy boolean]
83
-
operators used on integer and floating point types, `bool`, and `char`.
74
+
* Built-in [negation], [arithmetic], [logical], [comparison] or [lazy boolean] operators used on integer and floating point types, `bool`, and `char`.
84
75
85
76
r[const-eval.const-expr.borrows]
86
77
* All forms of [borrow]s, including raw borrows, except borrows of expressions whose temporary scopes would be extended (see [temporary lifetime extension]) to the end of the program and which are either:
Const contexts that are used as parts of types (array type and repeat length
271
-
expressions as well as const generic arguments) can only make restricted use of
272
-
surrounding generic parameters: such an expression must either be a single bare
273
-
const generic parameter, or an arbitrary expression not making use of any
274
-
generics.
261
+
Const contexts that are used as parts of types (array type and repeat length expressions as well as const generic arguments) can only make restricted use of surrounding generic parameters: such an expression must either be a single bare const generic parameter, or an arbitrary expression not making use of any generics.
0 commit comments