From 6294fd5ec9c6946bdd91f1274956c573f9f2a136 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 9 Nov 2019 15:34:00 +0300 Subject: Unfork struct and union ids --- crates/ra_hir/src/from_source.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'crates/ra_hir/src/from_source.rs') 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 @@ //! FIXME: write short doc here +use hir_def::{StructId, StructOrUnionId, UnionId}; use hir_expand::name::AsName; use ra_syntax::ast::{self, AstNode, NameOwner}; @@ -15,18 +16,19 @@ pub trait FromSource: Sized { fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source) -> Option; } +// FIXIME: these two impls are wrong, `ast::StructDef` might produce either a struct or a union impl FromSource for Struct { type Ast = ast::StructDef; fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source) -> Option { - let id = from_source(db, src)?; - Some(Struct { id }) + let id: StructOrUnionId = from_source(db, src)?; + Some(Struct { id: StructId(id) }) } } impl FromSource for Union { type Ast = ast::StructDef; fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source) -> Option { - let id = from_source(db, src)?; - Some(Union { id }) + let id: StructOrUnionId = from_source(db, src)?; + Some(Union { id: UnionId(id) }) } } impl FromSource for Enum { -- cgit v1.2.3