2019-01-09 00:47:12 +01:00
|
|
|
//! HIR (previously known as descriptors) provides a high-level object oriented
|
|
|
|
//! access to Rust code.
|
2018-11-28 03:42:26 +03:00
|
|
|
//!
|
|
|
|
//! 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
|
2019-01-09 00:47:12 +01:00
|
|
|
//! applied. So, the relation between syntax and HIR is many-to-one.
|
2020-03-23 14:00:51 +02:00
|
|
|
//!
|
|
|
|
//! 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 it's
|
|
|
|
//! parents and full context). It should be "clean code".
|
|
|
|
//!
|
|
|
|
//! `ra_hir_*` crates are the implementation of the compiler logic.
|
|
|
|
//! They are written in "ECS" style, with relatively little abstractions.
|
2020-03-23 14:04:50 +02:00
|
|
|
//! Many types are not self-contained, and explicitly use local indexes, arenas, etc.
|
2020-03-23 14:00:51 +02:00
|
|
|
//!
|
|
|
|
//! `ra_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.
|
2018-11-28 03:42:26 +03:00
|
|
|
|
2019-09-30 11:58:53 +03:00
|
|
|
#![recursion_limit = "512"]
|
|
|
|
|
2019-01-24 19:12:11 +03:00
|
|
|
macro_rules! impl_froms {
|
2020-01-14 15:27:05 +01:00
|
|
|
($e:ident: $($v:ident $(($($sv:ident),*))?),*$(,)?) => {
|
2019-01-24 19:12:11 +03:00
|
|
|
$(
|
|
|
|
impl From<$v> for $e {
|
|
|
|
fn from(it: $v) -> $e {
|
|
|
|
$e::$v(it)
|
|
|
|
}
|
|
|
|
}
|
2019-09-13 00:31:04 +03:00
|
|
|
$($(
|
|
|
|
impl From<$sv> for $e {
|
|
|
|
fn from(it: $sv) -> $e {
|
|
|
|
$e::$v($v::$sv(it))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)*)?
|
2019-01-24 19:12:11 +03:00
|
|
|
)*
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-18 18:35:10 +01:00
|
|
|
mod semantics;
|
2018-11-28 04:09:44 +03:00
|
|
|
pub mod db;
|
2020-02-28 17:27:49 +01:00
|
|
|
mod source_analyzer;
|
2018-11-28 03:42:26 +03:00
|
|
|
|
2019-03-21 22:13:11 +03:00
|
|
|
pub mod diagnostics;
|
2018-12-08 23:40:55 +03:00
|
|
|
|
2019-10-31 18:45:10 +03:00
|
|
|
mod from_id;
|
2019-05-23 21:14:19 +03:00
|
|
|
mod code_model;
|
2019-01-05 00:02:05 +03:00
|
|
|
|
2019-12-08 12:57:13 +01:00
|
|
|
mod has_source;
|
2019-09-16 13:48:54 +03:00
|
|
|
|
2019-10-29 15:53:25 +03:00
|
|
|
pub use crate::{
|
2019-10-30 18:50:10 +03:00
|
|
|
code_model::{
|
2020-02-12 15:31:44 +01:00
|
|
|
Adt, AsAssocItem, AssocItem, AssocItemContainer, AttrDef, Const, Crate, CrateDependency,
|
2020-04-25 14:23:34 +02:00
|
|
|
DefWithBody, Docs, Enum, EnumVariant, Field, FieldSource, Function, GenericDef, HasAttrs,
|
2020-02-29 21:24:40 +01:00
|
|
|
HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, ScopeDef, Static, Struct,
|
2020-04-25 14:23:34 +02:00
|
|
|
Trait, Type, TypeAlias, TypeParam, Union, VariantDef, Visibility,
|
2019-10-30 18:50:10 +03:00
|
|
|
},
|
2019-12-08 12:57:13 +01:00
|
|
|
has_source::HasSource,
|
2020-03-05 11:08:31 +01:00
|
|
|
semantics::{original_range, PathResolution, Semantics, SemanticsScope},
|
2018-11-28 03:42:26 +03:00
|
|
|
};
|
|
|
|
|
2019-10-30 17:24:36 +03:00
|
|
|
pub use hir_def::{
|
2020-02-15 21:48:20 +01:00
|
|
|
adt::StructKind,
|
2019-11-27 17:46:02 +03:00
|
|
|
body::scope::ExprScopes,
|
2019-10-31 10:51:54 +03:00
|
|
|
builtin_type::BuiltinType,
|
2019-11-23 14:43:38 +03:00
|
|
|
docs::Documentation,
|
2019-12-03 15:24:02 -05:00
|
|
|
nameres::ModuleSource,
|
2019-12-13 12:12:36 +01:00
|
|
|
path::{ModPath, Path, PathKind},
|
2019-10-30 17:28:30 +03:00
|
|
|
type_ref::Mutability,
|
2019-10-30 17:24:36 +03:00
|
|
|
};
|
2019-11-24 14:02:08 +03:00
|
|
|
pub use hir_expand::{
|
2020-04-30 18:20:13 +08:00
|
|
|
hygiene::Hygiene, name::Name, HirFileId, InFile, MacroCallId, MacroCallLoc, MacroDefId,
|
|
|
|
MacroFile, Origin,
|
2019-11-24 14:02:08 +03:00
|
|
|
};
|
2019-12-08 12:44:14 +01:00
|
|
|
pub use hir_ty::{display::HirDisplay, CallableDef};
|