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_expand/src | |
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_expand/src')
-rw-r--r-- | crates/ra_hir_expand/src/ast_id_map.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/crates/ra_hir_expand/src/ast_id_map.rs b/crates/ra_hir_expand/src/ast_id_map.rs index a764bdf24..a6644d55f 100644 --- a/crates/ra_hir_expand/src/ast_id_map.rs +++ b/crates/ra_hir_expand/src/ast_id_map.rs | |||
@@ -10,7 +10,7 @@ use std::{ | |||
10 | marker::PhantomData, | 10 | marker::PhantomData, |
11 | }; | 11 | }; |
12 | 12 | ||
13 | use ra_arena::{impl_arena_id, Arena, RawId}; | 13 | use ra_arena::{Arena, Idx}; |
14 | use ra_syntax::{ast, AstNode, AstPtr, SyntaxNode, SyntaxNodePtr}; | 14 | use ra_syntax::{ast, AstNode, AstPtr, SyntaxNode, SyntaxNodePtr}; |
15 | 15 | ||
16 | /// `AstId` points to an AST node in a specific file. | 16 | /// `AstId` points to an AST node in a specific file. |
@@ -49,14 +49,12 @@ impl<N: AstNode> FileAstId<N> { | |||
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | 52 | type ErasedFileAstId = Idx<SyntaxNodePtr>; |
53 | struct ErasedFileAstId(RawId); | ||
54 | impl_arena_id!(ErasedFileAstId); | ||
55 | 53 | ||
56 | /// Maps items' `SyntaxNode`s to `ErasedFileAstId`s and back. | 54 | /// Maps items' `SyntaxNode`s to `ErasedFileAstId`s and back. |
57 | #[derive(Debug, PartialEq, Eq, Default)] | 55 | #[derive(Debug, PartialEq, Eq, Default)] |
58 | pub struct AstIdMap { | 56 | pub struct AstIdMap { |
59 | arena: Arena<ErasedFileAstId, SyntaxNodePtr>, | 57 | arena: Arena<SyntaxNodePtr>, |
60 | } | 58 | } |
61 | 59 | ||
62 | impl AstIdMap { | 60 | impl AstIdMap { |