Struct rustc_hir::hir::Crate[][src]

pub struct Crate<'hir> {
Show 14 fields pub item: Mod<'hir>, pub exported_macros: &'hir [MacroDef<'hir>], pub non_exported_macro_attrs: &'hir [Attribute], pub items: BTreeMap<ItemId, Item<'hir>>, pub trait_items: BTreeMap<TraitItemId, TraitItem<'hir>>, pub impl_items: BTreeMap<ImplItemId, ImplItem<'hir>>, pub foreign_items: BTreeMap<ForeignItemId, ForeignItem<'hir>>, pub bodies: BTreeMap<BodyId, Body<'hir>>, pub trait_impls: BTreeMap<DefId, Vec<LocalDefId>>, pub body_ids: Vec<BodyId>, pub modules: BTreeMap<LocalDefId, ModuleItems>, pub proc_macros: Vec<HirId>, pub trait_map: FxHashMap<LocalDefId, FxHashMap<ItemLocalId, Box<[TraitCandidate]>>>, pub attrs: BTreeMap<HirId, &'hir [Attribute]>,
Expand description

The top-level data structure that stores the entire contents of the crate currently being compiled.

For more details, see the rustc dev guide.


item: Mod<'hir>exported_macros: &'hir [MacroDef<'hir>]non_exported_macro_attrs: &'hir [Attribute]items: BTreeMap<ItemId, Item<'hir>>trait_items: BTreeMap<TraitItemId, TraitItem<'hir>>impl_items: BTreeMap<ImplItemId, ImplItem<'hir>>foreign_items: BTreeMap<ForeignItemId, ForeignItem<'hir>>bodies: BTreeMap<BodyId, Body<'hir>>trait_impls: BTreeMap<DefId, Vec<LocalDefId>>body_ids: Vec<BodyId>

A list of the body ids written out in the order in which they appear in the crate. If you’re going to process all the bodies in the crate, you should iterate over this list rather than the keys of bodies.

modules: BTreeMap<LocalDefId, ModuleItems>

A list of modules written out in the order in which they appear in the crate. This includes the main crate module.

proc_macros: Vec<HirId>

A list of proc macro HirIds, written out in the order in which they are declared in the static array generated by proc_macro_harness.

trait_map: FxHashMap<LocalDefId, FxHashMap<ItemLocalId, Box<[TraitCandidate]>>>

Map indicating what traits are in scope for places where this is relevant; generated by resolve.

attrs: BTreeMap<HirId, &'hir [Attribute]>

Collected attributes from HIR nodes.


Visits all items in the crate in some deterministic (but unspecified) order. If you just need to process every item, but don’t care about nesting, this method is the best choice.

If you do care about nesting – usually because your algorithm follows lexical scoping rules – then you want a different approach. You should override visit_nested_item in your visitor and then call intravisit::walk_crate instead.

A parallel version of visit_all_item_likes.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.


Note: Most layout information is completely unstable and may be different between compiler versions and platforms. 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: 328 bytes