Expand description
hir_def
crate contains everything between macro expansion and type
inference.
It defines various items (structs, enums, traits) which comprises Rust code, as well as an algorithm for resolving paths to such entities.
Note that hir_def
is a work in progress, so not all of the above is
actually true.
Re-exports§
pub use self::hir::type_ref;
pub use rustc_abi as layout;
pub use rustc_abi as layout;
pub use rustc_abi as layout;
Modules§
- A higher level attributes based on TokenTree, with also some shortcuts.
- Defines
Body
: a lowered representation of bodies of functions, statics and consts. - This module defines built-in types.
- Contains basic data about various HIR declarations.
- Defines database & queries for name resolution.
- This module defines a
DynMap
– a container for heterogeneous maps. - Macro expansion utilities.
- An algorithm to find a path to refer to a certain item.
- Many kinds of items or constructs can have generic parameters: functions, structs, impls, traits, etc. This module provides a common HIR for these generic parameters. See also the
Generics
type and thegenerics_of
query in rustc. - This module describes hir-level representation of expressions.
- A map of all publicly exported items in a crate.
- Describes items defined or visible (ie, imported) in a certain scope. This is shared between modules and blocks.
- A simplified AST that only contains items.
- Collects lang items: items marked with
#[lang = "..."]
attribute. - Context for lowering paths.
- This module implements import-resolution/macro expansion algorithm.
- A desugared representation of paths like
crate::foo
or<Type as Trait>::bar
. - In rust, it is possible to have a value, a type and a macro with the same name without conflicts.
- Name resolution façade.
- Utilities for mapping between hir IDs and the surface syntax.
- Defines hir-level representation of visibility (e.g.
pub
andpub(crate)
).
Structs§
- Id of the anonymous const block expression and patterns. This is very similar to
ClosureId
and shouldn’t be aDefWithBodyId
since its type inference is dependent on its parent. - A TypeOrConstParamId with an invariant that it actually belongs to a const
- A
ModuleId
that is always a crate’s root module. - A wrapper around three booleans
- A constant in a type as a substitution for const generics (like
Foo<{ 2 + 2 }>
) or as an array length (like[u8; 2 + 2]
). These constants are body owner and are a variant ofDefWithBodyId
. These are not calledAnonymousConstId
to prevent confusion withConstBlockId
. - A TypeOrConstParamId with an invariant that it actually belongs to a type
Enums§
- A Data Type
- The defs which have a body.
- A constant, which might appears as a const item, an anonymous const block in expressions or patterns, or as a constant in types with const generics.
- A generic param
- A macro
- The defs which can be visible in the module.
- Something that holds types, required for the current const arg lowering implementation as they need to be able to query where they are defined.
Traits§
- A helper trait for converting to MacroCallId
- A thing that we want to store in interned ids, but we don’t know its type in
hir-def
. This is currently only used inInTypeConstId
for storing the type (which has typeTy
defined in thehir-ty
crate) of the constant in its id, which is a temporary hack so we may want to remove this after removing that.
Type Aliases§
- An ID of a module, local to a
DefMap
.