mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Fix hir for ast::UnionDef
This commit is contained in:
parent
e1c0bdaf75
commit
5fd68b5929
22 changed files with 121 additions and 86 deletions
|
@ -1,6 +1,6 @@
|
|||
//! FIXME: write short doc here
|
||||
|
||||
use hir_def::{AstItemDef, LocationCtx, ModuleId, StructId, StructOrUnionId, UnionId};
|
||||
use hir_def::{AstItemDef, LocationCtx, ModuleId};
|
||||
use hir_expand::{name::AsName, AstId, MacroDefId, MacroDefKind};
|
||||
use ra_syntax::{
|
||||
ast::{self, AstNode, NameOwner},
|
||||
|
@ -19,19 +19,18 @@ pub trait FromSource: Sized {
|
|||
fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self>;
|
||||
}
|
||||
|
||||
// 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<Self::Ast>) -> Option<Self> {
|
||||
let id: StructOrUnionId = from_source(db, src)?;
|
||||
Some(Struct { id: StructId(id) })
|
||||
let id = from_source(db, src)?;
|
||||
Some(Struct { id })
|
||||
}
|
||||
}
|
||||
impl FromSource for Union {
|
||||
type Ast = ast::StructDef;
|
||||
type Ast = ast::UnionDef;
|
||||
fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self> {
|
||||
let id: StructOrUnionId = from_source(db, src)?;
|
||||
Some(Union { id: UnionId(id) })
|
||||
let id = from_source(db, src)?;
|
||||
Some(Union { id })
|
||||
}
|
||||
}
|
||||
impl FromSource for Enum {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue