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
hir
don’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
- 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
- Attr
Source Map - Attribute
Template - 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_attr
expansion. - Attrs
With Owner - Builtin
Attr - Builtin
Type - Callable
- Capture
Usage Source - Capture
Usages - CfgOptions
- Configuration options used for conditional compilation on items with
cfg
attributes. We have two kind of options in different namespaces: atomic options likeunix
, and key-value options liketarget_arch="x86"
. - Chalk
TyInterner - Change
With Proc Macros - Closure
- Closure
Capture - Const
- Const
Param - 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.
- Crate
Dependency - DefMap
- Contains the results of (early) name resolution.
- Derive
Helper - Display
Target - Editioned
File Id - Enum
- Evaluated
Const - Extern
Block - Extern
Crate Decl - Field
- File
Position Wrapper - File
Range Wrapper - Function
- Generic
Substitution - Impl
- Import
Path Config - A wrapper around three booleans
- InFile
Wrapper InFile<T>
stores a value ofT
inside a particular file/syntax tree.- Inline
AsmOperand - Label
- Layout
- Lifetime
Param - Local
- A single local definition.
- Local
Source - Macro
- Macro
Call Id - ModPath
- Module
- Name
Name
is 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!- Overloaded
Deref - Param
- Proc
Macros - Proc
Macros Builder - Self
Param - Semantics
- Primary API to get semantic information, like types, from syntax trees.
- Semantics
Impl - Semantics
Scope SemanticsScope
encapsulates the notion of a scope (the set of visible names) at a particular program point.- Static
- Static
Lifetime - Struct
- Symbol
- Tool
Module - Trait
- Trait
Alias - TraitId
- Trait
Ref - Tuple
Field - Type
- Type
Alias - Type
Info - Type
OrConst Param - Type
Param - Union
- Variant
- Visible
Traits
Enums§
- Access
- Adjust
- Adt
- A Data Type
- Assoc
Item - Invariant:
inner.as_assoc_item(db).is_some()
We do not actively enforce this invariant. - Assoc
Item Container - Auto
Borrow - Binding
Mode - Callable
Kind - Capture
Kind - Cast
Error - CfgAtom
- A simple configuration value passed in from the outside.
- CfgExpr
- Closure
Style - Complete
#[rust_analyzer::completions(...)]
options.- Const
Eval Error - DefWith
Body - The defs which have a body.
- DocLink
Def - Subset of
ide_db::Definition
that doc links can resolve to. - Drop
Glue - DynCompatibility
Violation - Extern
Assoc Item - Invariant:
inner.as_extern_assoc_item(db).is_some()
We do not actively enforce this invariant. - Field
Source - FnAbi
- Generic
Def - Generic
Param - HirDisplay
Error - HirFile
Id - Item
Container - Item
InNs - Lang
Item - A representation of all the valid language items in Rust.
- Layout
Error - Macro
Kind - Method
Violation Code - MirEval
Error - MirLower
Error - Module
Def - The defs which can be visible in the module.
- Module
DefId - The defs which can be visible in the module.
- Module
Source - Mutability
- Namespace
- Path
Kind - Path
Resolution - Pointer
Cast - Prefix
Kind - Safety
- Whether a function is safe or not.
- Scope
Def - For IDE only
- Struct
Kind - TyFingerprint
- This is used as a key for indexing impls.
- TypeRef
- Compare ty::Ty
- Unsafety
Reason - Variance
- Variant
Def - Visibility
- Visibility of an item, with the path resolved.
Traits§
- AsAssoc
Item - AsExtern
Assoc Item - HasAttrs
- HasContainer
- HasCrate
- Trait for obtaining the defining crate of an item.
- HasSource
- HasVisibility
- HirDisplay
- HirWrite
- Method
Candidate Callback - Path
Candidate Callback - Syntax
Context Ext
Functions§
- marks_
rev - prettify_
macro_ expansion - Inserts whitespace and replaces
$crate
in macro expansions. - resolve_
absolute_ path - resolve_
doc_ path_ on - Resolves the item
link
points to in the scope ofdef
.