-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
&mut T
during the evaluation of a const/static initializer
#16
Comments
&mut T
and &NonFreezeType
during the evaluation of a const/static initializer&mut T
during the evaluation of a const/static initializer
So what about constants of type |
That's fine, even on nightly: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2015&gist=a9a11a688079f6535f8e7e548cdbcd3a Const eval will error out if you leak a local and you can't promote a mutable reference to something other than |
Hm. I am still confused by what exactly the guarantee is that we need. So it is okay to have
That's because I see two parts to this:
|
Also, shouldn't this be tracked in /~https://github.com/rust-rfcs/const-eval/? |
we are in
Not from within another static/const. If an immutable (and thus safe to access) static contained a mutable reference to another static, then you'd be able to "safely" obtain two mutable references to the same static, which is obviously wrong.
Yes, Yes, No I don't see how we could lift that and how that would be sound. Making this a validation guarantee does have some nice properties, but fails out of the same reasons that the freeze and needs drop checks can't be part of validation. Associated constants would end up causing monomorphization time errors. |
Oh, eh... look, a three-headed monkey! 🐵 🐵 🐵 |
Ah that's your concern. Yeah you should only get shared refs there. So without interior mutability, there wouldn't even be a problem... |
While is very important to not have
static
orconst
items of such types, during the evaluation of astatic
orconst
item we might want to work with intermediate values of this type.E.g.
seems totally reasonable.
The text was updated successfully, but these errors were encountered: