diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-03-19 17:47:43 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-03-19 17:47:43 +0000 |
commit | 1ba03c6995015b3143a417ed07437f0c9028a97d (patch) | |
tree | ce3eb047dd9fe9005750a3b1417d95b1aa8fe01e /crates/ra_hir_def/src/lib.rs | |
parent | 988f1dda6bde576ec2457dd97a7525014609c771 (diff) | |
parent | f840fcb2f525c13809d6a736e434155edf075a06 (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.rs | 18 |
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 | }; |
53 | use ra_arena::{impl_arena_id, RawId}; | 53 | use ra_arena::Idx; |
54 | use ra_db::{impl_intern_key, salsa, CrateId}; | 54 | use ra_db::{impl_intern_key, salsa, CrateId}; |
55 | use ra_syntax::{ast, AstNode}; | 55 | use 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)] | 67 | pub type LocalModuleId = Idx<nameres::ModuleData>; |
68 | pub struct LocalModuleId(RawId); | ||
69 | impl_arena_id!(LocalModuleId); | ||
70 | 68 | ||
71 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 69 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
72 | pub struct ItemLoc<N: AstNode> { | 70 | pub 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)] | 128 | pub type LocalEnumVariantId = Idx<adt::EnumVariantData>; |
131 | pub struct LocalEnumVariantId(RawId); | ||
132 | impl_arena_id!(LocalEnumVariantId); | ||
133 | 129 | ||
134 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 130 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
135 | pub struct StructFieldId { | 131 | pub 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)] | 136 | pub type LocalStructFieldId = Idx<adt::StructFieldData>; |
141 | pub struct LocalStructFieldId(RawId); | ||
142 | impl_arena_id!(LocalStructFieldId); | ||
143 | 137 | ||
144 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 138 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
145 | pub struct ConstId(salsa::InternId); | 139 | pub 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)] | 169 | pub type LocalTypeParamId = Idx<generics::TypeParamData>; |
176 | pub struct LocalTypeParamId(RawId); | ||
177 | impl_arena_id!(LocalTypeParamId); | ||
178 | 170 | ||
179 | macro_rules! impl_froms { | 171 | macro_rules! impl_froms { |
180 | ($e:ident: $($v:ident $(($($sv:ident),*))?),*) => { | 172 | ($e:ident: $($v:ident $(($($sv:ident),*))?),*) => { |