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 aAnonConst
. 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. ReturnsNone
if the input was not a named constant. - valtree_
to_ 🔒constant_ expr