Hi all,
Could someone explain to me how to evaluate a constant operand (mir::Operand::Constant
), to the corresponding ty::Const
?
In particular, I don't know how to handle the case of a promoted constant literal:
mir::Constant{ literal: mir::Literal::Promoted { index }, .. }
The tcx.const_eval(..)
method seems to do what I want, but I don't know how to get the def_id
of the constant that I'm considering. That is, to build the GlobalId
argument it seems that I need a ty::Instance
, and to build it I need the def_id
of the constant literal.
Edit: to add a bit of context, the mir::Operand::Constant
that contains the promoted constant literal comes from an assignment in the MIR of a procedure that I'm analyzing.