Skip to content

Commit 81a6b8e

Browse files
committed
link to reading-mutable-static soundness concern
1 parent 266a7ad commit 81a6b8e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

patterns.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ pub fn test(x: &[u8]) -> bool {
4242
To ensure soundness of exhaustiveness checking, it is crucial that all data considered this check is fully immutable.
4343
In particular, for constants of reference type, it is important that they only point to immutable data.
4444
For this reason, the static const checks reject references to `static` items.
45-
This is a new soundness concern that otherwise does not come up during CTFE (where *reading from* a mutable `static` during const initialization is a problem, but just referencing a mutable `static` is not).
45+
This is a new soundness concern that otherwise does not come up during CTFE.
46+
Note that this is orthogonal to the concern of [*reading from* a mutable `static`](const.md#reading-statics) during const initialization, which is a problem for all `const` (even when they are not used in patterns) because it breaks the "inlining" property.
4647
A more precise check could be possible, but is non-trivial: even an immutable `static` could point to a mutable `static`; that would have to be excluded.
4748
(We could, in principle, also rely on it being UB to have a shared reference to mutable memory, but for now we prefer not to rely on the aliasing model like that---aliasing of global pointers is a tricky subject.)
4849

0 commit comments

Comments
 (0)