diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-09 12:37:49 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-09 12:37:49 +0000 |
commit | 9d786ea221b27fbdf7c7f7beea0290db448e0611 (patch) | |
tree | 312ae071afe742011c1e396d63123729e31f9815 /crates/ra_hir/src/from_source.rs | |
parent | defc7ad772123a449f7cc384dd46d88c3a45fb53 (diff) | |
parent | 6294fd5ec9c6946bdd91f1274956c573f9f2a136 (diff) |
Merge #2198
2198: Unfork struct and union ids r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/from_source.rs')
-rw-r--r-- | crates/ra_hir/src/from_source.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/crates/ra_hir/src/from_source.rs b/crates/ra_hir/src/from_source.rs index 9899bdbbc..c95d2cdd0 100644 --- a/crates/ra_hir/src/from_source.rs +++ b/crates/ra_hir/src/from_source.rs | |||
@@ -1,5 +1,6 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | use hir_def::{StructId, StructOrUnionId, UnionId}; | ||
3 | use hir_expand::name::AsName; | 4 | use hir_expand::name::AsName; |
4 | use ra_syntax::ast::{self, AstNode, NameOwner}; | 5 | use ra_syntax::ast::{self, AstNode, NameOwner}; |
5 | 6 | ||
@@ -15,18 +16,19 @@ pub trait FromSource: Sized { | |||
15 | fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self>; | 16 | fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self>; |
16 | } | 17 | } |
17 | 18 | ||
19 | // FIXIME: these two impls are wrong, `ast::StructDef` might produce either a struct or a union | ||
18 | impl FromSource for Struct { | 20 | impl FromSource for Struct { |
19 | type Ast = ast::StructDef; | 21 | type Ast = ast::StructDef; |
20 | fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self> { | 22 | fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self> { |
21 | let id = from_source(db, src)?; | 23 | let id: StructOrUnionId = from_source(db, src)?; |
22 | Some(Struct { id }) | 24 | Some(Struct { id: StructId(id) }) |
23 | } | 25 | } |
24 | } | 26 | } |
25 | impl FromSource for Union { | 27 | impl FromSource for Union { |
26 | type Ast = ast::StructDef; | 28 | type Ast = ast::StructDef; |
27 | fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self> { | 29 | fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self> { |
28 | let id = from_source(db, src)?; | 30 | let id: StructOrUnionId = from_source(db, src)?; |
29 | Some(Union { id }) | 31 | Some(Union { id: UnionId(id) }) |
30 | } | 32 | } |
31 | } | 33 | } |
32 | impl FromSource for Enum { | 34 | impl FromSource for Enum { |