diff options
Diffstat (limited to 'crates/hir_def')
-rw-r--r-- | crates/hir_def/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/hir_def/src/adt.rs | 2 | ||||
-rw-r--r-- | crates/hir_def/src/attr.rs | 2 | ||||
-rw-r--r-- | crates/hir_def/src/body.rs | 2 | ||||
-rw-r--r-- | crates/hir_def/src/db.rs | 2 | ||||
-rw-r--r-- | crates/hir_def/src/expr.rs | 4 | ||||
-rw-r--r-- | crates/hir_def/src/generics.rs | 2 | ||||
-rw-r--r-- | crates/hir_def/src/item_tree.rs | 12 | ||||
-rw-r--r-- | crates/hir_def/src/item_tree/lower.rs | 4 | ||||
-rw-r--r-- | crates/hir_def/src/path.rs | 2 | ||||
-rw-r--r-- | crates/hir_def/src/src.rs | 2 | ||||
-rw-r--r-- | crates/hir_def/src/trace.rs | 4 | ||||
-rw-r--r-- | crates/hir_def/src/type_ref.rs | 2 |
13 files changed, 18 insertions, 24 deletions
diff --git a/crates/hir_def/Cargo.toml b/crates/hir_def/Cargo.toml index 5d21283f7..535221294 100644 --- a/crates/hir_def/Cargo.toml +++ b/crates/hir_def/Cargo.toml | |||
@@ -20,7 +20,7 @@ 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 | la-arena = { version = "0.2.0", path = "../../lib/arena" } |
24 | 24 | ||
25 | stdx = { path = "../stdx", version = "0.0.0" } | 25 | stdx = { path = "../stdx", version = "0.0.0" } |
26 | base_db = { path = "../base_db", version = "0.0.0" } | 26 | base_db = { path = "../base_db", version = "0.0.0" } |
diff --git a/crates/hir_def/src/adt.rs b/crates/hir_def/src/adt.rs index 237c3d3f9..06f0b9b18 100644 --- a/crates/hir_def/src/adt.rs +++ b/crates/hir_def/src/adt.rs | |||
@@ -8,7 +8,7 @@ use hir_expand::{ | |||
8 | name::{AsName, Name}, | 8 | name::{AsName, Name}, |
9 | InFile, | 9 | InFile, |
10 | }; | 10 | }; |
11 | use la_arena::{map::ArenaMap, Arena}; | 11 | use la_arena::{Arena, ArenaMap}; |
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 5a86823c2..1b09ff816 100644 --- a/crates/hir_def/src/attr.rs +++ b/crates/hir_def/src/attr.rs | |||
@@ -7,7 +7,7 @@ use cfg::{CfgExpr, CfgOptions}; | |||
7 | use either::Either; | 7 | use either::Either; |
8 | use hir_expand::{hygiene::Hygiene, name::AsName, AstId, InFile}; | 8 | use hir_expand::{hygiene::Hygiene, name::AsName, AstId, InFile}; |
9 | use itertools::Itertools; | 9 | use itertools::Itertools; |
10 | use la_arena::map::ArenaMap; | 10 | use la_arena::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 43ee57277..344f0b6c0 100644 --- a/crates/hir_def/src/body.rs +++ b/crates/hir_def/src/body.rs | |||
@@ -16,7 +16,7 @@ use hir_expand::{ | |||
16 | ast_id_map::AstIdMap, diagnostics::DiagnosticSink, hygiene::Hygiene, AstId, ExpandResult, | 16 | ast_id_map::AstIdMap, diagnostics::DiagnosticSink, hygiene::Hygiene, AstId, ExpandResult, |
17 | HirFileId, InFile, MacroDefId, | 17 | HirFileId, InFile, MacroDefId, |
18 | }; | 18 | }; |
19 | use la_arena::{map::ArenaMap, Arena}; | 19 | use la_arena::{Arena, ArenaMap}; |
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/db.rs b/crates/hir_def/src/db.rs index 0506a7274..6ef9fe790 100644 --- a/crates/hir_def/src/db.rs +++ b/crates/hir_def/src/db.rs | |||
@@ -3,7 +3,7 @@ use std::sync::Arc; | |||
3 | 3 | ||
4 | use base_db::{salsa, CrateId, SourceDatabase, Upcast}; | 4 | use base_db::{salsa, CrateId, SourceDatabase, Upcast}; |
5 | use hir_expand::{db::AstDatabase, HirFileId}; | 5 | use hir_expand::{db::AstDatabase, HirFileId}; |
6 | use la_arena::map::ArenaMap; | 6 | use la_arena::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 a293df9f1..5be838f4a 100644 --- a/crates/hir_def/src/expr.rs +++ b/crates/hir_def/src/expr.rs | |||
@@ -13,7 +13,7 @@ | |||
13 | //! See also a neighboring `body` module. | 13 | //! See also a neighboring `body` module. |
14 | 14 | ||
15 | use hir_expand::name::Name; | 15 | use hir_expand::name::Name; |
16 | use la_arena::{Idx, RawId}; | 16 | use la_arena::{Idx, RawIdx}; |
17 | use syntax::ast::RangeOp; | 17 | use syntax::ast::RangeOp; |
18 | 18 | ||
19 | use crate::{ | 19 | use crate::{ |
@@ -24,7 +24,7 @@ use crate::{ | |||
24 | 24 | ||
25 | pub type ExprId = Idx<Expr>; | 25 | pub type ExprId = Idx<Expr>; |
26 | pub(crate) fn dummy_expr_id() -> ExprId { | 26 | pub(crate) fn dummy_expr_id() -> ExprId { |
27 | ExprId::from_raw(RawId::from(!0)) | 27 | ExprId::from_raw(RawIdx::from(!0)) |
28 | } | 28 | } |
29 | 29 | ||
30 | pub type PatId = Idx<Pat>; | 30 | pub type PatId = Idx<Pat>; |
diff --git a/crates/hir_def/src/generics.rs b/crates/hir_def/src/generics.rs index 75eab791a..3ace3be1f 100644 --- a/crates/hir_def/src/generics.rs +++ b/crates/hir_def/src/generics.rs | |||
@@ -10,7 +10,7 @@ use hir_expand::{ | |||
10 | name::{name, AsName, Name}, | 10 | name::{name, AsName, Name}, |
11 | InFile, | 11 | InFile, |
12 | }; | 12 | }; |
13 | use la_arena::{map::ArenaMap, Arena}; | 13 | use la_arena::{Arena, ArenaMap}; |
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 91e42aa0d..ff62928df 100644 --- a/crates/hir_def/src/item_tree.rs +++ b/crates/hir_def/src/item_tree.rs | |||
@@ -20,7 +20,7 @@ use hir_expand::{ | |||
20 | name::{name, AsName, Name}, | 20 | name::{name, AsName, Name}, |
21 | HirFileId, InFile, | 21 | HirFileId, InFile, |
22 | }; | 22 | }; |
23 | use la_arena::{Arena, Idx, RawId}; | 23 | use la_arena::{Arena, Idx, RawIdx}; |
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}; |
@@ -145,7 +145,6 @@ impl ItemTree { | |||
145 | macro_calls, | 145 | macro_calls, |
146 | macro_rules, | 146 | macro_rules, |
147 | macro_defs, | 147 | macro_defs, |
148 | exprs, | ||
149 | vis, | 148 | vis, |
150 | generics, | 149 | generics, |
151 | } = &mut **data; | 150 | } = &mut **data; |
@@ -167,7 +166,6 @@ impl ItemTree { | |||
167 | macro_calls.shrink_to_fit(); | 166 | macro_calls.shrink_to_fit(); |
168 | macro_rules.shrink_to_fit(); | 167 | macro_rules.shrink_to_fit(); |
169 | macro_defs.shrink_to_fit(); | 168 | macro_defs.shrink_to_fit(); |
170 | exprs.shrink_to_fit(); | ||
171 | 169 | ||
172 | vis.arena.shrink_to_fit(); | 170 | vis.arena.shrink_to_fit(); |
173 | generics.arena.shrink_to_fit(); | 171 | generics.arena.shrink_to_fit(); |
@@ -296,7 +294,6 @@ struct ItemTreeData { | |||
296 | macro_calls: Arena<MacroCall>, | 294 | macro_calls: Arena<MacroCall>, |
297 | macro_rules: Arena<MacroRules>, | 295 | macro_rules: Arena<MacroRules>, |
298 | macro_defs: Arena<MacroDef>, | 296 | macro_defs: Arena<MacroDef>, |
299 | exprs: Arena<Expr>, | ||
300 | 297 | ||
301 | vis: ItemVisibilities, | 298 | vis: ItemVisibilities, |
302 | generics: GenericParamsStorage, | 299 | generics: GenericParamsStorage, |
@@ -461,7 +458,7 @@ macro_rules! impl_index { | |||
461 | }; | 458 | }; |
462 | } | 459 | } |
463 | 460 | ||
464 | impl_index!(fields: Field, variants: Variant, exprs: Expr); | 461 | impl_index!(fields: Field, variants: Variant); |
465 | 462 | ||
466 | impl Index<RawVisibilityId> for ItemTree { | 463 | impl Index<RawVisibilityId> for ItemTree { |
467 | type Output = RawVisibility; | 464 | type Output = RawVisibility; |
@@ -664,11 +661,6 @@ pub struct MacroDef { | |||
664 | pub ast_id: FileAstId<ast::MacroDef>, | 661 | pub ast_id: FileAstId<ast::MacroDef>, |
665 | } | 662 | } |
666 | 663 | ||
667 | // NB: There's no `FileAstId` for `Expr`. The only case where this would be useful is for array | ||
668 | // lengths, but we don't do much with them yet. | ||
669 | #[derive(Debug, Clone, Eq, PartialEq)] | ||
670 | pub struct Expr; | ||
671 | |||
672 | macro_rules! impl_froms { | 664 | macro_rules! impl_froms { |
673 | ($e:ident { $($v:ident ($t:ty)),* $(,)? }) => { | 665 | ($e:ident { $($v:ident ($t:ty)),* $(,)? }) => { |
674 | $( | 666 | $( |
diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs index 3b206ef85..5e71ca42c 100644 --- a/crates/hir_def/src/item_tree/lower.rs +++ b/crates/hir_def/src/item_tree/lower.rs | |||
@@ -683,12 +683,12 @@ impl Ctx { | |||
683 | } | 683 | } |
684 | 684 | ||
685 | fn next_field_idx(&self) -> Idx<Field> { | 685 | fn next_field_idx(&self) -> Idx<Field> { |
686 | Idx::from_raw(RawId::from( | 686 | Idx::from_raw(RawIdx::from( |
687 | self.tree.data.as_ref().map_or(0, |data| data.fields.len() as u32), | 687 | self.tree.data.as_ref().map_or(0, |data| data.fields.len() as u32), |
688 | )) | 688 | )) |
689 | } | 689 | } |
690 | fn next_variant_idx(&self) -> Idx<Variant> { | 690 | fn next_variant_idx(&self) -> Idx<Variant> { |
691 | Idx::from_raw(RawId::from( | 691 | Idx::from_raw(RawIdx::from( |
692 | self.tree.data.as_ref().map_or(0, |data| data.variants.len() as u32), | 692 | self.tree.data.as_ref().map_or(0, |data| data.variants.len() as u32), |
693 | )) | 693 | )) |
694 | } | 694 | } |
diff --git a/crates/hir_def/src/path.rs b/crates/hir_def/src/path.rs index 3dd7c3cbb..e34cd7f2f 100644 --- a/crates/hir_def/src/path.rs +++ b/crates/hir_def/src/path.rs | |||
@@ -87,7 +87,7 @@ impl ModPath { | |||
87 | 87 | ||
88 | /// If this path is a single identifier, like `foo`, return its name. | 88 | /// If this path is a single identifier, like `foo`, return its name. |
89 | pub fn as_ident(&self) -> Option<&Name> { | 89 | pub fn as_ident(&self) -> Option<&Name> { |
90 | if self.kind != PathKind::Plain || self.segments.len() > 1 { | 90 | if !self.is_ident() { |
91 | return None; | 91 | return None; |
92 | } | 92 | } |
93 | self.segments.first() | 93 | self.segments.first() |
diff --git a/crates/hir_def/src/src.rs b/crates/hir_def/src/src.rs index eb29265d9..751d4c052 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 hir_expand::InFile; | 3 | use hir_expand::InFile; |
4 | use la_arena::map::ArenaMap; | 4 | use la_arena::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 0a9beae8e..6e6ceb8e4 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 la_arena::{map::ArenaMap, Arena, Idx, RawId}; | 12 | use la_arena::{Arena, ArenaMap, Idx, RawIdx}; |
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>>, |
@@ -30,7 +30,7 @@ impl<T, V> Trace<T, V> { | |||
30 | let id = if let Some(arena) = &mut self.arena { | 30 | let id = if let Some(arena) = &mut self.arena { |
31 | arena.alloc(data()) | 31 | arena.alloc(data()) |
32 | } else { | 32 | } else { |
33 | let id = Idx::<T>::from_raw(RawId::from(self.len)); | 33 | let id = Idx::<T>::from_raw(RawIdx::from(self.len)); |
34 | self.len += 1; | 34 | self.len += 1; |
35 | id | 35 | id |
36 | }; | 36 | }; |
diff --git a/crates/hir_def/src/type_ref.rs b/crates/hir_def/src/type_ref.rs index ae93d0d10..049b2e462 100644 --- a/crates/hir_def/src/type_ref.rs +++ b/crates/hir_def/src/type_ref.rs | |||
@@ -159,6 +159,8 @@ impl TypeRef { | |||
159 | ast::Type::DynTraitType(inner) => { | 159 | ast::Type::DynTraitType(inner) => { |
160 | TypeRef::DynTrait(type_bounds_from_ast(ctx, inner.type_bound_list())) | 160 | TypeRef::DynTrait(type_bounds_from_ast(ctx, inner.type_bound_list())) |
161 | } | 161 | } |
162 | // FIXME: Macros in type position are not yet supported. | ||
163 | ast::Type::MacroType(_) => TypeRef::Error, | ||
162 | } | 164 | } |
163 | } | 165 | } |
164 | 166 | ||