opportunistically evaluate constants while populating mir::Body::required_consts
#71802
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.