Skip to content

Conversation

@RalfJung
Copy link
Member

This is the docs part for rust-lang/rust#148967.

I had no idea where to put it. Putting it in "const-expr" is odd since that is generally a compositional notion (the subexpressions of a const expression must be const expressions), whereas the limitation I am describing here only applies at the top level, i.e. for the final value of a const/static initializer.

@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Jan 19, 2026
if a byte has provenance but is not part of an adjacent group of bytes that form an entire pointer, compilation will fail.

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.
As a quality-of-implementation concern, the compiler should only actually fail if the initializer copied or overwrite parts of a pointer and that memory ends up in the final value.
Copy link
Contributor

@traviscross traviscross Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
As a quality-of-implementation concern, the compiler should only actually fail if the initializer copied or overwrite parts of a pointer and that memory ends up in the final value.
As a quality-of-implementation concern, the compiler should only actually fail if the initializer copies or overwrites parts of a pointer and that memory ends up in the final value.

(And we'll want to unwrap the lines.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lines aren't wrapped...?

@traviscross
Copy link
Contributor

I had no idea where to put it. Putting it in "const-expr" is odd since that is generally a compositional notion (the subexpressions of a const expression must be const expressions), whereas the limitation I am describing here only applies at the top level, i.e. for the final value of a const/static initializer.

Good question. We had put the restrictions on the final value of a const in the chapter on const items, but given that this applies to static items as well that'd be maybe a bit more annoying.

Maybe @ehuss will have a good idea on this.

@traviscross traviscross added the I-lang-docs-nominated Nominated for discussion during a lang-docs team meeting. label Jan 19, 2026
@RalfJung RalfJung force-pushed the const-eval-final-value-byte-provenance branch from 5f30a47 to 5b019ef Compare January 20, 2026 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

I-lang-docs-nominated Nominated for discussion during a lang-docs team meeting. S-waiting-on-review Status: The marked PR is awaiting review from a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants