From 27dabb28763cf78720ab8294ef0892836c01f2f8 Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Thu, 10 Feb 2022 15:55:07 -0800 Subject: [PATCH 1/4] Update const_eval.md for feature stabilization We are in the process of stabilizing `const_fn_fn_ptr_basics` and `const_fn_trait_bound`. This edit updates const_eval.md to reflect the new capabilities after stabilizing these features. --- src/const_eval.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/const_eval.md b/src/const_eval.md index 93d2fe8b6..81aea6d32 100644 --- a/src/const_eval.md +++ b/src/const_eval.md @@ -65,8 +65,8 @@ A _const context_ is one of the following: A _const fn_ is a function that one is permitted to call from a const context. Declaring a function `const` has no effect on any existing uses, it only restricts the types that arguments and the -return type may use, as well as prevent various expressions from being used within it. You can freely do anything with a const function that -you can do with a regular function. +return type may use, as well as prevent various expressions from being used within it. You can freely +do anything with a const function that you can do with a regular function. When called from a const context, the function is interpreted by the compiler at compile time. The interpretation happens in the @@ -84,13 +84,12 @@ slightly) different results. It is advisable to not make array lengths and enum discriminants depend on floating point computations. -Notable features that const contexts have, but const fn haven't are: +Notable features that are allowed in const contexts but not in const functions include: * floating point operations * floating point values are treated just like generic parameters without trait bounds beyond `Copy`. So you cannot do anything with them but copy/move them around. * `dyn Trait` types -* generic bounds on generic parameters beyond `Sized` * comparing raw pointers * union field access From 107fda262e91f0202e046b35bad4faa563f25199 Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Mon, 14 Feb 2022 13:45:47 -0800 Subject: [PATCH 2/4] dyn Trait types are allowed now too --- src/const_eval.md | 1 - 1 file changed, 1 deletion(-) diff --git a/src/const_eval.md b/src/const_eval.md index 81aea6d32..ab1b60921 100644 --- a/src/const_eval.md +++ b/src/const_eval.md @@ -89,7 +89,6 @@ Notable features that are allowed in const contexts but not in const functions i * floating point operations * floating point values are treated just like generic parameters without trait bounds beyond `Copy`. So you cannot do anything with them but copy/move them around. -* `dyn Trait` types * comparing raw pointers * union field access From 31832a3a940e84c5b95622cae06f2d2292773853 Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Tue, 1 Mar 2022 10:04:05 -0800 Subject: [PATCH 3/4] Update does to reflect that union field access works too --- src/const_eval.md | 1 - 1 file changed, 1 deletion(-) diff --git a/src/const_eval.md b/src/const_eval.md index ab1b60921..3309ceccd 100644 --- a/src/const_eval.md +++ b/src/const_eval.md @@ -90,7 +90,6 @@ Notable features that are allowed in const contexts but not in const functions i * floating point values are treated just like generic parameters without trait bounds beyond `Copy`. So you cannot do anything with them but copy/move them around. * comparing raw pointers -* union field access Conversely, the following are possible in a const function, but not in a const context: From 806370f1b4112bf7b4e71297ce998877b70534dd Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Wed, 2 Mar 2022 16:11:04 -0800 Subject: [PATCH 4/4] Remove 'compairing raw pointers' --- src/const_eval.md | 1 - 1 file changed, 1 deletion(-) diff --git a/src/const_eval.md b/src/const_eval.md index 3309ceccd..b46e94e12 100644 --- a/src/const_eval.md +++ b/src/const_eval.md @@ -89,7 +89,6 @@ Notable features that are allowed in const contexts but not in const functions i * floating point operations * floating point values are treated just like generic parameters without trait bounds beyond `Copy`. So you cannot do anything with them but copy/move them around. -* comparing raw pointers Conversely, the following are possible in a const function, but not in a const context: