-
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
Tracking Issue for const_heap
#79597
Comments
As discussed here, this feature makes |
Btw, given how far-reaching the consequences of this feature are, I wonder if doing this without an RFC is really appropriate. But it could make sense to experiment some more with what can be done for transient vs. non-transient allocations, and how @oli-obk something is wrong with "implementation history", it links to the same PR twice. |
The experimentation that @vn-ki has been doing has exposed various problems that aren't even related to heap stuff itself, but are prerequisites. I believe we should keep on doing this experimentation, just to find out what all the problems are and how a possible implementation could look. Doing this in the abstract has not allowed us to realize what the dependency graph actually is and I will be updating the skill tree to reflect that as we gain more information. Some examples off the top of my head:
|
The first three points don't seem really related to heap allocations though? |
They are not, they are prerequisites for |
Is there a separate issue for this? I think this is closely related to some of the other issues that came up over the last year -- where we have a restriction that applies to the final value of all consts, but be unnecessarily apply it even during the course of the computation -- since we have no good way to otherwise ensure that the final value is okay. |
There is not. I have a local branch that generalizes to all such checks, so we'll be able to just check them on the final value |
For associated consts, I assume that's a post-monomorphization error then? (I know this is off-topic here, that's why I asked if there is a better place.^^) |
No... this is a static check that is overzealous in the presence of generics and such. |
Okay, looking forward to it. :) Doing a write-up first before finishing the implementation could also help (but we can also do that later if you prefer... I just think we should do it before landing; "writeup later" hasn't worked out well for us in the past^^). |
I personally think that heap allocation at compile time should be done independently. It is a bad idea to include it in I would suggest independently create
It is just like running |
What you describe (and as you noted), can already be done via That said, at the current design phase, you can statically know wheter a |
How far is the implementation state from being able to construct a It would be pretty useful for string interner in the compiler itself given that available static alternatives like |
Very far. This requires not just const heap, but also all kinds of trait methods to be |
Add `intrinsics::const_deallocate` Tracking issue: rust-lang#79597 Related: rust-lang#91884 This allows deallocation of a memory allocated by `intrinsics::const_allocate`. At the moment, this can be only used to reduce memory usage, but in the future this may be useful to detect memory leaks (If an allocated memory remains after evaluation, raise an error...?).
This is a tracking issue for rust-lang/const-eval#20
The feature gate for the issue is
#![feature(const_heap)]
.The general design can be found here
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Steps
Unresolved Questions
Global
allocator? This would give us post-monomorpization errors. More details can be found in https://hackmd.io/h2O2vkj3RimrBTfm9hvZWA#Transient-heap-allocations-via-Globalconst fn
: before this change, aconst fn() -> T
would inevitably have to always return the same value; after this change, that is no longer the case. Withptr_guaranteed_eq
, this can even to some extend be observed during CTFE. So in that sense, this feature is much bigger than anything we ever stabilized for CTFE.build.rs
scripts or proc macros that generate the appropriate constants/statics and references them. Const heap will "just" make generating static/const allocations more convenient.const fn foo() -> &'static Cell<i32>
, which could then be used to initialize aconst FOO: &'static Cell<i32>
which is unsound (and only caught by dynamic checks). The tracking issue for interior mutability behind references is Tracking Issue forconst_refs_to_cell
#80384Implementation history
The text was updated successfully, but these errors were encountered: