pub(crate) struct CompilerInterface<'tcx> {
    pub tables: RefCell<Tables<'tcx, BridgeTys>>,
    pub cx: RefCell<CompilerCtxt<'tcx, BridgeTys>>,
}Expand description
Public API for querying compiler information.
All queries are delegated to rustc_public_bridge::context::CompilerCtxt
that provides similar APIs but based on internal rustc constructs.
Do not use this directly. This is currently used in the macro expansion.
Fields§
§tables: RefCell<Tables<'tcx, BridgeTys>>§cx: RefCell<CompilerCtxt<'tcx, BridgeTys>>Implementations§
Source§impl<'tcx> CompilerInterface<'tcx>
 
impl<'tcx> CompilerInterface<'tcx>
pub(crate) fn entry_fn(&self) -> Option<CrateItem>
Sourcepub(crate) fn all_local_items(&self) -> CrateItems
 
pub(crate) fn all_local_items(&self) -> CrateItems
Retrieve all items of the local crate that have a MIR associated with them.
Sourcepub(crate) fn mir_body(&self, item: DefId) -> Body
 
pub(crate) fn mir_body(&self, item: DefId) -> Body
Retrieve the body of a function. This function will panic if the body is not available.
Sourcepub(crate) fn has_body(&self, item: DefId) -> bool
 
pub(crate) fn has_body(&self, item: DefId) -> bool
Check whether the body of a function is available.
pub(crate) fn foreign_modules( &self, crate_num: CrateNum, ) -> Vec<ForeignModuleDef>
Sourcepub(crate) fn crate_functions(&self, crate_num: CrateNum) -> Vec<FnDef>
 
pub(crate) fn crate_functions(&self, crate_num: CrateNum) -> Vec<FnDef>
Retrieve all functions defined in this crate.
Sourcepub(crate) fn crate_statics(&self, crate_num: CrateNum) -> Vec<StaticDef>
 
pub(crate) fn crate_statics(&self, crate_num: CrateNum) -> Vec<StaticDef>
Retrieve all static items defined in this crate.
pub(crate) fn foreign_module(&self, mod_def: ForeignModuleDef) -> ForeignModule
pub(crate) fn foreign_items(&self, mod_def: ForeignModuleDef) -> Vec<ForeignDef>
pub(crate) fn all_trait_decls(&self) -> TraitDecls
pub(crate) fn trait_decls(&self, crate_num: CrateNum) -> TraitDecls
pub(crate) fn trait_decl(&self, trait_def: &TraitDef) -> TraitDecl
pub(crate) fn all_trait_impls(&self) -> ImplTraitDecls
pub(crate) fn trait_impls(&self, crate_num: CrateNum) -> ImplTraitDecls
pub(crate) fn trait_impl(&self, trait_impl: &ImplDef) -> ImplTrait
pub(crate) fn generics_of(&self, def_id: DefId) -> Generics
pub(crate) fn predicates_of(&self, def_id: DefId) -> GenericPredicates
pub(crate) fn explicit_predicates_of(&self, def_id: DefId) -> GenericPredicates
Sourcepub(crate) fn local_crate(&self) -> Crate
 
pub(crate) fn local_crate(&self) -> Crate
Get information about the local crate.
Sourcepub(crate) fn external_crates(&self) -> Vec<Crate>
 
pub(crate) fn external_crates(&self) -> Vec<Crate>
Retrieve a list of all external crates.
Sourcepub(crate) fn find_crates(&self, name: &str) -> Vec<Crate>
 
pub(crate) fn find_crates(&self, name: &str) -> Vec<Crate>
Find a crate with the given name.
Sourcepub(crate) fn def_name(&self, def_id: DefId, trimmed: bool) -> Symbol
 
pub(crate) fn def_name(&self, def_id: DefId, trimmed: bool) -> Symbol
Returns the name of given DefId.
Sourcepub(crate) fn tool_attrs(
    &self,
    def_id: DefId,
    attr: &[Symbol],
) -> Vec<Attribute>
 
pub(crate) fn tool_attrs( &self, def_id: DefId, attr: &[Symbol], ) -> Vec<Attribute>
Return registered tool attributes with the given attribute name.
FIXME(jdonszelmann): may panic on non-tool attributes. After more attribute work, non-tool attributes will simply return an empty list.
Single segmented name like #[clippy] is specified as &["clippy".to_string()].
Multi-segmented name like #[rustfmt::skip] is specified as &["rustfmt".to_string(), "skip".to_string()].
Sourcepub(crate) fn all_tool_attrs(&self, def_id: DefId) -> Vec<Attribute>
 
pub(crate) fn all_tool_attrs(&self, def_id: DefId) -> Vec<Attribute>
Get all tool attributes of a definition.
Sourcepub(crate) fn span_to_string(&self, span: Span) -> String
 
pub(crate) fn span_to_string(&self, span: Span) -> String
Returns printable, human readable form of Span.
Sourcepub(crate) fn get_filename(&self, span: &Span) -> Filename
 
pub(crate) fn get_filename(&self, span: &Span) -> Filename
Return filename from given Span, for diagnostic purposes.
Sourcepub(crate) fn get_lines(&self, span: &Span) -> LineInfo
 
pub(crate) fn get_lines(&self, span: &Span) -> LineInfo
Return lines corresponding to this Span.
Sourcepub(crate) fn is_foreign_item(&self, item: DefId) -> bool
 
pub(crate) fn is_foreign_item(&self, item: DefId) -> bool
Returns whether this is a foreign item.
Sourcepub(crate) fn foreign_item_kind(&self, def: ForeignDef) -> ForeignItemKind
 
pub(crate) fn foreign_item_kind(&self, def: ForeignDef) -> ForeignItemKind
Returns the kind of a given foreign item.
Sourcepub(crate) fn adt_kind(&self, def: AdtDef) -> AdtKind
 
pub(crate) fn adt_kind(&self, def: AdtDef) -> AdtKind
Returns the kind of a given algebraic data type.
Sourcepub(crate) fn adt_is_box(&self, def: AdtDef) -> bool
 
pub(crate) fn adt_is_box(&self, def: AdtDef) -> bool
Returns if the ADT is a box.
Sourcepub(crate) fn adt_is_simd(&self, def: AdtDef) -> bool
 
pub(crate) fn adt_is_simd(&self, def: AdtDef) -> bool
Returns whether this ADT is simd.
Sourcepub(crate) fn adt_is_cstr(&self, def: AdtDef) -> bool
 
pub(crate) fn adt_is_cstr(&self, def: AdtDef) -> bool
Returns whether this definition is a C string.
Sourcepub(crate) fn adt_repr(&self, def: AdtDef) -> ReprOptions
 
pub(crate) fn adt_repr(&self, def: AdtDef) -> ReprOptions
Returns the representation options for this ADT
Sourcepub(crate) fn fn_sig(&self, def: FnDef, args: &GenericArgs) -> PolyFnSig
 
pub(crate) fn fn_sig(&self, def: FnDef, args: &GenericArgs) -> PolyFnSig
Retrieve the function signature for the given generic arguments.
Sourcepub(crate) fn intrinsic(&self, item: DefId) -> Option<IntrinsicDef>
 
pub(crate) fn intrinsic(&self, item: DefId) -> Option<IntrinsicDef>
Retrieve the intrinsic definition if the item corresponds one.
Sourcepub(crate) fn intrinsic_name(&self, def: IntrinsicDef) -> Symbol
 
pub(crate) fn intrinsic_name(&self, def: IntrinsicDef) -> Symbol
Retrieve the plain function name of an intrinsic.
Sourcepub(crate) fn closure_sig(&self, args: &GenericArgs) -> PolyFnSig
 
pub(crate) fn closure_sig(&self, args: &GenericArgs) -> PolyFnSig
Retrieve the closure signature for the given generic arguments.
Sourcepub(crate) fn adt_variants_len(&self, def: AdtDef) -> usize
 
