@@ -27,9 +27,7 @@ to be run.
2727* [ Struct] expressions.
2828* [ Enum variant] expressions.
2929* [ Block expressions] , including ` unsafe ` blocks.
30- * [ let statements] and thus irrefutable [ patterns] , with the caveat that until ` if ` and ` match `
31- are implemented, one cannot use both short circuiting operators (` && ` and ` || ` ) and let
32- statements within the same constant.
30+ * [ let statements] and thus irrefutable [ patterns] , including mutable bindings
3331 * [ assignment expressions]
3432 * [ compound assignment expressions]
3533 * [ expression statements]
@@ -40,11 +38,15 @@ to be run.
4038* Built-in [ negation] , [ arithmetic] , [ logical] , [ comparison] or [ lazy boolean]
4139 operators used on integer and floating point types, ` bool ` , and ` char ` .
4240* Shared [ borrow] s, except if applied to a type with [ interior mutability] .
43- * The [ dereference operator] .
41+ * The [ dereference operator] except for raw pointers .
4442* [ Grouped] expressions.
45- * [ Cast] expressions, except pointer to address and
46- function pointer to address casts.
43+ * [ Cast] expressions, except
44+ * pointer to address casts,
45+ * function pointer to address casts, and
46+ * unsizing casts to trait objects.
4747* Calls of [ const functions] and const methods.
48+ * [ loop] , [ while] and [ ` while let ` ] expressions.
49+ * [ if] , [ ` if let ` ] and [ match] expressions.
4850
4951## Const context
5052
@@ -57,6 +59,23 @@ A _const context_ is one of the following:
5759 * [ statics]
5860 * [ enum discriminants]
5961
62+ ## Const Functions
63+
64+ A _ const fn_ is a function that one is permitted to call from a const context. Declaring a function
65+ ` const ` has no effect on any existing uses, it only restricts the types that arguments and the
66+ return type may use, as well as prevent various expressions from being used within it.
67+
68+ Notable features that const contexts have, but const fn haven't are:
69+
70+ * floating point operations
71+ * floating point values are treated just like generic parameters without trait bounds beyond
72+ ` Copy ` . So you cannot do anything with them but copy/move them around.
73+ * ` dyn Trait ` types
74+ * generic bounds on generic parameters beyond ` Sized `
75+ * comparing raw pointers
76+ * union field access
77+ * [ ` transmute ` ] invocations.
78+
6079[ arithmetic ] : expressions/operator-expr.md#arithmetic-and-logical-binary-operators
6180[ array expressions ] : expressions/array-expr.md
6281[ array indexing ] : expressions/array-expr.md#array-and-slice-indexing-expressions
@@ -81,10 +100,14 @@ A _const context_ is one of the following:
81100[ functions ] : items/functions.md
82101[ grouped ] : expressions/grouped-expr.md
83102[ interior mutability ] : interior-mutability.md
103+ [ if ] : expressions/if-expr.md#if-expressions
104+ [ `if let` ] : expressions/if-expr.md#if-let-expressions
84105[ lazy boolean ] : expressions/operator-expr.md#lazy-boolean-operators
85106[ let statements ] : statements.md#let-statements
86107[ literals ] : expressions/literal-expr.md
87108[ logical ] : expressions/operator-expr.md#arithmetic-and-logical-binary-operators
109+ [ loop ] : expressions/loop-expr.md#infinite-loops
110+ [ match ] : expressions/match-expr.md
88111[ negation ] : expressions/operator-expr.md#negation-operators
89112[ overflow ] : expressions/operator-expr.md#overflow
90113[ paths ] : expressions/path-expr.md
@@ -94,3 +117,6 @@ A _const context_ is one of the following:
94117[ statics ] : items/static-items.md
95118[ struct ] : expressions/struct-expr.md
96119[ tuple expressions ] : expressions/tuple-expr.md
120+ [ `transmute` ] : ../std/mem/fn.transmute.html
121+ [ while ] : expressions/loop-expr.md#predicate-loops
122+ [ `while let` ] : expressions/loop-expr.md#predicate-pattern-loops
0 commit comments