Skip to content

Commit 692f694

Browse files
authored
Merge pull request #498 from chriskrycho/const-evaluation-467
"Improve language in 'Constant Expressions'.
2 parents 6112697 + bc95b74 commit 692f694

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/const_eval.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ can be evaluated at compile-time.
66

77
## Constant expressions
88

9-
Certain types of expressions can be evaluated at compile time. These are called
10-
_constant expressions_ and are required in const contexts. In
11-
other places, such as in [`let` statements](statements.html#let-statements),
12-
constant expressions may be evaluated at compile time. If errors, such as out
13-
of bounds [array indexing] or [overflow] occurs,
14-
then it is a compiler error if the value must be evaluated at compile time,
15-
otherwise it is just a warning, but the code will most likely panic when run.
9+
Certain forms of expressions, called constant expressions, can be evaluated at
10+
compile time. In [const contexts](#const-context), these are the only allowed
11+
expressions, and are always evaluated at compile time. In other places, such as
12+
[`let` statements](statements.html#let-statements), constant expressions *may*
13+
be, but are not guaranteed to be, evaluated at compile time. Behaviors such as
14+
out of bounds [array indexing] or [overflow] are compiler errors if the value
15+
must be evaluated at compile time (i.e. in const contexts). Otherwise, these
16+
behaviors are warnings, but will likely panic at run-time.
1617

1718
The following expressions are constant expressions, so long as any operands are
1819
also constant expressions and do not cause any [`Drop::drop`][destructors] calls

0 commit comments

Comments
 (0)