-
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
unstably allow constants to refer to statics and read from immutable statics #119614
Conversation
The Miri subtree was changed cc @rust-lang/miri Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fine by me, as long as the tracking issue mentions this new source of monomorphization time errors as an open question to put to T-lang
tests/ui/feature-gates/feature-gate-const-refs-to-static.stderr
Outdated
Show resolved
Hide resolved
768c020
to
7f21ace
Compare
This comment has been minimized.
This comment has been minimized.
6a0f1bc
to
1ad4b85
Compare
This comment has been minimized.
This comment has been minimized.
1ad4b85
to
8db79e5
Compare
This comment has been minimized.
This comment has been minimized.
8db79e5
to
8344f1b
Compare
This comment has been minimized.
This comment has been minimized.
8344f1b
to
60b12fd
Compare
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
I realized I have to make validation descend into statics, or else valtree construction can encounter unvalidated data. This also makes the feature more conservative: consts that refer to mutable memory behind a shared reference are immediately rejected, not just when they are used as a pattern. |
d9943e9
to
0eb6726
Compare
This comment has been minimized.
This comment has been minimized.
0eb6726
to
aee26a8
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
aea0509
to
c7cca7c
Compare
seems fishy to allow valtrees to read from immutable statics. That means we meaningfully lose the static's identity during rountdrip. |
Valtrees are about the value. How would the static's identity matter? |
@bors r- conflicts |
ea7654f
to
4def373
Compare
@bors r=oli-obk |
☀️ Test successful - checks-actions |
Finished benchmarking commit (6cc4843): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Bootstrap: 666.587s -> 667.259s (0.10%) |
…li-obk add another test for promoteds-in-static rust-lang#119614 led to validation of promoteds recursing into statics. These statics can point to `static mut` and interior mutable `static` and do other things we don't allow in `const`, but promoteds are validated as `const`, so we get strange errors (saying "in `const`" when there is no const) and surprising validation failures. rust-lang#120960 fixes that; this here adds another test. r? `@oli-obk` Fixes rust-lang#120968
…li-obk add another test for promoteds-in-static rust-lang#119614 led to validation of promoteds recursing into statics. These statics can point to `static mut` and interior mutable `static` and do other things we don't allow in `const`, but promoteds are validated as `const`, so we get strange errors (saying "in `const`" when there is no const) and surprising validation failures. rust-lang#120960 fixes that; this here adds another test. r? ``@oli-obk`` Fixes rust-lang#120968
Rollup merge of rust-lang#120970 - RalfJung:static-promoted-test, r=oli-obk add another test for promoteds-in-static rust-lang#119614 led to validation of promoteds recursing into statics. These statics can point to `static mut` and interior mutable `static` and do other things we don't allow in `const`, but promoteds are validated as `const`, so we get strange errors (saying "in `const`" when there is no const) and surprising validation failures. rust-lang#120960 fixes that; this here adds another test. r? ``@oli-obk`` Fixes rust-lang#120968
add another test for promoteds-in-static rust-lang/rust#119614 led to validation of promoteds recursing into statics. These statics can point to `static mut` and interior mutable `static` and do other things we don't allow in `const`, but promoteds are validated as `const`, so we get strange errors (saying "in `const`" when there is no const) and surprising validation failures. rust-lang/rust#120960 fixes that; this here adds another test. r? ``@oli-obk`` Fixes rust-lang/rust#120968
I am not aware of any fundamental reason why we cannot allow constants to mention statics. What we really need is that constants do not read from statics that can change their value:
r? @oli-obk -- if you are okay with experimenting with this feature, I will create a tracking issue.
Based on and blocked on #119044; only the last commit is new.