mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
move adt to adt
This commit is contained in:
parent
a03c109f50
commit
31d3a56b18
3 changed files with 23 additions and 24 deletions
|
@ -3,17 +3,32 @@
|
|||
|
||||
use std::sync::Arc;
|
||||
|
||||
use ra_syntax::{
|
||||
ast::{self, NameOwner, StructFlavor}
|
||||
};
|
||||
use ra_syntax::ast::{self, NameOwner, StructFlavor};
|
||||
|
||||
use crate::{
|
||||
Name, AsName, Struct, Enum, EnumVariant,
|
||||
Name, AsName, Struct, Enum, EnumVariant, Crate,
|
||||
HirDatabase,
|
||||
type_ref::TypeRef,
|
||||
ids::LocationCtx,
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum AdtDef {
|
||||
Struct(Struct),
|
||||
Enum(Enum),
|
||||
}
|
||||
impl_froms!(AdtDef: Struct, Enum);
|
||||
|
||||
impl AdtDef {
|
||||
pub(crate) fn krate(self, db: &impl HirDatabase) -> Option<Crate> {
|
||||
match self {
|
||||
AdtDef::Struct(s) => s.module(db),
|
||||
AdtDef::Enum(e) => e.module(db),
|
||||
}
|
||||
.krate(db)
|
||||
}
|
||||
}
|
||||
|
||||
impl Struct {
|
||||
pub(crate) fn variant_data(&self, db: &impl HirDatabase) -> Arc<VariantData> {
|
||||
db.struct_data((*self).into()).variant_data.clone()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue