1
Fork 0

Add Variant and a few more APIs to stable_mir

This commit is contained in:
Celina G. Val 2023-11-30 20:22:20 -08:00
parent e281163dc8
commit efaf4258ba
7 changed files with 153 additions and 39 deletions

View file

@ -11,7 +11,7 @@ use crate::mir::Body;
use crate::ty::{
AdtDef, AdtKind, Allocation, ClosureDef, ClosureKind, Const, FnDef, GenericArgs,
GenericPredicates, Generics, ImplDef, ImplTrait, LineInfo, PolyFnSig, RigidTy, Span, TraitDecl,
TraitDef, Ty, TyKind,
TraitDef, Ty, TyKind, VariantDef,
};
use crate::{
mir, Crate, CrateItem, CrateItems, DefId, Error, Filename, ImplTraitDecls, ItemKind, Symbol,
@ -71,6 +71,12 @@ pub trait Context {
/// Retrieve the function signature for the given generic arguments.
fn fn_sig(&self, def: FnDef, args: &GenericArgs) -> PolyFnSig;
/// The number of variants in this ADT.
fn adt_variants_len(&self, def: AdtDef) -> usize;
/// The name of a variant.
fn variant_name(&self, def: VariantDef) -> Symbol;
/// Evaluate constant as a target usize.
fn eval_target_usize(&self, cnst: &Const) -> Result<u64, Error>;