pub(crate) fn adt_variants_len(&self, def: AdtDef) -> usize
The number of variants in this ADT.
Sourcepub(crate) fn adt_discr_for_variant(
    &self,
    adt: AdtDef,
    variant: VariantIdx,
) -> Discr
 
pub(crate) fn adt_discr_for_variant( &self, adt: AdtDef, variant: VariantIdx, ) -> Discr
Discriminant for a given variant index of AdtDef.
Sourcepub(crate) fn coroutine_discr_for_variant(
    &self,
    coroutine: CoroutineDef,
    args: &GenericArgs,
    variant: VariantIdx,
) -> Discr
 
pub(crate) fn coroutine_discr_for_variant( &self, coroutine: CoroutineDef, args: &GenericArgs, variant: VariantIdx, ) -> Discr
Discriminant for a given variand index and args of a coroutine.
Sourcepub(crate) fn variant_name(&self, def: VariantDef) -> Symbol
 
pub(crate) fn variant_name(&self, def: VariantDef) -> Symbol
The name of a variant.
pub(crate) fn variant_fields(&self, def: VariantDef) -> Vec<FieldDef>
Sourcepub(crate) fn eval_target_usize(
    &self,
    mir_const: &MirConst,
) -> Result<u64, Error>
 
pub(crate) fn eval_target_usize( &self, mir_const: &MirConst, ) -> Result<u64, Error>
Evaluate constant as a target usize.
pub(crate) fn eval_target_usize_ty( &self, ty_const: &TyConst, ) -> Result<u64, Error>
Sourcepub(crate) fn try_new_const_zst(&self, ty: Ty) -> Result<MirConst, Error>
 
pub(crate) fn try_new_const_zst(&self, ty: Ty) -> Result<MirConst, Error>
Create a new zero-sized constant.
Sourcepub(crate) fn new_const_str(&self, value: &str) -> MirConst
 
pub(crate) fn new_const_str(&self, value: &str) -> MirConst
Create a new constant that represents the given string value.
Sourcepub(crate) fn new_const_bool(&self, value: bool) -> MirConst
 
pub(crate) fn new_const_bool(&self, value: bool) -> MirConst
Create a new constant that represents the given boolean value.
Sourcepub(crate) fn try_new_const_uint(
    &self,
    value: u128,
    uint_ty: UintTy,
) -> Result<MirConst, Error>
 
pub(crate) fn try_new_const_uint( &self, value: u128, uint_ty: UintTy, ) -> Result<MirConst, Error>
Create a new constant that represents the given value.
pub(crate) fn try_new_ty_const_uint( &self, value: u128, uint_ty: UintTy, ) -> Result<TyConst, Error>
Sourcepub(crate) fn new_rigid_ty(&self, kind: RigidTy) -> Ty
 
pub(crate) fn new_rigid_ty(&self, kind: RigidTy) -> Ty
Create a new type from the given kind.
Sourcepub(crate) fn new_box_ty(&self, ty: Ty) -> Ty
 
pub(crate) fn new_box_ty(&self, ty: Ty) -> Ty
Create a new box type, Box<T>, for the given inner type T.
Sourcepub(crate) fn def_ty_with_args(&self, item: DefId, args: &GenericArgs) -> Ty
 
pub(crate) fn def_ty_with_args(&self, item: DefId, args: &GenericArgs) -> Ty
Returns the type of given definition instantiated with the given arguments.
Sourcepub(crate) fn mir_const_pretty(&self, cnst: &MirConst) -> String
 
pub(crate) fn mir_const_pretty(&self, cnst: &MirConst) -> String
Returns literal value of a const as a string.
Sourcepub(crate) fn span_of_an_item(&self, def_id: DefId) -> Span
 
pub(crate) fn span_of_an_item(&self, def_id: DefId) -> Span
Span of an item.
pub(crate) fn ty_const_pretty(&self, ct: TyConstId) -> String
Sourcepub(crate) fn rigid_ty_discriminant_ty(&self, ty: &RigidTy) -> Ty
 
pub(crate) fn rigid_ty_discriminant_ty(&self, ty: &RigidTy) -> Ty
Get the discriminant Ty for this Ty if there’s one.
Sourcepub(crate) fn instance_body(&self, instance: InstanceDef) -> Option<Body>
 
