-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Compile error when directly using &mut in explicity const context #140126
Copy link
Copy link
Closed as duplicate of#143129
Closed as duplicate of#143129
Copy link
Labels
A-ZSTArea: Zero-sized types (ZSTs).Area: Zero-sized types (ZSTs).A-arrayArea: `[T; N]`Area: `[T; N]`A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-constant-promotionArea: constant promotionArea: constant promotionC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-ZSTArea: Zero-sized types (ZSTs).Area: Zero-sized types (ZSTs).A-arrayArea: `[T; N]`Area: `[T; N]`A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-constant-promotionArea: constant promotionArea: constant promotionC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
I tried this code:
I expected to see this happen: Both constants compile or both fail to compile.
Instead, this happened:
BADfailed to compile.I'm not sure which is the intended behavior or if it is UB. I don't know the rules around constants that hold mutable references.
This fails to compile in constants, statics and
const {}blocks. This succeeds when using const functions to wrap the expressions, even in constants, statics, andconst {}blocks.Additional examples: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=7b7a327957429e5706e520755d9cd467
See also an ICE related to this "ICE
error performing operation: fully_perform" #140123Meta
rustc --version --verbose:Backtrace
RUST_BACKTRACE=1 cargo +nightly build