Skip to content

Commit 8acf907

Browse files
committed
Some more precise explanations of which features are allowed in const/const fn
1 parent 167d751 commit 8acf907

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/const_eval.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ to be run.
3838
* Built-in [negation], [arithmetic], [logical], [comparison] or [lazy boolean]
3939
operators used on integer and floating point types, `bool`, and `char`.
4040
* Shared [borrow]s, except if applied to a type with [interior mutability].
41-
* The [dereference operator].
41+
* The [dereference operator] except for raw pointers.
4242
* [Grouped] expressions.
43-
* [Cast] expressions, except pointer to address and
44-
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.
4547
* Calls of [const functions] and const methods.
4648
* [loop], [while] and [`while let`] expressions.
4749
* [if], [`if let`] and [match] expressions.
@@ -65,13 +67,13 @@ return type may use, as well as prevent various expressions from being used with
6567

6668
Notable features that const contexts have, but const fn haven't are:
6769

68-
* floating point types
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.
6973
* `dyn Trait` types
7074
* generic bounds on generic parameters beyond `Sized`
71-
* dereferencing of raw pointers
72-
* casting raw pointers to integers
7375
* comparing raw pointers
74-
* union field access
76+
* union field access or `transmute` invocations.
7577

7678
[arithmetic]: expressions/operator-expr.md#arithmetic-and-logical-binary-operators
7779
[array expressions]: expressions/array-expr.md

0 commit comments

Comments
 (0)