pub(crate) fn instance_body(&self, instance: InstanceDef) -> Option<Body>
Get the body of an Instance which is already monomorphized.
Sourcepub(crate) fn instance_ty(&self, instance: InstanceDef) -> Ty
 
pub(crate) fn instance_ty(&self, instance: InstanceDef) -> Ty
Get the instance type with generic instantiations applied and lifetimes erased.
Sourcepub(crate) fn instance_args(&self, def: InstanceDef) -> GenericArgs
 
pub(crate) fn instance_args(&self, def: InstanceDef) -> GenericArgs
Get the instantiation types.
Sourcepub(crate) fn instance_def_id(&self, instance: InstanceDef) -> DefId
 
pub(crate) fn instance_def_id(&self, instance: InstanceDef) -> DefId
Get the instance.
Sourcepub(crate) fn instance_mangled_name(&self, instance: InstanceDef) -> Symbol
 
pub(crate) fn instance_mangled_name(&self, instance: InstanceDef) -> Symbol
Get the instance mangled name.
Sourcepub(crate) fn is_empty_drop_shim(&self, def: InstanceDef) -> bool
 
pub(crate) fn is_empty_drop_shim(&self, def: InstanceDef) -> bool
Check if this is an empty DropGlue shim.
Sourcepub(crate) fn mono_instance(&self, def_id: DefId) -> Instance
 
pub(crate) fn mono_instance(&self, def_id: DefId) -> Instance
Convert a non-generic crate item into an instance. This function will panic if the item is generic.
Sourcepub(crate) fn requires_monomorphization(&self, def_id: DefId) -> bool
 
pub(crate) fn requires_monomorphization(&self, def_id: DefId) -> bool
Item requires monomorphization.
Sourcepub(crate) fn resolve_instance(
    &self,
    def: FnDef,
    args: &GenericArgs,
) -> Option<Instance>
 
pub(crate) fn resolve_instance( &self, def: FnDef, args: &GenericArgs, ) -> Option<Instance>
Resolve an instance from the given function definition and generic arguments.
Sourcepub(crate) fn resolve_drop_in_place(&self, ty: Ty) -> Instance
 
pub(crate) fn resolve_drop_in_place(&self, ty: Ty) -> Instance
Resolve an instance for drop_in_place for the given type.
Sourcepub(crate) fn resolve_for_fn_ptr(
    &self,
    def: FnDef,
    args: &GenericArgs,
) -> Option<Instance>
 
pub(crate) fn resolve_for_fn_ptr( &self, def: FnDef, args: &GenericArgs, ) -> Option<Instance>
Resolve instance for a function pointer.
Sourcepub(crate) fn resolve_closure(
    &self,
    def: ClosureDef,
    args: &GenericArgs,
    kind: ClosureKind,
) -> Option<Instance>
 
pub(crate) fn resolve_closure( &self, def: ClosureDef, args: &GenericArgs, kind: ClosureKind, ) -> Option<Instance>
Resolve instance for a closure with the requested type.
Sourcepub(crate) fn eval_static_initializer(
    &self,
    def: StaticDef,
) -> Result<Allocation, Error>
 
pub(crate) fn eval_static_initializer( &self, def: StaticDef, ) -> Result<Allocation, Error>
Evaluate a static’s initializer.
Sourcepub(crate) fn eval_instance(
    &self,
    def: InstanceDef,
    const_ty: Ty,
) -> Result<Allocation, Error>
 
pub(crate) fn eval_instance( &self, def: InstanceDef, const_ty: Ty, ) -> Result<Allocation, Error>
Try to evaluate an instance into a constant.
Sourcepub(crate) fn global_alloc(&self, id: AllocId) -> GlobalAlloc
 
pub(crate) fn global_alloc(&self, id: AllocId) -> GlobalAlloc
Retrieve global allocation for the given allocation ID.
Sourcepub(crate) fn vtable_allocation(
    &self,
    global_alloc: &GlobalAlloc,
) -> Option<AllocId>
 
