Expand description
HIR (previously known as descriptors) provides a high-level object-oriented access to Rust code.
The principal difference between HIR and syntax trees is that HIR is bound to a particular crate instance. That is, it has cfg flags and features applied. So, the relation between syntax and HIR is many-to-one.
HIR is the public API of the all of the compiler logic above syntax trees. It is written in “OO” style. Each type is self contained (as in, it knows its parents and full context). It should be “clean code”.
hir_* crates are the implementation of the compiler logic.
They are written in “ECS” style, with relatively little abstractions.
Many types are not self-contained, and explicitly use local indexes, arenas, etc.
hir is what insulates the “we don’t know how to actually write an incremental compiler”
from the ide with completions, hovers, etc. It is a (soft, internal) boundary:
https://www.tedinski.com/2018/02/06/system-boundaries.html.
Re-exports§
- pub use crate::diagnostics::*;
Modules§
- db
- Re-exports various subcrates databases so that the calling code can depend
only on hir. This breaks abstraction boundary a bit, it would be cool if we didn’t do that.
- diagnostics
- Re-export diagnostics such that clients of hirdon’t have to depend on low-level crates.
- import_map 
- A map of all publicly exported items in a crate.
- mir
- MIR definitions and implementation
- next_solver 
- Things relevant to the next trait solver.
- sym
- Module defining all known symbols required by the rest of rust-analyzer.
- symbols
- File symbol extraction.
- term_search 
- Term search
- tt
Macros§
Structs§
- Adjustment
- Attr
- AttrId
- AttrSource Map 
- AttributeTemplate 
- A template that the attribute input must match.
Only top-level shape (#[attr]vs#[attr(...)]vs#[attr = ...]) is considered now.
- Attrs
- Desugared attributes of an item post cfg_attrexpansion.
- AttrsWith Owner 
- BuiltinAttr 
- BuiltinType 
- Callable
- CaptureUsage Source 
- CaptureUsages 
- CfgOptions
- Configuration options used for conditional compilation on items with cfgattributes. We have two kind of options in different namespaces: atomic options likeunix, and key-value options liketarget_arch="x86".
- ChangeWith Proc Macros 
- Closure
- ClosureCapture 
- Const
- ConstParam 
- Crate
- hir::Crate describes a single crate. It’s the main interface with which a crate’s dependencies interact. Mostly, it should be just a proxy for the root module.
- CrateDependency 
- DefMap
- Contains the results of (early) name resolution.
- DeriveHelper 
- DisplayTarget 
- EditionedFile Id 
- Enum
- EvaluatedConst 
- ExternBlock 
- ExternCrate Decl 
- Field
- FilePosition Wrapper 
- FileRange Wrapper 
- FindPath Config 
- A wrapper around three booleans
- Function
- GenericSubstitution 
- Impl
- InFileWrapper 
- InFile<T>stores a value of- Tinside a particular file/syntax tree.
- InlineAsmOperand 
- InstantiatedEnum 
- InstantiatedField 
- InstantiatedStruct 
- InstantiatedVariant 
- Label
- Layout
- LifetimeParam 
- Local
- A single local definition.
- LocalSource 
- Macro
- MacroCall Id 
- ModPath
- Module
- Name
- Nameis a wrapper around string, which is used in hir for both references and declarations. In theory, names should also carry hygiene info, but we are not there yet!
- OverloadedDeref 
- Param
- PathResolution PerNs 
- ProcMacros 
- ProcMacros Builder 
- SelfParam 
- Semantics
- Primary API to get semantic information, like types, from syntax trees.
- SemanticsImpl 
- SemanticsScope 
- SemanticsScopeencapsulates the notion of a scope (the set of visible names) at a particular program point.
- Static
- StaticLifetime 
- Struct
- Symbol
- ToolModule 
- Trait
- TraitId
- TraitRef 
- TupleField 
- Type
- TypeAlias 
- TypeInfo 
- TypeNs
- TypeOrConst Param 
- TypeParam 
- Union
- Variant
- VisibleTraits 
Enums§
- Access
- Adjust
- Adt
- A Data Type
- AssocItem 
- Invariant: inner.as_assoc_item(db).is_some()We do not actively enforce this invariant.
- AssocItem Container 
- AutoBorrow 
- BindingMode 
- CallableKind 
- CaptureKind 
- CastError 
- CfgAtom
- A simple configuration value passed in from the outside.
- CfgExpr
- ClosureStyle 
- Complete
- #[rust_analyzer::completions(...)]options.
- ConstEval Error 
- DefWithBody 
- The defs which have a body.
- DocLinkDef 
- Subset of ide_db::Definitionthat doc links can resolve to.
- DropGlue 
- DynCompatibilityViolation 
- ExternAssoc Item 
- Invariant: inner.as_extern_assoc_item(db).is_some()We do not actively enforce this invariant.
- FieldSource 
- FnAbi
- GenericDef 
- GenericParam 
- HirDisplayError 
- HirFileId 
- ItemContainer 
- ItemInNs 
- LangItem 
- A representation of all the valid language items in Rust.
- LayoutError 
- MacroKind 
- MethodViolation Code 
- MirEvalError 
- MirLowerError 
- ModuleDef 
- The defs which can be visible in the module.
- ModuleDefId 
- The defs which can be visible in the module.
- ModuleSource 
- Mutability
- Namespace
- PathKind 
- PathResolution 
- PointerCast 
- PrefixKind 
- Safety
- ScopeDef 
- For IDE only
- StructKind 
- TyFingerprint
- This is used as a key for indexing impls.
- TypeRef
- Compare ty::Ty
- UnsafetyReason 
- Variance
- VariantDef 
- Visibility
- Visibility of an item, with the path resolved.
Traits§
- AsAssocItem 
- AsExternAssoc Item 
- HasAttrs
- HasContainer
- HasCrate
- Trait for obtaining the defining crate of an item.
- HasSource
- HasVisibility
- HirDisplay
- HirWrite
- MethodCandidate Callback 
- PathCandidate Callback 
Functions§
- attach_db 
- attach_db_ allow_ change 
- clear_tls_ solver_ cache 
- Clears the thread-local trait solver cache.
- crate_def_ map 
- prettify_macro_ expansion 
- Inserts whitespace and replaces $cratein macro expansions.
- resolve_absolute_ path 
- resolve_doc_ path_ on 
- Resolves the item linkpoints to in the scope ofdef.
- setup_tracing