Add FieldDef to StableMIR and methods to get type
This commit is contained in:
parent
e19c7cd159
commit
1720b108f7
6 changed files with 95 additions and 5 deletions
|
@ -9,7 +9,7 @@ use crate::mir::alloc::{AllocId, GlobalAlloc};
|
|||
use crate::mir::mono::{Instance, InstanceDef, StaticDef};
|
||||
use crate::mir::Body;
|
||||
use crate::ty::{
|
||||
AdtDef, AdtKind, Allocation, ClosureDef, ClosureKind, Const, FnDef, GenericArgs,
|
||||
AdtDef, AdtKind, Allocation, ClosureDef, ClosureKind, Const, FieldDef, FnDef, GenericArgs,
|
||||
GenericPredicates, Generics, ImplDef, ImplTrait, LineInfo, PolyFnSig, RigidTy, Span, TraitDecl,
|
||||
TraitDef, Ty, TyKind, VariantDef,
|
||||
};
|
||||
|
@ -76,6 +76,7 @@ pub trait Context {
|
|||
|
||||
/// The name of a variant.
|
||||
fn variant_name(&self, def: VariantDef) -> Symbol;
|
||||
fn variant_fields(&self, def: VariantDef) -> Vec<FieldDef>;
|
||||
|
||||
/// Evaluate constant as a target usize.
|
||||
fn eval_target_usize(&self, cnst: &Const) -> Result<u64, Error>;
|
||||
|
@ -89,6 +90,9 @@ pub trait Context {
|
|||
/// Returns the type of given crate item.
|
||||
fn def_ty(&self, item: DefId) -> Ty;
|
||||
|
||||
/// Returns the type of given definition instantiated with the given arguments.
|
||||
fn def_ty_with_args(&self, item: DefId, args: &GenericArgs) -> Result<Ty, Error>;
|
||||
|
||||
/// Returns literal value of a const as a string.
|
||||
fn const_literal(&self, cnst: &Const) -> String;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue