diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-09-12 22:35:28 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2019-09-12 22:35:28 +0100 |
commit | 1adf0519bcc8286c06e12aa7e5b16298addfea4a (patch) | |
tree | 3fe7cb05dc4d92d19ecbb87bfafc4a9ff202153e /crates/ra_hir/src/ty/lower.rs | |
parent | d8b621cf26b59ff5ae9379b50fc822590b6a3a4e (diff) | |
parent | 114a1b878e95c20490af574550ea0825b7a8f9d1 (diff) |
Merge #1835
1835: rename AdtDef -> Adt r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/ty/lower.rs')
-rw-r--r-- | crates/ra_hir/src/ty/lower.rs | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs index e67525a74..946e9e9fb 100644 --- a/crates/ra_hir/src/ty/lower.rs +++ b/crates/ra_hir/src/ty/lower.rs | |||
@@ -20,7 +20,7 @@ use crate::{ | |||
20 | nameres::Namespace, | 20 | nameres::Namespace, |
21 | path::{GenericArg, PathSegment}, | 21 | path::{GenericArg, PathSegment}, |
22 | resolve::{Resolution, Resolver}, | 22 | resolve::{Resolution, Resolver}, |
23 | ty::AdtDef, | 23 | ty::Adt, |
24 | type_ref::{TypeBound, TypeRef}, | 24 | type_ref::{TypeBound, TypeRef}, |
25 | BuiltinType, Const, Enum, EnumVariant, Function, ModuleDef, Path, Static, Struct, StructField, | 25 | BuiltinType, Const, Enum, EnumVariant, Function, ModuleDef, Path, Static, Struct, StructField, |
26 | Trait, TypeAlias, Union, | 26 | Trait, TypeAlias, Union, |
@@ -172,9 +172,7 @@ impl Ty { | |||
172 | ) -> Substs { | 172 | ) -> Substs { |
173 | let def_generic: Option<GenericDef> = match resolved { | 173 | let def_generic: Option<GenericDef> = match resolved { |
174 | TypableDef::Function(func) => Some(func.into()), | 174 | TypableDef::Function(func) => Some(func.into()), |
175 | TypableDef::Struct(s) => Some(s.into()), | 175 | TypableDef::Adt(adt) => Some(adt.into()), |
176 | TypableDef::Union(u) => Some(u.into()), | ||
177 | TypableDef::Enum(e) => Some(e.into()), | ||
178 | TypableDef::EnumVariant(var) => Some(var.parent_enum(db).into()), | 176 | TypableDef::EnumVariant(var) => Some(var.parent_enum(db).into()), |
179 | TypableDef::TypeAlias(t) => Some(t.into()), | 177 | TypableDef::TypeAlias(t) => Some(t.into()), |
180 | TypableDef::Const(_) | TypableDef::Static(_) | TypableDef::BuiltinType(_) => None, | 178 | TypableDef::Const(_) | TypableDef::Static(_) | TypableDef::BuiltinType(_) => None, |
@@ -193,9 +191,7 @@ impl Ty { | |||
193 | let last = path.segments.last().expect("path should have at least one segment"); | 191 | let last = path.segments.last().expect("path should have at least one segment"); |
194 | let segment = match resolved { | 192 | let segment = match resolved { |
195 | TypableDef::Function(_) | 193 | TypableDef::Function(_) |
196 | | TypableDef::Struct(_) | 194 | | TypableDef::Adt(_) |
197 | | TypableDef::Union(_) | ||
198 | | TypableDef::Enum(_) | ||
199 | | TypableDef::Const(_) | 195 | | TypableDef::Const(_) |
200 | | TypableDef::Static(_) | 196 | | TypableDef::Static(_) |
201 | | TypableDef::TypeAlias(_) | 197 | | TypableDef::TypeAlias(_) |
@@ -410,11 +406,9 @@ fn assoc_type_bindings_from_type_bound<'a>( | |||
410 | pub(crate) fn type_for_def(db: &impl HirDatabase, def: TypableDef, ns: Namespace) -> Ty { | 406 | pub(crate) fn type_for_def(db: &impl HirDatabase, def: TypableDef, ns: Namespace) -> Ty { |
411 | match (def, ns) { | 407 | match (def, ns) { |
412 | (TypableDef::Function(f), Namespace::Values) => type_for_fn(db, f), | 408 | (TypableDef::Function(f), Namespace::Values) => type_for_fn(db, f), |
413 | (TypableDef::Struct(s), Namespace::Types) => type_for_adt(db, s), | 409 | (TypableDef::Adt(Adt::Struct(s)), Namespace::Values) => type_for_struct_constructor(db, s), |
414 | (TypableDef::Struct(s), Namespace::Values) => type_for_struct_constructor(db, s), | 410 | (TypableDef::Adt(adt), Namespace::Types) => type_for_adt(db, adt), |
415 | (TypableDef::Enum(e), Namespace::Types) => type_for_adt(db, e), | ||
416 | (TypableDef::EnumVariant(v), Namespace::Values) => type_for_enum_variant_constructor(db, v), | 411 | (TypableDef::EnumVariant(v), Namespace::Values) => type_for_enum_variant_constructor(db, v), |
417 | (TypableDef::Union(u), Namespace::Types) => type_for_adt(db, u), | ||
418 | (TypableDef::TypeAlias(t), Namespace::Types) => type_for_type_alias(db, t), | 412 | (TypableDef::TypeAlias(t), Namespace::Types) => type_for_type_alias(db, t), |
419 | (TypableDef::Const(c), Namespace::Values) => type_for_const(db, c), | 413 | (TypableDef::Const(c), Namespace::Values) => type_for_const(db, c), |
420 | (TypableDef::Static(c), Namespace::Values) => type_for_static(db, c), | 414 | (TypableDef::Static(c), Namespace::Values) => type_for_static(db, c), |
@@ -422,8 +416,8 @@ pub(crate) fn type_for_def(db: &impl HirDatabase, def: TypableDef, ns: Namespace | |||
422 | 416 | ||
423 | // 'error' cases: | 417 | // 'error' cases: |
424 | (TypableDef::Function(_), Namespace::Types) => Ty::Unknown, | 418 | (TypableDef::Function(_), Namespace::Types) => Ty::Unknown, |
425 | (TypableDef::Union(_), Namespace::Values) => Ty::Unknown, | 419 | (TypableDef::Adt(Adt::Union(_)), Namespace::Values) => Ty::Unknown, |
426 | (TypableDef::Enum(_), Namespace::Values) => Ty::Unknown, | 420 | (TypableDef::Adt(Adt::Enum(_)), Namespace::Values) => Ty::Unknown, |
427 | (TypableDef::EnumVariant(_), Namespace::Types) => Ty::Unknown, | 421 | (TypableDef::EnumVariant(_), Namespace::Types) => Ty::Unknown, |
428 | (TypableDef::TypeAlias(_), Namespace::Values) => Ty::Unknown, | 422 | (TypableDef::TypeAlias(_), Namespace::Values) => Ty::Unknown, |
429 | (TypableDef::Const(_), Namespace::Types) => Ty::Unknown, | 423 | (TypableDef::Const(_), Namespace::Types) => Ty::Unknown, |
@@ -591,7 +585,7 @@ fn type_for_enum_variant_constructor(db: &impl HirDatabase, def: EnumVariant) -> | |||
591 | Ty::apply(TypeCtor::FnDef(def.into()), substs) | 585 | Ty::apply(TypeCtor::FnDef(def.into()), substs) |
592 | } | 586 | } |
593 | 587 | ||
594 | fn type_for_adt(db: &impl HirDatabase, adt: impl Into<AdtDef> + HasGenericParams) -> Ty { | 588 | fn type_for_adt(db: &impl HirDatabase, adt: impl Into<Adt> + HasGenericParams) -> Ty { |
595 | let generics = adt.generic_params(db); | 589 | let generics = adt.generic_params(db); |
596 | Ty::apply(TypeCtor::Adt(adt.into()), Substs::identity(&generics)) | 590 | Ty::apply(TypeCtor::Adt(adt.into()), Substs::identity(&generics)) |
597 | } | 591 | } |
@@ -608,9 +602,7 @@ fn type_for_type_alias(db: &impl HirDatabase, t: TypeAlias) -> Ty { | |||
608 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] | 602 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] |
609 | pub enum TypableDef { | 603 | pub enum TypableDef { |
610 | Function(Function), | 604 | Function(Function), |
611 | Struct(Struct), | 605 | Adt(Adt), |
612 | Union(Union), | ||
613 | Enum(Enum), | ||
614 | EnumVariant(EnumVariant), | 606 | EnumVariant(EnumVariant), |
615 | TypeAlias(TypeAlias), | 607 | TypeAlias(TypeAlias), |
616 | Const(Const), | 608 | Const(Const), |
@@ -619,9 +611,7 @@ pub enum TypableDef { | |||
619 | } | 611 | } |
620 | impl_froms!( | 612 | impl_froms!( |
621 | TypableDef: Function, | 613 | TypableDef: Function, |
622 | Struct, | 614 | Adt(Struct, Enum, Union), |
623 | Union, | ||
624 | Enum, | ||
625 | EnumVariant, | 615 | EnumVariant, |
626 | TypeAlias, | 616 | TypeAlias, |
627 | Const, | 617 | Const, |
@@ -633,9 +623,7 @@ impl From<ModuleDef> for Option<TypableDef> { | |||
633 | fn from(def: ModuleDef) -> Option<TypableDef> { | 623 | fn from(def: ModuleDef) -> Option<TypableDef> { |
634 | let res = match def { | 624 | let res = match def { |
635 | ModuleDef::Function(f) => f.into(), | 625 | ModuleDef::Function(f) => f.into(), |
636 | ModuleDef::Struct(s) => s.into(), | 626 | ModuleDef::Adt(adt) => adt.into(), |
637 | ModuleDef::Union(u) => u.into(), | ||
638 | ModuleDef::Enum(e) => e.into(), | ||
639 | ModuleDef::EnumVariant(v) => v.into(), | 627 | ModuleDef::EnumVariant(v) => v.into(), |
640 | ModuleDef::TypeAlias(t) => t.into(), | 628 | ModuleDef::TypeAlias(t) => t.into(), |
641 | ModuleDef::Const(v) => v.into(), | 629 | ModuleDef::Const(v) => v.into(), |