Skip to content

Commit

Permalink
Merge pull request #512 from oli-obk/master
Browse files Browse the repository at this point in the history
Let bindings are now available in const contexts
  • Loading branch information
Centril authored Jan 17, 2019
2 parents 78be683 + 3071432 commit e616dd4
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/const_eval.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ can be evaluated at compile-time.
Certain forms of expressions, called constant expressions, can be evaluated at
compile time. In [const contexts](#const-context), these are the only allowed
expressions, and are always evaluated at compile time. In other places, such as
[`let` statements](statements.html#let-statements), constant expressions *may*
[let statement]s, constant expressions *may*
be, but are not guaranteed to be, evaluated at compile time. 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
Expand All @@ -26,8 +26,13 @@ to be ran.
* [Array expressions].
* [Struct] expressions.
* [Enum variant] expressions.
* [Block expressions], including `unsafe` blocks, which only contain items and
possibly a constant tail expression.
* [Block expressions], including `unsafe` blocks.
* [let statement]s and thus irrefutable [patterns], with the caveat that until `if` and `match`
are implemented, one cannot use both short circuiting operators (`&&` and `||`) and let
statements within the same constant.
* [assignment expressions](operator-expr.html#assignment-expressions)
* [assignment operator expressions](operator-expr.html#compound-assignment-expressions)
* [expression statements](statements.html#expression-statements)
* [Field] expressions.
* Index expressions, [array indexing] or [slice] with a `usize`.
* [Range expressions].
Expand All @@ -39,7 +44,7 @@ to be ran.
* [Grouped] expressions.
* [Cast] expressions, except pointer to address and
function pointer to address casts.
* Calls of const functions and const methods
* Calls of const functions and const methods.

## Const context

Expand Down Expand Up @@ -81,3 +86,5 @@ A _const context_ is one of the following:
[dereference operator]: expressions/operator-expr.html#the-dereference-operator
[grouped]: expressions/grouped-expr.html
[cast]: expressions/operator-expr.html#type-cast-expressions
[let statement]: statements.html#let-statements
[patterns]: patterns.html

0 comments on commit e616dd4

Please sign in to comment.