Skip to content

Commit 4cb1985

Browse files
committed
bytes inside implicitly const-promoted expressions are immutable
1 parent 8c789ff commit 4cb1985

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/behavior-considered-undefined.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@ Please read the [Rustonomicon] before writing unsafe code.
4949
All this also applies when values of these
5050
types are passed in a (nested) field of a compound type, but not behind
5151
pointer indirections.
52-
* Mutating immutable bytes. All bytes inside a [`const`] item are immutable.
52+
* Mutating immutable bytes. All bytes inside a [`const`] item are immutable, including implicitly [const-promoted] expressions.
5353
The bytes owned by an immutable binding or immutable `static` are immutable, unless those bytes are part of an [`UnsafeCell<U>`].
5454

55-
Moreover, the bytes [pointed to] by a shared reference, including transitively through other references (both shared and mutable) and `Box`es, are immutable; transitivity includes those references stored in fields of compound types.
55+
Moreover, the bytes [pointed to] by a shared reference, including transitively through other references (both shared and mutable) and `Box`es, are immutable;
56+
transitivity includes those references stored in fields of compound types.
5657

5758
A mutation is any write of more than 0 bytes which overlaps with any of the relevant bytes (even if that write does not change the memory contents).
5859
* Invoking undefined behavior via compiler intrinsics.
@@ -189,3 +190,4 @@ reading uninitialized memory is permitted are inside `union`s and in "padding"
189190
[project-field]: expressions/field-expr.md
190191
[project-tuple]: expressions/tuple-expr.md#tuple-indexing-expressions
191192
[project-slice]: expressions/array-expr.md#array-and-slice-indexing-expressions
193+
[const-promoted]: destructors.md#constant-promotion

0 commit comments

Comments
 (0)