From a7e5aa46d59eb012694f54f9f49ad846d99e6e16 Mon Sep 17 00:00:00 2001 From: lcnr <rust@lcnr.de> Date: Thu, 6 Jan 2022 09:42:25 +0100 Subject: [PATCH] add sectuib about requirements for const eval --- design-docs/const-eval-requirements.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 design-docs/const-eval-requirements.md diff --git a/design-docs/const-eval-requirements.md b/design-docs/const-eval-requirements.md new file mode 100644 index 0000000..7a357a2 --- /dev/null +++ b/design-docs/const-eval-requirements.md @@ -0,0 +1,14 @@ +# Const eval requirements + +For this to work, const operations have to be deterministic and +must not depend on any external state, +at least when they are used in the type system. + +Using floats during CTFE is fully determinstic. So using +them inside of the type system is fine. CTFE can however +produce different results than what would happen on real hardware, +but this is not a concern for const generics. + +Other sources of non-determinism are allocations. This non-determinism +must however not be observed during const-evaluation (TODO: link to const-eval). +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)) \ No newline at end of file