Promotion of non-ZST mutable references is incompatible with const_mut_refs #75556
Labels
A-const-eval
Area: constant evaluation (mir interpretation)
C-bug
Category: This is a bug.
F-const_mut_refs
`#![feature(const_mut_refs)]`
requires-nightly
This issue requires a nightly compiler in some way.
Consider the following code:
This should just work. But instead it throws an error:
The reason for this is that
&mut [1,2,3]
gets lifetime extended via promotion, so this reference now points to a separate mutable static -- but mutable statics cannot be mutated during CTFE.I see no way to fix this, other than stopping to promote mutable references -- which we should IMO do anyway, they are a very strange and unprincipled special case. Just imagine doing this in a loop, suddenly all these different and mutable allocations share the same address...
Cc @rust-lang/wg-const-eval
The text was updated successfully, but these errors were encountered: