-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Ensure that evaluating or validating a constant never reads from a static #67337
Conversation
This comment has been minimized.
This comment has been minimized.
Oh I just realized this PR makes no sense. If the user points into the static, this PR won't detect that. We could poison |
This comment has been minimized.
This comment has been minimized.
So if I recall correctly, in rust-lang/const-eval#17 (comment) and https://github.com/rust-lang/const-eval/blob/master/const.md#reading-statics, I also came to the conclusion that we want to guard accesses during execution, and not the final value. |
0f986ca
to
c0faa51
Compare
That comment talks about not reading from (mutable) statics. I don't understand the connection to the final value not containing certain relocations.
Also, isn't code like this allowed? static FOO: i32 = 13;
const FOOPTR: &i32 = &FOO; So, I don't entirely understand how we even could backwards-compatibly forbid consts pointing to statics, and why we would want that? |
No:
|
Hmm... I guess I went overboard when looking at it from the perspective of the comment, but just referencing a static is not allowed on stable, so this is what we want to forbid right now. |
☔ The latest upstream changes (presumably #67485) made this pull request unmergeable. Please resolve the merge conflicts. |
Well, what this PR implement is not accessing a static. So the PR description is wrong, IMO. Except that, somehow, this also excludes referencing a static, and I am not sure why. |
c0faa51
to
fc0c48c
Compare
☔ The latest upstream changes (presumably #67540) made this pull request unmergeable. Please resolve the merge conflicts. |
and some uses of it will be illegal forever (e.g. mutable or interior mutable statics)
Co-Authored-By: Ralf Jung <[email protected]>
3168051
to
89250b9
Compare
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Looking good! r=me with tests blessed. |
@bors r=RalfJung |
📌 Commit 87fea04 has been approved by |
🌲 The tree is currently closed for pull requests below priority 100, this pull request will be tested once the tree is reopened |
…t, r=RalfJung Ensure that evaluating or validating a constant never reads from a static r? @RalfJung as per rust-lang#66302 (comment) This does not yet address the fact that evaluation of a constant can read from a static (under unleash-miri)
Rollup of 7 pull requests Successful merges: - #67337 (Ensure that evaluating or validating a constant never reads from a static) - #67543 (Add regression tests for fixed ICEs) - #67547 (Cleanup err codes) - #67551 (Add long error code explanation message for E0627) - #67561 (remove `description` from `Error` impls in docs) - #67569 (Clean up unsafety in char::encode_utf8) - #67572 (Use the chocolatey CDN directly to avoid the flaky API) Failed merges: r? @ghost
r? @RalfJung
as per #66302 (comment)
This does not yet address the fact that evaluation of a constant can read from a static (under unleash-miri)