mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Kill DefId
This commit is contained in:
parent
1ccf73c836
commit
a03c109f50
@ -8,13 +8,12 @@ use ra_syntax::{TreeArc, SyntaxNode, SourceFile, AstNode, ast};
|
|||||||
use ra_arena::{Arena, RawId, ArenaId, impl_arena_id};
|
use ra_arena::{Arena, RawId, ArenaId, impl_arena_id};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
HirDatabase, Def,
|
HirDatabase,
|
||||||
Module,
|
Module,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct HirInterner {
|
pub struct HirInterner {
|
||||||
defs: LocationIntener<DefLoc, DefId>,
|
|
||||||
macros: LocationIntener<MacroCallLoc, MacroCallId>,
|
macros: LocationIntener<MacroCallLoc, MacroCallId>,
|
||||||
fns: LocationIntener<ItemLoc<ast::FnDef>, FunctionId>,
|
fns: LocationIntener<ItemLoc<ast::FnDef>, FunctionId>,
|
||||||
structs: LocationIntener<ItemLoc<ast::StructDef>, StructId>,
|
structs: LocationIntener<ItemLoc<ast::StructDef>, StructId>,
|
||||||
@ -28,7 +27,15 @@ pub struct HirInterner {
|
|||||||
|
|
||||||
impl HirInterner {
|
impl HirInterner {
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
self.defs.len() + self.macros.len()
|
self.macros.len()
|
||||||
|
+ self.fns.len()
|
||||||
|
+ self.structs.len()
|
||||||
|
+ self.enums.len()
|
||||||
|
+ self.enum_variants.len()
|
||||||
|
+ self.consts.len()
|
||||||
|
+ self.statics.len()
|
||||||
|
+ self.traits.len()
|
||||||
|
+ self.types.len()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,33 +306,6 @@ impl AstItemDef<ast::TypeDef> for TypeId {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Def's are a core concept of hir. A `Def` is an Item (function, module, etc)
|
|
||||||
/// in a specific module.
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
|
||||||
pub struct DefId(RawId);
|
|
||||||
impl_arena_id!(DefId);
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
|
||||||
pub struct DefLoc {
|
|
||||||
pub(crate) kind: DefKind,
|
|
||||||
pub(crate) module: Module,
|
|
||||||
pub(crate) source_item_id: SourceItemId,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
|
||||||
pub(crate) enum DefKind {}
|
|
||||||
|
|
||||||
impl DefId {
|
|
||||||
pub(crate) fn loc(self, db: &impl AsRef<HirInterner>) -> DefLoc {
|
|
||||||
db.as_ref().defs.id2loc(self)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn resolve(self, db: &impl HirDatabase) -> Def {
|
|
||||||
let loc = self.loc(db);
|
|
||||||
match loc.kind {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Identifier of item within a specific file. This is stable over reparses, so
|
/// Identifier of item within a specific file. This is stable over reparses, so
|
||||||
/// it's OK to use it as a salsa key/value.
|
/// it's OK to use it as a salsa key/value.
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
@ -52,7 +52,7 @@ use crate::{
|
|||||||
pub use self::{
|
pub use self::{
|
||||||
path::{Path, PathKind},
|
path::{Path, PathKind},
|
||||||
name::Name,
|
name::Name,
|
||||||
ids::{HirFileId, DefId, DefLoc, MacroCallId, MacroCallLoc, HirInterner},
|
ids::{HirFileId, MacroCallId, MacroCallLoc, HirInterner},
|
||||||
macros::{MacroDef, MacroInput, MacroExpansion},
|
macros::{MacroDef, MacroInput, MacroExpansion},
|
||||||
nameres::{ItemMap, PerNs, Namespace, Resolution},
|
nameres::{ItemMap, PerNs, Namespace, Resolution},
|
||||||
ty::{Ty, AdtDef},
|
ty::{Ty, AdtDef},
|
||||||
|
Loading…
Reference in New Issue
Block a user