-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Encode MIR for const ctors in metadata and allow eval for them #134873
base: master
Are you sure you want to change the base?
Conversation
13cd788
to
55cc8e4
Compare
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Encode MIR for const ctors in metadata Fixes rust-lang#132985. This is needed for them to be usable under `min_generic_const_args`. They are not currently encoded for some reason. r? `@BoxyUwU`
See previous discussion here: #131081 (comment). It seems like the only concerns were perf (which is currently being run on this PR), and also making sure it made sense to wg-const-eval? |
cc @fee1-dead |
This comment has been minimized.
This comment has been minimized.
They are not encoded because they are currently lowered in expression position (i.e. from Since AFAICT we want to represent consts in I think this approach makes sense and if this isn't too expensive, we'd probably be best off doing this rather than -- for example -- introducing a new hack to make up for that missing MIR body when we pass a struct literal in a generic arg. |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Right, this is consistent with what I understand too. I'm not sure why I said "for some reason" -- I'll fix the commit message/PR description before merging. EDIT: Fixed. Also feel free to edit yourself if anything's unclear. :) |
55cc8e4
to
ddce93d
Compare
This is needed for them to be usable under `min_generic_const_args` (mgca). Whenever a const ctor appears as an expression, like in `let x = Foo;`, it is directly lowered to a construction of an aggregate value in MIR, instead of using the const generated for it. The anon const approach for generic const exprs works similarly, by creating an anon const with the aggregate as its body. However, with mgca, we want to avoid anon consts, so we need to use the const item. They were not previously encoded in the metadata MIR, so they could not be used cross-crate, and they were not able to be evaluated. This change fixes that.
ddce93d
to
e1f2703
Compare
The job Click to see the possible cause of the failure (guessed by this bot)
|
Finished benchmarking commit (e10a2b0): comparison URL. Overall result: ❌ regressions - please read the text belowBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (primary 0.4%, secondary 7.9%)This 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.
CyclesResults (primary 0.6%, secondary 15.8%)This 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.
Binary sizeResults (primary 0.3%, secondary 7.7%)This 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: 763.48s -> 762.494s (-0.13%) |
Fixes #132985.
This is needed for them to be usable under
min_generic_const_args
(mgca).Whenever a const ctor appears as an expression, like in
let x = Foo;
,it is directly lowered to a construction of an aggregate value in MIR,
instead of using the const generated for it. The anon const approach for
generic const exprs works similarly, by creating an anon const with the
aggregate as its body. However, with mgca, we want to avoid anon consts,
so we need to use the const item. They were not previously encoded in
the metadata MIR, so they could not be used cross-crate, and they were
not able to be evaluated. This change fixes that.
r? @BoxyUwU