Compile error when directly using &mut
in explicity const context
#140126
Labels
A-const-eval
Area: Constant evaluation, covers all const contexts (static, const fn, ...)
C-bug
Category: This is a bug.
needs-triage
This issue may need triage. Remove it if it has been sufficiently triaged.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I tried this code:
I expected to see this happen: Both constants compile or both fail to compile.
Instead, this happened:
BAD
failed 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
The text was updated successfully, but these errors were encountered: