diff options
Diffstat (limited to 'crates/ra_hir/src/code_model.rs')
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index a10e795ce..c1938bd86 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -127,7 +127,7 @@ impl BuiltinType { | |||
127 | pub enum ModuleDef { | 127 | pub enum ModuleDef { |
128 | Module(Module), | 128 | Module(Module), |
129 | Function(Function), | 129 | Function(Function), |
130 | AdtDef(AdtDef), | 130 | Adt(Adt), |
131 | // Can't be directly declared, but can be imported. | 131 | // Can't be directly declared, but can be imported. |
132 | EnumVariant(EnumVariant), | 132 | EnumVariant(EnumVariant), |
133 | Const(Const), | 133 | Const(Const), |
@@ -139,7 +139,7 @@ pub enum ModuleDef { | |||
139 | impl_froms!( | 139 | impl_froms!( |
140 | ModuleDef: Module, | 140 | ModuleDef: Module, |
141 | Function, | 141 | Function, |
142 | AdtDef(Struct, Enum, Union), | 142 | Adt(Struct, Enum, Union), |
143 | EnumVariant, | 143 | EnumVariant, |
144 | Const, | 144 | Const, |
145 | Static, | 145 | Static, |
@@ -496,37 +496,38 @@ impl EnumVariant { | |||
496 | } | 496 | } |
497 | } | 497 | } |
498 | 498 | ||
499 | /// A Data Type | ||
499 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] | 500 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] |
500 | pub enum AdtDef { | 501 | pub enum Adt { |
501 | Struct(Struct), | 502 | Struct(Struct), |
502 | Union(Union), | 503 | Union(Union), |
503 | Enum(Enum), | 504 | Enum(Enum), |
504 | } | 505 | } |
505 | impl_froms!(AdtDef: Struct, Union, Enum); | 506 | impl_froms!(Adt: Struct, Union, Enum); |
506 | 507 | ||
507 | impl AdtDef { | 508 | impl Adt { |
508 | pub fn ty(self, db: &impl HirDatabase) -> Ty { | 509 | pub fn ty(self, db: &impl HirDatabase) -> Ty { |
509 | match self { | 510 | match self { |
510 | AdtDef::Struct(it) => it.ty(db), | 511 | Adt::Struct(it) => it.ty(db), |
511 | AdtDef::Union(it) => it.ty(db), | 512 | Adt::Union(it) => it.ty(db), |
512 | AdtDef::Enum(it) => it.ty(db), | 513 | Adt::Enum(it) => it.ty(db), |
513 | } | 514 | } |
514 | } | 515 | } |
515 | 516 | ||
516 | pub(crate) fn krate(self, db: &impl HirDatabase) -> Option<Crate> { | 517 | pub(crate) fn krate(self, db: &impl HirDatabase) -> Option<Crate> { |
517 | match self { | 518 | match self { |
518 | AdtDef::Struct(s) => s.module(db), | 519 | Adt::Struct(s) => s.module(db), |
519 | AdtDef::Union(s) => s.module(db), | 520 | Adt::Union(s) => s.module(db), |
520 | AdtDef::Enum(e) => e.module(db), | 521 | Adt::Enum(e) => e.module(db), |
521 | } | 522 | } |
522 | .krate(db) | 523 | .krate(db) |
523 | } | 524 | } |
524 | 525 | ||
525 | pub(crate) fn resolver(self, db: &impl HirDatabase) -> Resolver { | 526 | pub(crate) fn resolver(self, db: &impl HirDatabase) -> Resolver { |
526 | match self { | 527 | match self { |
527 | AdtDef::Struct(it) => it.resolver(db), | 528 | Adt::Struct(it) => it.resolver(db), |
528 | AdtDef::Union(it) => it.resolver(db), | 529 | Adt::Union(it) => it.resolver(db), |
529 | AdtDef::Enum(it) => it.resolver(db), | 530 | Adt::Enum(it) => it.resolver(db), |
530 | } | 531 | } |
531 | } | 532 | } |
532 | } | 533 | } |