2019-10-29 14:55:39 +03:00
|
|
|
//! hir makes heavy use of ids: integer (u32) handlers to various things. You
|
|
|
|
//! can think of id as a pointer (but without a lifetime) or a file descriptor
|
|
|
|
//! (but for hir objects).
|
|
|
|
//!
|
|
|
|
//! This module defines a bunch of ids we are using. The most important ones are
|
|
|
|
//! probably `HirFileId` and `DefId`.
|
2019-09-30 11:58:53 +03:00
|
|
|
|
2019-10-29 14:55:39 +03:00
|
|
|
use ra_db::salsa;
|
2019-01-01 23:21:16 +03:00
|
|
|
|
2019-10-30 13:10:38 +03:00
|
|
|
pub use hir_def::{
|
|
|
|
AstItemDef, ConstId, EnumId, FunctionId, ItemLoc, LocationCtx, StaticId, StructId, TraitId,
|
|
|
|
TypeAliasId,
|
2019-09-08 09:53:49 +03:00
|
|
|
};
|
2019-10-29 15:11:42 +03:00
|
|
|
pub use hir_expand::{HirFileId, MacroCallId, MacroCallLoc, MacroDefId, MacroFile, MacroFileKind};
|
2019-05-04 17:42:24 +03:00
|
|
|
|
2019-04-09 22:51:22 +03:00
|
|
|
macro_rules! impl_intern_key {
|
|
|
|
($name:ident) => {
|
|
|
|
impl salsa::InternKey for $name {
|
|
|
|
fn from_intern_id(v: salsa::InternId) -> Self {
|
|
|
|
$name(v)
|
|
|
|
}
|
|
|
|
fn as_intern_id(&self) -> salsa::InternId {
|
|
|
|
self.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-05-01 17:06:11 +02:00
|
|
|
/// This exists just for Chalk, because Chalk just has a single `StructId` where
|
|
|
|
/// we have different kinds of ADTs, primitive types and special type
|
|
|
|
/// constructors like tuples and function pointers.
|
2019-04-20 12:34:36 +02:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
|
|
|
pub struct TypeCtorId(salsa::InternId);
|
|
|
|
impl_intern_key!(TypeCtorId);
|
|
|
|
|
2019-05-01 17:06:11 +02:00
|
|
|
/// This exists just for Chalk, because our ImplIds are only unique per module.
|
2019-04-20 12:34:36 +02:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
|
|
|
pub struct GlobalImplId(salsa::InternId);
|
|
|
|
impl_intern_key!(GlobalImplId);
|