aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/lib.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-03-19 17:47:43 +0000
committerGitHub <[email protected]>2020-03-19 17:47:43 +0000
commit1ba03c6995015b3143a417ed07437f0c9028a97d (patch)
treece3eb047dd9fe9005750a3b1417d95b1aa8fe01e /crates/ra_hir_def/src/lib.rs
parent988f1dda6bde576ec2457dd97a7525014609c771 (diff)
parentf840fcb2f525c13809d6a736e434155edf075a06 (diff)
Merge #3656
3656: Simplify arenas r=matklad a=matklad At the moment, Arena is paranetrized by two types: index and data. The original motivation was to allow index to be defined in the downstream crate, so that you can add inherent impls to the index. However, it seems like we've never actually used that capability, so perhaps we should switch to a generic Index impl? This PR tries this out, switching only `raw.rs` and parts of `hir_def`. wdyt? Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_def/src/lib.rs')
-rw-r--r--crates/ra_hir_def/src/lib.rs18
1 files changed, 5 insertions, 13 deletions
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs
index d0f043ed0..516dd773e 100644
--- a/crates/ra_hir_def/src/lib.rs
+++ b/crates/ra_hir_def/src/lib.rs
@@ -50,7 +50,7 @@ use hir_expand::{
50 ast_id_map::FileAstId, eager::expand_eager_macro, hygiene::Hygiene, AstId, HirFileId, InFile, 50 ast_id_map::FileAstId, eager::expand_eager_macro, hygiene::Hygiene, AstId, HirFileId, InFile,
51 MacroCallId, MacroCallKind, MacroDefId, MacroDefKind, 51 MacroCallId, MacroCallKind, MacroDefId, MacroDefKind,
52}; 52};
53use ra_arena::{impl_arena_id, RawId}; 53use ra_arena::Idx;
54use ra_db::{impl_intern_key, salsa, CrateId}; 54use ra_db::{impl_intern_key, salsa, CrateId};
55use ra_syntax::{ast, AstNode}; 55use ra_syntax::{ast, AstNode};
56 56
@@ -64,9 +64,7 @@ pub struct ModuleId {
64} 64}
65 65
66/// An ID of a module, **local** to a specific crate 66/// An ID of a module, **local** to a specific crate
67#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] 67pub type LocalModuleId = Idx<nameres::ModuleData>;
68pub struct LocalModuleId(RawId);
69impl_arena_id!(LocalModuleId);
70 68
71#[derive(Debug, Clone, PartialEq, Eq, Hash)] 69#[derive(Debug, Clone, PartialEq, Eq, Hash)]
72pub struct ItemLoc<N: AstNode> { 70pub struct ItemLoc<N: AstNode> {
@@ -127,9 +125,7 @@ pub struct EnumVariantId {
127 pub local_id: LocalEnumVariantId, 125 pub local_id: LocalEnumVariantId,
128} 126}
129 127
130#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 128pub type LocalEnumVariantId = Idx<adt::EnumVariantData>;
131pub struct LocalEnumVariantId(RawId);
132impl_arena_id!(LocalEnumVariantId);
133 129
134#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 130#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
135pub struct StructFieldId { 131pub struct StructFieldId {
@@ -137,9 +133,7 @@ pub struct StructFieldId {
137 pub local_id: LocalStructFieldId, 133 pub local_id: LocalStructFieldId,
138} 134}
139 135
140#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 136pub type LocalStructFieldId = Idx<adt::StructFieldData>;
141pub struct LocalStructFieldId(RawId);
142impl_arena_id!(LocalStructFieldId);
143 137
144#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 138#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
145pub struct ConstId(salsa::InternId); 139pub struct ConstId(salsa::InternId);
@@ -172,9 +166,7 @@ pub struct TypeParamId {
172 pub local_id: LocalTypeParamId, 166 pub local_id: LocalTypeParamId,
173} 167}
174 168
175#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 169pub type LocalTypeParamId = Idx<generics::TypeParamData>;
176pub struct LocalTypeParamId(RawId);
177impl_arena_id!(LocalTypeParamId);
178 170
179macro_rules! impl_froms { 171macro_rules! impl_froms {
180 ($e:ident: $($v:ident $(($($sv:ident),*))?),*) => { 172 ($e:ident: $($v:ident $(($($sv:ident),*))?),*) => {