Rollup of 8 pull requests by Centril · Pull Request #67532 · rust-lang/rust (original) (raw)
…r=oli-obk
Add simpler entry points to const eval for common usages.
I found the tcx.const_eval
API to be complex/awkward to work with, because of the inherent complexity from all of the different situations it is called from. Though it mainly used in one of the following ways:
- Evaluates the value of a constant without any substitutions, e.g. evaluating a static, discriminant, etc.
- Evaluates the value of a resolved instance of a constant. this happens when evaluating unevaluated constants or normalising trait constants.
- Evaluates a promoted constant.
This PR adds three new functions const_eval_mono
, const_eval_resolve
, and const_eval_promoted
to TyCtxt
, which each cater to one of the three ways tcx.const_eval
is normally used.