Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking issue for `&mut T` in const fn #57349
Comments
Centril
added
T-lang
C-tracking-issue
needs-rfc
labels
Jan 5, 2019
Centril
changed the title
Mutation in const fn
Tracking issue for `&mut T` in const fn
Jan 5, 2019
This comment has been minimized.
This comment has been minimized.
Centril
added
A-const-fn
A-const-eval
labels
Jan 5, 2019
This comment has been minimized.
This comment has been minimized.
|
I could be wrong, but based on previous conversation with @eddyb, this is very much in the plans. They originally wanted to even allow CTFE to mutate statics during the scope of their execution, until it was discussed out that this is undesirable because it would allow a single function call to behave differently depending on whether or not CTFE was used to precompute the function. |
This comment has been minimized.
This comment has been minimized.
|
Please cc @oli-obk and/or @RalfJung on all CTFE-related things. In terms of the implementation, we plan to allow all pointers where the memory they point to is on the CTFE "stack" (i.e. not a static) and maybe "heap" in the future, with maybe some limitations around But miri can already interpret more than everything you'd reasonably want to run in CTFE. |
ExpHP commentedJan 5, 2019
•
edited
This could be considered a subissue of #24111, however it does not (yet) correspond to a feature in the original RFC, nor does it necessarily correspond to anything that is implemented. It is simply that @Centril suggested I make an issue.
Basically, because
&mutreferences are unique in rust, mutations (except through interior mutability) are not actually observable. Therefore, in theory, it would seem thatconst fncould support mutation. i.e.:&mutarguments could be accepted&mutexpressions)x = y;or*x = y;).I could not locate any real discussion on this to date.
Presently, we need to discuss whether we want to do this, and if so, what the scope is.