Skip to content

Commit a7e5aa4

Browse files
committedJan 6, 2022
add sectuib about requirements for const eval
1 parent 9a3c210 commit a7e5aa4

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
 
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Const eval requirements
2+
3+
For this to work, const operations have to be deterministic and
4+
must not depend on any external state,
5+
at least when they are used in the type system.
6+
7+
Using floats during CTFE is fully determinstic. So using
8+
them inside of the type system is fine. CTFE can however
9+
produce different results than what would happen on real hardware,
10+
but this is not a concern for const generics.
11+
12+
Other sources of non-determinism are allocations. This non-determinism
13+
must however not be observed during const-evaluation (TODO: link to const-eval).
14+
Any references used in a constant are considered equal if their targets are equal, which is also determistic. (ref [val-trees](https://github.com/rust-lang/rust/issues/72396))

0 commit comments

Comments
 (0)
Please sign in to comment.