Trait hax_frontend_exporter::ConstantExt

source ·
pub trait ConstantExt<'tcx>: Sized + Debug {
    // Required method
    fn eval_constant<S: UnderOwnerState<'tcx>>(&self, s: &S) -> Option<Self>;

    // Provided method
    fn translate_uneval(
        &self,
        s: &impl UnderOwnerState<'tcx>,
        ucv: UnevaluatedConst<'tcx>,
        span: Span,
    ) -> TranslateUnevalRes<Self> { ... }
}

Required Methods§

source

fn eval_constant<S: UnderOwnerState<'tcx>>(&self, s: &S) -> Option<Self>

Provided Methods§

source

fn translate_uneval( &self, s: &impl UnderOwnerState<'tcx>, ucv: UnevaluatedConst<'tcx>, span: Span, ) -> TranslateUnevalRes<Self>

Performs a one-step translation of a constant.

  • When a constant refers to a named top-level constant, we want to use that, thus we translate the constant to a ConstantExprKind::GlobalName. This is captured by the variant TranslateUnevalRes::GlobalName.
  • When a constant refers to a anonymous top-level constant, we evaluate it. If the evaluation fails, we report an error: we expect every AnonConst to be reducible. Otherwise, we return the variant TranslateUnevalRes::EvaluatedConstant.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<'tcx> ConstantExt<'tcx> for Const<'tcx>

source§

fn eval_constant<S: UnderOwnerState<'tcx>>(&self, s: &S) -> Option<Self>

source§

impl<'tcx> ConstantExt<'tcx> for Const<'tcx>

source§

fn eval_constant<S: UnderOwnerState<'tcx>>(&self, s: &S) -> Option<Self>

Implementors§