Module uneval

Source
Expand description

Reconstruct structured expressions from rustc’s various constant representations.

Functions§

bits_and_type_to_float_constant_literal 🔒
Converts a bit-representation of a float of type ty to a constant literal
const_value_to_constant_expr
eval_mir_constant
Evaluate a mir::Const.
eval_ty_constant
Evaluate a ty::Const.
is_anon_const 🔒
Whether a DefId is a AnonConst. An anonymous constant is generated by Rustc, hoisting every constat bits from items as separate top-level items. This AnonConst mechanism is internal to Rustc; we don’t want to reflect that, instead we prefer inlining those. is_anon_const is used to detect such AnonConst so that we can evaluate and inline them.
op_to_const 🔒
Use the const-eval interpreter to convert an evaluated operand back to a structured constant expression.
scalar_int_to_constant_literal 🔒
translate_constant_reference
Attempts to translate a ty::UnevaluatedConst into a constant expression. This handles cases of references to top-level or associated constants. Returns None if the input was not a named constant.
valtree_to_constant_expr 🔒