about summary refs log tree commit diff
path: root/library/core/src/slice/raw.rs
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2021-12-10 22:40:32 +0100
committerGitHub <noreply@github.com>2021-12-10 22:40:32 +0100
commitd317da48b1341eec28ed070002a7110b39b9ae15 (patch)
tree65f021f374e4c2015a9f4ec5dc4ffc6e0c242e69 /library/core/src/slice/raw.rs
parent60aa03aa71e6057bded100d24519e6309c2152d6 (diff)
parent85558ad5b39d435d3c57e3e0df5f4c160ee0c6e3 (diff)
downloadrust-d317da48b1341eec28ed070002a7110b39b9ae15.tar.gz
rust-d317da48b1341eec28ed070002a7110b39b9ae15.zip
Rollup merge of #91325 - RalfJung:const_eval_select, r=dtolnay
adjust const_eval_select documentation

"The Rust compiler assumes" indicates that this is language UB, but [I don't think that is a good idea](https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/const_eval_select.20assumptions). This UB would be very hard to test for and looks like a way-too-big footgun. ``@oli-obk`` suggested this is meant to be more like "library UB", so I tried to adjust the docs accordingly.

I also removed all references to "referential transparency". That is a rather vague concept used to mean many different things, and I honestly have no idea what exactly is meant by it in this specific instance. But I assume ``@fee1-dead`` had in their mind a property that all `const fn` code upholds, so by demanding that the runtime code and the const-time code are *observably equivalent*, whatever that property is would also be enforced here.

Cc ``@rust-lang/wg-const-eval``
Diffstat (limited to 'library/core/src/slice/raw.rs')
-rw-r--r--library/core/src/slice/raw.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/library/core/src/slice/raw.rs b/library/core/src/slice/raw.rs
index d98db3f57c0..e7972838184 100644
--- a/library/core/src/slice/raw.rs
+++ b/library/core/src/slice/raw.rs
@@ -149,8 +149,8 @@ const fn debug_check_data_len<T>(data: *const T, len: usize) {
     // it is not required for safety (the safety must be guatanteed by
     // the `from_raw_parts[_mut]` caller).
     //
-    // Since the checks are not required, we ignore them in CTFE as they can't
-    // be done there (alignment does not make much sense there).
+    // As per our safety precondition, we may assume that assertion above never fails.
+    // Therefore, noop and rt_check are observably equivalent.
     unsafe {
         crate::intrinsics::const_eval_select((data,), noop, rt_check);
     }