Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/const_eval.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,14 @@ r[const-eval.const-expr.loop]
r[const-eval.const-expr.if-match]
* [if] and [match] expressions.

## Const initializers

r[const-eval.const-expr.final-value-provenance]
The representation of the final value of a [constant][constant initializer] or [static initializer] must only contain bytes with provenance in whole-pointer groups. If a byte has provenance but is not part of an adjacent group of bytes that form an entire pointer, compilation will fail.

> [!NOTE]
> If a byte in the representation of the final value is uninitialized, then it *may* end up having provenance, which can cause compilation to fail. `rustc` tries (but does not guarantee) to only actually fail if the initializer copies or overwrites parts of a pointer and those bytes appear in the final value.

r[const-eval.const-context]
## Const context
[const context]: #const-context
Expand Down Expand Up @@ -307,6 +315,7 @@ The types of a const function's parameters and return type are restricted to tho
[const generic argument]: items/generics.md#const-generics
[const generic parameters]: items/generics.md#const-generics
[constant expressions]: #constant-expressions
[constant initializer]: items.const
[constants]: items/constant-items.md
[Const parameters]: items/generics.md
[dereference expression]: expr.deref
Expand Down Expand Up @@ -336,6 +345,7 @@ The types of a const function's parameters and return type are restricted to tho
[promoted]: destructors.md#constant-promotion
[range expressions]: expressions/range-expr.md
[slice]: types/slice.md
[static initializer]: items.static.init
[statics]: items/static-items.md
[Struct expressions]: expressions/struct-expr.md
[temporary lifetime extension]: destructors.scope.lifetime-extension
Expand Down