diff options
Diffstat (limited to 'crates')
30 files changed, 28 insertions, 253 deletions
diff --git a/crates/arena/Cargo.toml b/crates/arena/Cargo.toml deleted file mode 100644 index 863eedf76..000000000 --- a/crates/arena/Cargo.toml +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | [package] | ||
2 | name = "arena" | ||
3 | version = "0.0.0" | ||
4 | description = "TBD" | ||
5 | license = "MIT OR Apache-2.0" | ||
6 | authors = ["rust-analyzer developers"] | ||
7 | edition = "2018" | ||
8 | |||
9 | [lib] | ||
10 | doctest = false | ||
diff --git a/crates/arena/src/lib.rs b/crates/arena/src/lib.rs deleted file mode 100644 index 3169aa5b8..000000000 --- a/crates/arena/src/lib.rs +++ /dev/null | |||
@@ -1,152 +0,0 @@ | |||
1 | //! Yet another index-based arena. | ||
2 | |||
3 | use std::{ | ||
4 | fmt, | ||
5 | hash::{Hash, Hasher}, | ||
6 | iter::FromIterator, | ||
7 | marker::PhantomData, | ||
8 | ops::{Index, IndexMut}, | ||
9 | }; | ||
10 | |||
11 | pub mod map; | ||
12 | |||
13 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
14 | pub struct RawId(u32); | ||
15 | |||
16 | impl From<RawId> for u32 { | ||
17 | fn from(raw: RawId) -> u32 { | ||
18 | raw.0 | ||
19 | } | ||
20 | } | ||
21 | |||
22 | impl From<u32> for RawId { | ||
23 | fn from(id: u32) -> RawId { | ||
24 | RawId(id) | ||
25 | } | ||
26 | } | ||
27 | |||
28 | impl fmt::Debug for RawId { | ||
29 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
30 | self.0.fmt(f) | ||
31 | } | ||
32 | } | ||
33 | |||
34 | impl fmt::Display for RawId { | ||
35 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
36 | self.0.fmt(f) | ||
37 | } | ||
38 | } | ||
39 | |||
40 | pub struct Idx<T> { | ||
41 | raw: RawId, | ||
42 | _ty: PhantomData<fn() -> T>, | ||
43 | } | ||
44 | |||
45 | impl<T> Clone for Idx<T> { | ||
46 | fn clone(&self) -> Self { | ||
47 | *self | ||
48 | } | ||
49 | } | ||
50 | impl<T> Copy for Idx<T> {} | ||
51 | |||
52 | impl<T> PartialEq for Idx<T> { | ||
53 | fn eq(&self, other: &Idx<T>) -> bool { | ||
54 | self.raw == other.raw | ||
55 | } | ||
56 | } | ||
57 | impl<T> Eq for Idx<T> {} | ||
58 | |||
59 | impl<T> Hash for Idx<T> { | ||
60 | fn hash<H: Hasher>(&self, state: &mut H) { | ||
61 | self.raw.hash(state) | ||
62 | } | ||
63 | } | ||
64 | |||
65 | impl<T> fmt::Debug for Idx<T> { | ||
66 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
67 | let mut type_name = std::any::type_name::<T>(); | ||
68 | if let Some(idx) = type_name.rfind(':') { | ||
69 | type_name = &type_name[idx + 1..] | ||
70 | } | ||
71 | write!(f, "Idx::<{}>({})", type_name, self.raw) | ||
72 | } | ||
73 | } | ||
74 | |||
75 | impl<T> Idx<T> { | ||
76 | pub fn from_raw(raw: RawId) -> Self { | ||
77 | Idx { raw, _ty: PhantomData } | ||
78 | } | ||
79 | pub fn into_raw(self) -> RawId { | ||
80 | self.raw | ||
81 | } | ||
82 | } | ||
83 | |||
84 | #[derive(Clone, PartialEq, Eq)] | ||
85 | pub struct Arena<T> { | ||
86 | data: Vec<T>, | ||
87 | } | ||
88 | |||
89 | impl<T: fmt::Debug> fmt::Debug for Arena<T> { | ||
90 | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { | ||
91 | fmt.debug_struct("Arena").field("len", &self.len()).field("data", &self.data).finish() | ||
92 | } | ||
93 | } | ||
94 | |||
95 | impl<T> Arena<T> { | ||
96 | pub const fn new() -> Arena<T> { | ||
97 | Arena { data: Vec::new() } | ||
98 | } | ||
99 | pub fn clear(&mut self) { | ||
100 | self.data.clear(); | ||
101 | } | ||
102 | |||
103 | pub fn len(&self) -> usize { | ||
104 | self.data.len() | ||
105 | } | ||
106 | pub fn is_empty(&self) -> bool { | ||
107 | self.data.is_empty() | ||
108 | } | ||
109 | pub fn alloc(&mut self, value: T) -> Idx<T> { | ||
110 | let id = RawId(self.data.len() as u32); | ||
111 | self.data.push(value); | ||
112 | Idx::from_raw(id) | ||
113 | } | ||
114 | pub fn iter( | ||
115 | &self, | ||
116 | ) -> impl Iterator<Item = (Idx<T>, &T)> + ExactSizeIterator + DoubleEndedIterator { | ||
117 | self.data.iter().enumerate().map(|(idx, value)| (Idx::from_raw(RawId(idx as u32)), value)) | ||
118 | } | ||
119 | pub fn shrink_to_fit(&mut self) { | ||
120 | self.data.shrink_to_fit(); | ||
121 | } | ||
122 | } | ||
123 | |||
124 | impl<T> Default for Arena<T> { | ||
125 | fn default() -> Arena<T> { | ||
126 | Arena { data: Vec::new() } | ||
127 | } | ||
128 | } | ||
129 | |||
130 | impl<T> Index<Idx<T>> for Arena<T> { | ||
131 | type Output = T; | ||
132 | fn index(&self, idx: Idx<T>) -> &T { | ||
133 | let idx = idx.into_raw().0 as usize; | ||
134 | &self.data[idx] | ||
135 | } | ||
136 | } | ||
137 | |||
138 | impl<T> IndexMut<Idx<T>> for Arena<T> { | ||
139 | fn index_mut(&mut self, idx: Idx<T>) -> &mut T { | ||
140 | let idx = idx.into_raw().0 as usize; | ||
141 | &mut self.data[idx] | ||
142 | } | ||
143 | } | ||
144 | |||
145 | impl<T> FromIterator<T> for Arena<T> { | ||
146 | fn from_iter<I>(iter: I) -> Self | ||
147 | where | ||
148 | I: IntoIterator<Item = T>, | ||
149 | { | ||
150 | Arena { data: Vec::from_iter(iter) } | ||
151 | } | ||
152 | } | ||
diff --git a/crates/arena/src/map.rs b/crates/arena/src/map.rs deleted file mode 100644 index 0f33907c0..000000000 --- a/crates/arena/src/map.rs +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | //! A map from arena IDs to some other type. Space requirement is O(highest ID). | ||
2 | |||
3 | use std::marker::PhantomData; | ||
4 | |||
5 | use crate::Idx; | ||
6 | |||
7 | /// A map from arena IDs to some other type. Space requirement is O(highest ID). | ||
8 | #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
9 | pub struct ArenaMap<ID, V> { | ||
10 | v: Vec<Option<V>>, | ||
11 | _ty: PhantomData<ID>, | ||
12 | } | ||
13 | |||
14 | impl<T, V> ArenaMap<Idx<T>, V> { | ||
15 | pub fn insert(&mut self, id: Idx<T>, t: V) { | ||
16 | let idx = Self::to_idx(id); | ||
17 | |||
18 | self.v.resize_with((idx + 1).max(self.v.len()), || None); | ||
19 | self.v[idx] = Some(t); | ||
20 | } | ||
21 | |||
22 | pub fn get(&self, id: Idx<T>) -> Option<&V> { | ||
23 | self.v.get(Self::to_idx(id)).and_then(|it| it.as_ref()) | ||
24 | } | ||
25 | |||
26 | pub fn get_mut(&mut self, id: Idx<T>) -> Option<&mut V> { | ||
27 | self.v.get_mut(Self::to_idx(id)).and_then(|it| it.as_mut()) | ||
28 | } | ||
29 | |||
30 | pub fn values(&self) -> impl Iterator<Item = &V> { | ||
31 | self.v.iter().filter_map(|o| o.as_ref()) | ||
32 | } | ||
33 | |||
34 | pub fn values_mut(&mut self) -> impl Iterator<Item = &mut V> { | ||
35 | self.v.iter_mut().filter_map(|o| o.as_mut()) | ||
36 | } | ||
37 | |||
38 | pub fn iter(&self) -> impl Iterator<Item = (Idx<T>, &V)> { | ||
39 | self.v.iter().enumerate().filter_map(|(idx, o)| Some((Self::from_idx(idx), o.as_ref()?))) | ||
40 | } | ||
41 | |||
42 | fn to_idx(id: Idx<T>) -> usize { | ||
43 | u32::from(id.into_raw()) as usize | ||
44 | } | ||
45 | |||
46 | fn from_idx(idx: usize) -> Idx<T> { | ||
47 | Idx::from_raw((idx as u32).into()) | ||
48 | } | ||
49 | } | ||
50 | |||
51 | impl<T, V> std::ops::Index<Idx<V>> for ArenaMap<Idx<V>, T> { | ||
52 | type Output = T; | ||
53 | fn index(&self, id: Idx<V>) -> &T { | ||
54 | self.v[Self::to_idx(id)].as_ref().unwrap() | ||
55 | } | ||
56 | } | ||
57 | |||
58 | impl<T, V> Default for ArenaMap<Idx<V>, T> { | ||
59 | fn default() -> Self { | ||
60 | ArenaMap { v: Vec::new(), _ty: PhantomData } | ||
61 | } | ||
62 | } | ||
diff --git a/crates/hir_def/Cargo.toml b/crates/hir_def/Cargo.toml index 7ef966cd2..5d21283f7 100644 --- a/crates/hir_def/Cargo.toml +++ b/crates/hir_def/Cargo.toml | |||
@@ -20,9 +20,9 @@ fst = { version = "0.4", default-features = false } | |||
20 | itertools = "0.10.0" | 20 | itertools = "0.10.0" |
21 | indexmap = "1.4.0" | 21 | indexmap = "1.4.0" |
22 | smallvec = "1.4.0" | 22 | smallvec = "1.4.0" |
23 | la-arena = "0.1.0" | ||
23 | 24 | ||
24 | stdx = { path = "../stdx", version = "0.0.0" } | 25 | stdx = { path = "../stdx", version = "0.0.0" } |
25 | arena = { path = "../arena", version = "0.0.0" } | ||
26 | base_db = { path = "../base_db", version = "0.0.0" } | 26 | base_db = { path = "../base_db", version = "0.0.0" } |
27 | syntax = { path = "../syntax", version = "0.0.0" } | 27 | syntax = { path = "../syntax", version = "0.0.0" } |
28 | profile = { path = "../profile", version = "0.0.0" } | 28 | profile = { path = "../profile", version = "0.0.0" } |
diff --git a/crates/hir_def/src/adt.rs b/crates/hir_def/src/adt.rs index 236d6f1b7..237c3d3f9 100644 --- a/crates/hir_def/src/adt.rs +++ b/crates/hir_def/src/adt.rs | |||
@@ -2,13 +2,13 @@ | |||
2 | 2 | ||
3 | use std::sync::Arc; | 3 | use std::sync::Arc; |
4 | 4 | ||
5 | use arena::{map::ArenaMap, Arena}; | ||
6 | use base_db::CrateId; | 5 | use base_db::CrateId; |
7 | use either::Either; | 6 | use either::Either; |
8 | use hir_expand::{ | 7 | use hir_expand::{ |
9 | name::{AsName, Name}, | 8 | name::{AsName, Name}, |
10 | InFile, | 9 | InFile, |
11 | }; | 10 | }; |
11 | use la_arena::{map::ArenaMap, Arena}; | ||
12 | use syntax::ast::{self, NameOwner, VisibilityOwner}; | 12 | use syntax::ast::{self, NameOwner, VisibilityOwner}; |
13 | use tt::{Delimiter, DelimiterKind, Leaf, Subtree, TokenTree}; | 13 | use tt::{Delimiter, DelimiterKind, Leaf, Subtree, TokenTree}; |
14 | 14 | ||
diff --git a/crates/hir_def/src/attr.rs b/crates/hir_def/src/attr.rs index 9e6426b31..5a86823c2 100644 --- a/crates/hir_def/src/attr.rs +++ b/crates/hir_def/src/attr.rs | |||
@@ -2,12 +2,12 @@ | |||
2 | 2 | ||
3 | use std::{ops, sync::Arc}; | 3 | use std::{ops, sync::Arc}; |
4 | 4 | ||
5 | use arena::map::ArenaMap; | ||
6 | use base_db::CrateId; | 5 | use base_db::CrateId; |
7 | use cfg::{CfgExpr, CfgOptions}; | 6 | use cfg::{CfgExpr, CfgOptions}; |
8 | use either::Either; | 7 | use either::Either; |
9 | use hir_expand::{hygiene::Hygiene, name::AsName, AstId, InFile}; | 8 | use hir_expand::{hygiene::Hygiene, name::AsName, AstId, InFile}; |
10 | use itertools::Itertools; | 9 | use itertools::Itertools; |
10 | use la_arena::map::ArenaMap; | ||
11 | use mbe::ast_to_token_tree; | 11 | use mbe::ast_to_token_tree; |
12 | use syntax::{ | 12 | use syntax::{ |
13 | ast::{self, AstNode, AttrsOwner}, | 13 | ast::{self, AstNode, AttrsOwner}, |
diff --git a/crates/hir_def/src/body.rs b/crates/hir_def/src/body.rs index d07004b9d..43ee57277 100644 --- a/crates/hir_def/src/body.rs +++ b/crates/hir_def/src/body.rs | |||
@@ -8,7 +8,6 @@ pub mod scope; | |||
8 | 8 | ||
9 | use std::{mem, ops::Index, sync::Arc}; | 9 | use std::{mem, ops::Index, sync::Arc}; |
10 | 10 | ||
11 | use arena::{map::ArenaMap, Arena}; | ||
12 | use base_db::CrateId; | 11 | use base_db::CrateId; |
13 | use cfg::CfgOptions; | 12 | use cfg::CfgOptions; |
14 | use drop_bomb::DropBomb; | 13 | use drop_bomb::DropBomb; |
@@ -17,6 +16,7 @@ use hir_expand::{ | |||
17 | ast_id_map::AstIdMap, diagnostics::DiagnosticSink, hygiene::Hygiene, AstId, ExpandResult, | 16 | ast_id_map::AstIdMap, diagnostics::DiagnosticSink, hygiene::Hygiene, AstId, ExpandResult, |
18 | HirFileId, InFile, MacroDefId, | 17 | HirFileId, InFile, MacroDefId, |
19 | }; | 18 | }; |
19 | use la_arena::{map::ArenaMap, Arena}; | ||
20 | use rustc_hash::FxHashMap; | 20 | use rustc_hash::FxHashMap; |
21 | use syntax::{ast, AstNode, AstPtr}; | 21 | use syntax::{ast, AstNode, AstPtr}; |
22 | use test_utils::mark; | 22 | use test_utils::mark; |
diff --git a/crates/hir_def/src/body/lower.rs b/crates/hir_def/src/body/lower.rs index 3dc33f248..27575c537 100644 --- a/crates/hir_def/src/body/lower.rs +++ b/crates/hir_def/src/body/lower.rs | |||
@@ -3,13 +3,13 @@ | |||
3 | 3 | ||
4 | use std::{any::type_name, sync::Arc}; | 4 | use std::{any::type_name, sync::Arc}; |
5 | 5 | ||
6 | use arena::Arena; | ||
7 | use either::Either; | 6 | use either::Either; |
8 | use hir_expand::{ | 7 | use hir_expand::{ |
9 | hygiene::Hygiene, | 8 | hygiene::Hygiene, |
10 | name::{name, AsName, Name}, | 9 | name::{name, AsName, Name}, |
11 | ExpandError, HirFileId, MacroDefId, MacroDefKind, | 10 | ExpandError, HirFileId, MacroDefId, MacroDefKind, |
12 | }; | 11 | }; |
12 | use la_arena::Arena; | ||
13 | use rustc_hash::FxHashMap; | 13 | use rustc_hash::FxHashMap; |
14 | use syntax::{ | 14 | use syntax::{ |
15 | ast::{ | 15 | ast::{ |
diff --git a/crates/hir_def/src/body/scope.rs b/crates/hir_def/src/body/scope.rs index 065785da7..49f1427b4 100644 --- a/crates/hir_def/src/body/scope.rs +++ b/crates/hir_def/src/body/scope.rs | |||
@@ -1,8 +1,8 @@ | |||
1 | //! Name resolution for expressions. | 1 | //! Name resolution for expressions. |
2 | use std::sync::Arc; | 2 | use std::sync::Arc; |
3 | 3 | ||
4 | use arena::{Arena, Idx}; | ||
5 | use hir_expand::name::Name; | 4 | use hir_expand::name::Name; |
5 | use la_arena::{Arena, Idx}; | ||
6 | use rustc_hash::FxHashMap; | 6 | use rustc_hash::FxHashMap; |
7 | 7 | ||
8 | use crate::{ | 8 | use crate::{ |
diff --git a/crates/hir_def/src/db.rs b/crates/hir_def/src/db.rs index d3bf5b34c..0506a7274 100644 --- a/crates/hir_def/src/db.rs +++ b/crates/hir_def/src/db.rs | |||
@@ -1,9 +1,9 @@ | |||
1 | //! Defines database & queries for name resolution. | 1 | //! Defines database & queries for name resolution. |
2 | use std::sync::Arc; | 2 | use std::sync::Arc; |
3 | 3 | ||
4 | use arena::map::ArenaMap; | ||
5 | use base_db::{salsa, CrateId, SourceDatabase, Upcast}; | 4 | use base_db::{salsa, CrateId, SourceDatabase, Upcast}; |
6 | use hir_expand::{db::AstDatabase, HirFileId}; | 5 | use hir_expand::{db::AstDatabase, HirFileId}; |
6 | use la_arena::map::ArenaMap; | ||
7 | use syntax::SmolStr; | 7 | use syntax::SmolStr; |
8 | 8 | ||
9 | use crate::{ | 9 | use crate::{ |
diff --git a/crates/hir_def/src/expr.rs b/crates/hir_def/src/expr.rs index 76f5721e5..af01d32dc 100644 --- a/crates/hir_def/src/expr.rs +++ b/crates/hir_def/src/expr.rs | |||
@@ -12,8 +12,8 @@ | |||
12 | //! | 12 | //! |
13 | //! See also a neighboring `body` module. | 13 | //! See also a neighboring `body` module. |
14 | 14 | ||
15 | use arena::{Idx, RawId}; | ||
16 | use hir_expand::name::Name; | 15 | use hir_expand::name::Name; |
16 | use la_arena::{Idx, RawId}; | ||
17 | use syntax::ast::RangeOp; | 17 | use syntax::ast::RangeOp; |
18 | 18 | ||
19 | use crate::{ | 19 | use crate::{ |
diff --git a/crates/hir_def/src/generics.rs b/crates/hir_def/src/generics.rs index 9b5b886c2..75eab791a 100644 --- a/crates/hir_def/src/generics.rs +++ b/crates/hir_def/src/generics.rs | |||
@@ -4,13 +4,13 @@ | |||
4 | //! in rustc. | 4 | //! in rustc. |
5 | use std::sync::Arc; | 5 | use std::sync::Arc; |
6 | 6 | ||
7 | use arena::{map::ArenaMap, Arena}; | ||
8 | use base_db::FileId; | 7 | use base_db::FileId; |
9 | use either::Either; | 8 | use either::Either; |
10 | use hir_expand::{ | 9 | use hir_expand::{ |
11 | name::{name, AsName, Name}, | 10 | name::{name, AsName, Name}, |
12 | InFile, | 11 | InFile, |
13 | }; | 12 | }; |
13 | use la_arena::{map::ArenaMap, Arena}; | ||
14 | use syntax::ast::{self, GenericParamsOwner, NameOwner, TypeBoundsOwner}; | 14 | use syntax::ast::{self, GenericParamsOwner, NameOwner, TypeBoundsOwner}; |
15 | 15 | ||
16 | use crate::{ | 16 | use crate::{ |
diff --git a/crates/hir_def/src/item_tree.rs b/crates/hir_def/src/item_tree.rs index b6f510731..91e42aa0d 100644 --- a/crates/hir_def/src/item_tree.rs +++ b/crates/hir_def/src/item_tree.rs | |||
@@ -11,7 +11,6 @@ use std::{ | |||
11 | sync::Arc, | 11 | sync::Arc, |
12 | }; | 12 | }; |
13 | 13 | ||
14 | use arena::{Arena, Idx, RawId}; | ||
15 | use ast::{AstNode, NameOwner, StructKind}; | 14 | use ast::{AstNode, NameOwner, StructKind}; |
16 | use base_db::CrateId; | 15 | use base_db::CrateId; |
17 | use either::Either; | 16 | use either::Either; |
@@ -21,6 +20,7 @@ use hir_expand::{ | |||
21 | name::{name, AsName, Name}, | 20 | name::{name, AsName, Name}, |
22 | HirFileId, InFile, | 21 | HirFileId, InFile, |
23 | }; | 22 | }; |
23 | use la_arena::{Arena, Idx, RawId}; | ||
24 | use rustc_hash::FxHashMap; | 24 | use rustc_hash::FxHashMap; |
25 | use smallvec::SmallVec; | 25 | use smallvec::SmallVec; |
26 | use syntax::{ast, match_ast}; | 26 | use syntax::{ast, match_ast}; |
diff --git a/crates/hir_def/src/lib.rs b/crates/hir_def/src/lib.rs index 211cb2faf..08ed920c6 100644 --- a/crates/hir_def/src/lib.rs +++ b/crates/hir_def/src/lib.rs | |||
@@ -52,12 +52,12 @@ mod test_db; | |||
52 | 52 | ||
53 | use std::hash::{Hash, Hasher}; | 53 | use std::hash::{Hash, Hasher}; |
54 | 54 | ||
55 | use arena::Idx; | ||
56 | use base_db::{impl_intern_key, salsa, CrateId}; | 55 | use base_db::{impl_intern_key, salsa, CrateId}; |
57 | use hir_expand::{ | 56 | use hir_expand::{ |
58 | ast_id_map::FileAstId, eager::expand_eager_macro, hygiene::Hygiene, AstId, HirFileId, InFile, | 57 | ast_id_map::FileAstId, eager::expand_eager_macro, hygiene::Hygiene, AstId, HirFileId, InFile, |
59 | MacroCallId, MacroCallKind, MacroDefId, MacroDefKind, | 58 | MacroCallId, MacroCallKind, MacroDefId, MacroDefKind, |
60 | }; | 59 | }; |
60 | use la_arena::Idx; | ||
61 | use syntax::ast; | 61 | use syntax::ast; |
62 | 62 | ||
63 | use crate::builtin_type::BuiltinType; | 63 | use crate::builtin_type::BuiltinType; |
diff --git a/crates/hir_def/src/nameres.rs b/crates/hir_def/src/nameres.rs index 5682e122d..50acc3f54 100644 --- a/crates/hir_def/src/nameres.rs +++ b/crates/hir_def/src/nameres.rs | |||
@@ -56,9 +56,9 @@ mod tests; | |||
56 | 56 | ||
57 | use std::sync::Arc; | 57 | use std::sync::Arc; |
58 | 58 | ||
59 | use arena::Arena; | ||
60 | use base_db::{CrateId, Edition, FileId}; | 59 | use base_db::{CrateId, Edition, FileId}; |
61 | use hir_expand::{diagnostics::DiagnosticSink, name::Name, InFile}; | 60 | use hir_expand::{diagnostics::DiagnosticSink, name::Name, InFile}; |
61 | use la_arena::Arena; | ||
62 | use rustc_hash::FxHashMap; | 62 | use rustc_hash::FxHashMap; |
63 | use stdx::format_to; | 63 | use stdx::format_to; |
64 | use syntax::ast; | 64 | use syntax::ast; |
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs index f027fd48d..0cd61698c 100644 --- a/crates/hir_def/src/nameres/collector.rs +++ b/crates/hir_def/src/nameres/collector.rs | |||
@@ -1469,8 +1469,8 @@ impl ModCollector<'_, '_> { | |||
1469 | #[cfg(test)] | 1469 | #[cfg(test)] |
1470 | mod tests { | 1470 | mod tests { |
1471 | use crate::{db::DefDatabase, test_db::TestDB}; | 1471 | use crate::{db::DefDatabase, test_db::TestDB}; |
1472 | use arena::Arena; | ||
1473 | use base_db::{fixture::WithFixture, SourceDatabase}; | 1472 | use base_db::{fixture::WithFixture, SourceDatabase}; |
1473 | use la_arena::Arena; | ||
1474 | 1474 | ||
1475 | use super::*; | 1475 | use super::*; |
1476 | 1476 | ||
diff --git a/crates/hir_def/src/src.rs b/crates/hir_def/src/src.rs index f67244b46..eb29265d9 100644 --- a/crates/hir_def/src/src.rs +++ b/crates/hir_def/src/src.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | //! Utilities for mapping between hir IDs and the surface syntax. | 1 | //! Utilities for mapping between hir IDs and the surface syntax. |
2 | 2 | ||
3 | use arena::map::ArenaMap; | ||
4 | use hir_expand::InFile; | 3 | use hir_expand::InFile; |
4 | use la_arena::map::ArenaMap; | ||
5 | 5 | ||
6 | use crate::{db::DefDatabase, item_tree::ItemTreeNode, AssocItemLoc, ItemLoc}; | 6 | use crate::{db::DefDatabase, item_tree::ItemTreeNode, AssocItemLoc, ItemLoc}; |
7 | 7 | ||
diff --git a/crates/hir_def/src/trace.rs b/crates/hir_def/src/trace.rs index fd64e7018..0a9beae8e 100644 --- a/crates/hir_def/src/trace.rs +++ b/crates/hir_def/src/trace.rs | |||
@@ -9,7 +9,7 @@ | |||
9 | //! absolute offsets. The `Trace` structure (inspired, at least in name, by | 9 | //! absolute offsets. The `Trace` structure (inspired, at least in name, by |
10 | //! Kotlin's `BindingTrace`) allows use the same code to compute both | 10 | //! Kotlin's `BindingTrace`) allows use the same code to compute both |
11 | //! projections. | 11 | //! projections. |
12 | use arena::{map::ArenaMap, Arena, Idx, RawId}; | 12 | use la_arena::{map::ArenaMap, Arena, Idx, RawId}; |
13 | 13 | ||
14 | pub(crate) struct Trace<T, V> { | 14 | pub(crate) struct Trace<T, V> { |
15 | arena: Option<Arena<T>>, | 15 | arena: Option<Arena<T>>, |
diff --git a/crates/hir_expand/Cargo.toml b/crates/hir_expand/Cargo.toml index 9fad2ab94..b535a3d4f 100644 --- a/crates/hir_expand/Cargo.toml +++ b/crates/hir_expand/Cargo.toml | |||
@@ -13,8 +13,8 @@ doctest = false | |||
13 | log = "0.4.8" | 13 | log = "0.4.8" |
14 | either = "1.5.3" | 14 | either = "1.5.3" |
15 | rustc-hash = "1.0.0" | 15 | rustc-hash = "1.0.0" |
16 | la-arena = "0.1.0" | ||
16 | 17 | ||
17 | arena = { path = "../arena", version = "0.0.0" } | ||
18 | base_db = { path = "../base_db", version = "0.0.0" } | 18 | base_db = { path = "../base_db", version = "0.0.0" } |
19 | syntax = { path = "../syntax", version = "0.0.0" } | 19 | syntax = { path = "../syntax", version = "0.0.0" } |
20 | parser = { path = "../parser", version = "0.0.0" } | 20 | parser = { path = "../parser", version = "0.0.0" } |
diff --git a/crates/hir_expand/src/ast_id_map.rs b/crates/hir_expand/src/ast_id_map.rs index f63629b30..f4f6e11fd 100644 --- a/crates/hir_expand/src/ast_id_map.rs +++ b/crates/hir_expand/src/ast_id_map.rs | |||
@@ -12,7 +12,7 @@ use std::{ | |||
12 | marker::PhantomData, | 12 | marker::PhantomData, |
13 | }; | 13 | }; |
14 | 14 | ||
15 | use arena::{Arena, Idx}; | 15 | use la_arena::{Arena, Idx}; |
16 | use syntax::{ast, AstNode, AstPtr, SyntaxNode, SyntaxNodePtr}; | 16 | use syntax::{ast, AstNode, AstPtr, SyntaxNode, SyntaxNodePtr}; |
17 | 17 | ||
18 | /// `AstId` points to an AST node in a specific file. | 18 | /// `AstId` points to an AST node in a specific file. |
diff --git a/crates/hir_ty/Cargo.toml b/crates/hir_ty/Cargo.toml index b0a453961..436c1405b 100644 --- a/crates/hir_ty/Cargo.toml +++ b/crates/hir_ty/Cargo.toml | |||
@@ -20,11 +20,11 @@ scoped-tls = "1" | |||
20 | chalk-solve = { version = "0.47", default-features = false } | 20 | chalk-solve = { version = "0.47", default-features = false } |
21 | chalk-ir = "0.47" | 21 | chalk-ir = "0.47" |
22 | chalk-recursive = "0.47" | 22 | chalk-recursive = "0.47" |
23 | la-arena = "0.1.0" | ||
23 | 24 | ||
24 | stdx = { path = "../stdx", version = "0.0.0" } | 25 | stdx = { path = "../stdx", version = "0.0.0" } |
25 | hir_def = { path = "../hir_def", version = "0.0.0" } | 26 | hir_def = { path = "../hir_def", version = "0.0.0" } |
26 | hir_expand = { path = "../hir_expand", version = "0.0.0" } | 27 | hir_expand = { path = "../hir_expand", version = "0.0.0" } |
27 | arena = { path = "../arena", version = "0.0.0" } | ||
28 | base_db = { path = "../base_db", version = "0.0.0" } | 28 | base_db = { path = "../base_db", version = "0.0.0" } |
29 | profile = { path = "../profile", version = "0.0.0" } | 29 | profile = { path = "../profile", version = "0.0.0" } |
30 | syntax = { path = "../syntax", version = "0.0.0" } | 30 | syntax = { path = "../syntax", version = "0.0.0" } |
diff --git a/crates/hir_ty/src/db.rs b/crates/hir_ty/src/db.rs index f3567c49e..b0e2a3b7d 100644 --- a/crates/hir_ty/src/db.rs +++ b/crates/hir_ty/src/db.rs | |||
@@ -2,12 +2,12 @@ | |||
2 | 2 | ||
3 | use std::sync::Arc; | 3 | use std::sync::Arc; |
4 | 4 | ||
5 | use arena::map::ArenaMap; | ||
6 | use base_db::{impl_intern_key, salsa, CrateId, Upcast}; | 5 | use base_db::{impl_intern_key, salsa, CrateId, Upcast}; |
7 | use hir_def::{ | 6 | use hir_def::{ |
8 | db::DefDatabase, expr::ExprId, ConstParamId, DefWithBodyId, FunctionId, GenericDefId, ImplId, | 7 | db::DefDatabase, expr::ExprId, ConstParamId, DefWithBodyId, FunctionId, GenericDefId, ImplId, |
9 | LocalFieldId, TypeParamId, VariantId, | 8 | LocalFieldId, TypeParamId, VariantId, |
10 | }; | 9 | }; |
10 | use la_arena::map::ArenaMap; | ||
11 | 11 | ||
12 | use crate::{ | 12 | use crate::{ |
13 | method_resolution::{InherentImpls, TraitImpls}, | 13 | method_resolution::{InherentImpls, TraitImpls}, |
diff --git a/crates/hir_ty/src/diagnostics/match_check.rs b/crates/hir_ty/src/diagnostics/match_check.rs index 61c47eec8..fbe760c39 100644 --- a/crates/hir_ty/src/diagnostics/match_check.rs +++ b/crates/hir_ty/src/diagnostics/match_check.rs | |||
@@ -218,13 +218,13 @@ | |||
218 | //! ``` | 218 | //! ``` |
219 | use std::{iter, sync::Arc}; | 219 | use std::{iter, sync::Arc}; |
220 | 220 | ||
221 | use arena::Idx; | ||
222 | use hir_def::{ | 221 | use hir_def::{ |
223 | adt::VariantData, | 222 | adt::VariantData, |
224 | body::Body, | 223 | body::Body, |
225 | expr::{Expr, Literal, Pat, PatId}, | 224 | expr::{Expr, Literal, Pat, PatId}, |
226 | AdtId, EnumVariantId, StructId, VariantId, | 225 | AdtId, EnumVariantId, StructId, VariantId, |
227 | }; | 226 | }; |
227 | use la_arena::Idx; | ||
228 | use smallvec::{smallvec, SmallVec}; | 228 | use smallvec::{smallvec, SmallVec}; |
229 | 229 | ||
230 | use crate::{db::HirDatabase, ApplicationTy, InferenceResult, Ty, TypeCtor}; | 230 | use crate::{db::HirDatabase, ApplicationTy, InferenceResult, Ty, TypeCtor}; |
diff --git a/crates/hir_ty/src/infer.rs b/crates/hir_ty/src/infer.rs index a14d67c06..46a806b9a 100644 --- a/crates/hir_ty/src/infer.rs +++ b/crates/hir_ty/src/infer.rs | |||
@@ -18,7 +18,6 @@ use std::mem; | |||
18 | use std::ops::Index; | 18 | use std::ops::Index; |
19 | use std::sync::Arc; | 19 | use std::sync::Arc; |
20 | 20 | ||
21 | use arena::map::ArenaMap; | ||
22 | use hir_def::{ | 21 | use hir_def::{ |
23 | body::Body, | 22 | body::Body, |
24 | data::{ConstData, FunctionData, StaticData}, | 23 | data::{ConstData, FunctionData, StaticData}, |
@@ -31,6 +30,7 @@ use hir_def::{ | |||
31 | TypeAliasId, VariantId, | 30 | TypeAliasId, VariantId, |
32 | }; | 31 | }; |
33 | use hir_expand::{diagnostics::DiagnosticSink, name::name}; | 32 | use hir_expand::{diagnostics::DiagnosticSink, name::name}; |
33 | use la_arena::map::ArenaMap; | ||
34 | use rustc_hash::FxHashMap; | 34 | use rustc_hash::FxHashMap; |
35 | use stdx::impl_from; | 35 | use stdx::impl_from; |
36 | use syntax::SmolStr; | 36 | use syntax::SmolStr; |
diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index 9594cce8b..68d16f89a 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs | |||
@@ -7,7 +7,6 @@ | |||
7 | //! This usually involves resolving names, collecting generic arguments etc. | 7 | //! This usually involves resolving names, collecting generic arguments etc. |
8 | use std::{iter, sync::Arc}; | 8 | use std::{iter, sync::Arc}; |
9 | 9 | ||
10 | use arena::map::ArenaMap; | ||
11 | use base_db::CrateId; | 10 | use base_db::CrateId; |
12 | use hir_def::{ | 11 | use hir_def::{ |
13 | adt::StructKind, | 12 | adt::StructKind, |
@@ -21,6 +20,7 @@ use hir_def::{ | |||
21 | TypeAliasId, TypeParamId, UnionId, VariantId, | 20 | TypeAliasId, TypeParamId, UnionId, VariantId, |
22 | }; | 21 | }; |
23 | use hir_expand::name::Name; | 22 | use hir_expand::name::Name; |
23 | use la_arena::map::ArenaMap; | ||
24 | use smallvec::SmallVec; | 24 | use smallvec::SmallVec; |
25 | use stdx::impl_from; | 25 | use stdx::impl_from; |
26 | use test_utils::mark; | 26 | use test_utils::mark; |
diff --git a/crates/profile/Cargo.toml b/crates/profile/Cargo.toml index 4951f1835..096233a09 100644 --- a/crates/profile/Cargo.toml +++ b/crates/profile/Cargo.toml | |||
@@ -13,8 +13,7 @@ doctest = false | |||
13 | once_cell = "1.3.1" | 13 | once_cell = "1.3.1" |
14 | cfg-if = "1" | 14 | cfg-if = "1" |
15 | libc = "0.2.73" | 15 | libc = "0.2.73" |
16 | 16 | la-arena = "0.1.0" | |
17 | arena = { path = "../arena", version = "0.0.0" } | ||
18 | 17 | ||
19 | [target.'cfg(target_os = "linux")'.dependencies] | 18 | [target.'cfg(target_os = "linux")'.dependencies] |
20 | perf-event = "0.4" | 19 | perf-event = "0.4" |
diff --git a/crates/profile/src/tree.rs b/crates/profile/src/tree.rs index 3fac1f36c..62f0c30b5 100644 --- a/crates/profile/src/tree.rs +++ b/crates/profile/src/tree.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | //! A simple tree implementation which tries to not allocate all over the place. | 1 | //! A simple tree implementation which tries to not allocate all over the place. |
2 | use std::ops; | 2 | use std::ops; |
3 | 3 | ||
4 | use arena::Arena; | 4 | use la_arena::Arena; |
5 | 5 | ||
6 | #[derive(Default)] | 6 | #[derive(Default)] |
7 | pub(crate) struct Tree<T> { | 7 | pub(crate) struct Tree<T> { |
@@ -9,7 +9,7 @@ pub(crate) struct Tree<T> { | |||
9 | current_path: Vec<(Idx<T>, Option<Idx<T>>)>, | 9 | current_path: Vec<(Idx<T>, Option<Idx<T>>)>, |
10 | } | 10 | } |
11 | 11 | ||
12 | pub(crate) type Idx<T> = arena::Idx<Node<T>>; | 12 | pub(crate) type Idx<T> = la_arena::Idx<Node<T>>; |
13 | 13 | ||
14 | impl<T> Tree<T> { | 14 | impl<T> Tree<T> { |
15 | pub(crate) fn start(&mut self) | 15 | pub(crate) fn start(&mut self) |
diff --git a/crates/project_model/Cargo.toml b/crates/project_model/Cargo.toml index 855fb83ea..51e7a7070 100644 --- a/crates/project_model/Cargo.toml +++ b/crates/project_model/Cargo.toml | |||
@@ -17,8 +17,8 @@ serde = { version = "1.0.106", features = ["derive"] } | |||
17 | serde_json = "1.0.48" | 17 | serde_json = "1.0.48" |
18 | anyhow = "1.0.26" | 18 | anyhow = "1.0.26" |
19 | itertools = "0.10.0" | 19 | itertools = "0.10.0" |
20 | la-arena = "0.1.0" | ||
20 | 21 | ||
21 | arena = { path = "../arena", version = "0.0.0" } | ||
22 | cfg = { path = "../cfg", version = "0.0.0" } | 22 | cfg = { path = "../cfg", version = "0.0.0" } |
23 | base_db = { path = "../base_db", version = "0.0.0" } | 23 | base_db = { path = "../base_db", version = "0.0.0" } |
24 | toolchain = { path = "../toolchain", version = "0.0.0" } | 24 | toolchain = { path = "../toolchain", version = "0.0.0" } |
diff --git a/crates/project_model/src/cargo_workspace.rs b/crates/project_model/src/cargo_workspace.rs index a1ab9c6db..c0ed37fc1 100644 --- a/crates/project_model/src/cargo_workspace.rs +++ b/crates/project_model/src/cargo_workspace.rs | |||
@@ -10,10 +10,10 @@ use std::{ | |||
10 | }; | 10 | }; |
11 | 11 | ||
12 | use anyhow::{Context, Result}; | 12 | use anyhow::{Context, Result}; |
13 | use arena::{Arena, Idx}; | ||
14 | use base_db::Edition; | 13 | use base_db::Edition; |
15 | use cargo_metadata::{BuildScript, CargoOpt, Message, MetadataCommand, PackageId}; | 14 | use cargo_metadata::{BuildScript, CargoOpt, Message, MetadataCommand, PackageId}; |
16 | use itertools::Itertools; | 15 | use itertools::Itertools; |
16 | use la_arena::{Arena, Idx}; | ||
17 | use paths::{AbsPath, AbsPathBuf}; | 17 | use paths::{AbsPath, AbsPathBuf}; |
18 | use rustc_hash::FxHashMap; | 18 | use rustc_hash::FxHashMap; |
19 | use stdx::JodChild; | 19 | use stdx::JodChild; |
diff --git a/crates/project_model/src/sysroot.rs b/crates/project_model/src/sysroot.rs index 95b622715..ff44dae4a 100644 --- a/crates/project_model/src/sysroot.rs +++ b/crates/project_model/src/sysroot.rs | |||
@@ -7,7 +7,7 @@ | |||
7 | use std::{convert::TryFrom, env, ops, path::PathBuf, process::Command}; | 7 | use std::{convert::TryFrom, env, ops, path::PathBuf, process::Command}; |
8 | 8 | ||
9 | use anyhow::{format_err, Result}; | 9 | use anyhow::{format_err, Result}; |
10 | use arena::{Arena, Idx}; | 10 | use la_arena::{Arena, Idx}; |
11 | use paths::{AbsPath, AbsPathBuf}; | 11 | use paths::{AbsPath, AbsPathBuf}; |
12 | 12 | ||
13 | use crate::utf8_stdout; | 13 | use crate::utf8_stdout; |