Open
Description
We can evaluate all constants that do not depend on generic parameters in
We make that a MutVisitor
that evaluates all constants that it can and replaces them in-place and only adds those that it couldn't evaluate to the required_const
list.
This way we never have to evaluate another constant in the entire MIR optimization pipeline, because we know none can be evaluated (modulo those that we already evaluate for merging required_const
s during inlining.
cc @rust-lang/wg-mir-opt I think I like having the above invariant. It will make working with constants in MIR much simpler and make any kind of error handling that would have to be implemented unified into a single location.
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
RalfJung commentedon May 2, 2020
Ideally that would actually dispatch through the
const_eval
error handling to have it all centralized there...Same goes for the const error reporting that codegen is doing, FWIW.
Which makes me wonder, can we move this impl block to
librustc_mir/const_eval/error.rs
or so? This is solely CTFE error logic, so logically part of the "CTFE <-> rustc glue" that we otherwise have inlibrustc_mir::const_eval
.oli-obk commentedon May 2, 2020
hmm right, I think nothing from librustc uses this anymore. We can't move the impl block, but we can make the functions free functions.
RalfJung commentedon May 2, 2020
Yeah something like that.
So we also use this issue to track cleaning up the error reporting story more generally? If we also include cleaning up this then I think we can close #67191, AFAIK that's all that's left.
[-]opportunistically evaluate constants while populating `mir::Body::required_consts`[/-][+]opportunistically evaluate constants while populating `mir::Body::required_consts` + CTFE error cleanup[/+]RalfJung commentedon May 3, 2020
rust-lang/miri#1382 is also related, this is Miri lacking the code that codegen has to properly report post-monomorphization errors.
7 remaining items