pub(crate) fn vtable_allocation( &self, global_alloc: &GlobalAlloc, ) -> Option<AllocId>
Retrieve the id for the virtual table.
pub(crate) fn krate(&self, def_id: DefId) -> Crate
pub(crate) fn instance_name(&self, def: InstanceDef, trimmed: bool) -> Symbol
Sourcepub(crate) fn target_info(&self) -> MachineInfo
 
pub(crate) fn target_info(&self) -> MachineInfo
Return information about the target machine.
Sourcepub(crate) fn instance_abi(&self, def: InstanceDef) -> Result<FnAbi, Error>
 
pub(crate) fn instance_abi(&self, def: InstanceDef) -> Result<FnAbi, Error>
Get an instance ABI.
Sourcepub(crate) fn fn_ptr_abi(&self, fn_ptr: PolyFnSig) -> Result<FnAbi, Error>
 
pub(crate) fn fn_ptr_abi(&self, fn_ptr: PolyFnSig) -> Result<FnAbi, Error>
Get the ABI of a function pointer.
Sourcepub(crate) fn layout_shape(&self, id: Layout) -> LayoutShape
 
pub(crate) fn layout_shape(&self, id: Layout) -> LayoutShape
Get the layout shape.
Sourcepub(crate) fn place_pretty(&self, place: &Place) -> String
 
pub(crate) fn place_pretty(&self, place: &Place) -> String
Get a debug string representation of a place.
Sourcepub(crate) fn binop_ty(&self, bin_op: BinOp, rhs: Ty, lhs: Ty) -> Ty
 
pub(crate) fn binop_ty(&self, bin_op: BinOp, rhs: Ty, lhs: Ty) -> Ty
Get the resulting type of binary operation.
Sourcepub(crate) fn unop_ty(&self, un_op: UnOp, arg: Ty) -> Ty
 
pub(crate) fn unop_ty(&self, un_op: UnOp, arg: Ty) -> Ty
Get the resulting type of unary operation.
Sourcepub(crate) fn associated_items(&self, def_id: DefId) -> AssocItems
 
pub(crate) fn associated_items(&self, def_id: DefId) -> AssocItems
Get all associated items of a definition.
Auto Trait Implementations§
impl<'tcx> DynSend for CompilerInterface<'tcx>
impl<'tcx> !DynSync for CompilerInterface<'tcx>
impl<'tcx> !Freeze for CompilerInterface<'tcx>
impl<'tcx> !RefUnwindSafe for CompilerInterface<'tcx>
impl<'tcx> !Send for CompilerInterface<'tcx>
impl<'tcx> !Sync for CompilerInterface<'tcx>
impl<'tcx> Unpin for CompilerInterface<'tcx>
impl<'tcx> !UnwindSafe for CompilerInterface<'tcx>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, R> CollectAndApply<T, R> for T
 
impl<T, R> CollectAndApply<T, R> for T
Source§impl<T> Instrument for T
 
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
 
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
 
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
 
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
 
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
 
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<P> IntoQueryParam<P> for P
 
impl<P> IntoQueryParam<P> for P
fn into_query_param(self) -> P
Source§impl<T> MaybeResult<T> for T
 
impl<T> MaybeResult<T> for T
Source§impl<T> Pointable for T
 
impl<T> Pointable for T
Source§impl<I, T, U> Upcast<I, U> for Twhere
    U: UpcastFrom<I, T>,
 
impl<I, T, U> Upcast<I, U> for Twhere
    U: UpcastFrom<I, T>,
Source§impl<I, T> UpcastFrom<I, T> for T
 
impl<I, T> UpcastFrom<I, T> for T
fn upcast_from(from: T, _tcx: I) -> T
Source§impl<Tcx, T> Value<Tcx> for Twhere
    Tcx: DepContext,
 
impl<Tcx, T> Value<Tcx> for Twhere
    Tcx: DepContext,
default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed, ) -> T
Source§impl<T> WithSubscriber for T
 
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
 
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
 
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<T> ErasedDestructor for Twhere
    T: 'static,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 472 bytes