aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-09-12 22:34:52 +0100
committerAleksey Kladov <[email protected]>2019-09-12 22:34:52 +0100
commit114a1b878e95c20490af574550ea0825b7a8f9d1 (patch)
tree3fe7cb05dc4d92d19ecbb87bfafc4a9ff202153e /crates/ra_hir/src/ty
parentbcf30d389c3744ab517372431eb7e1e1dfcc50df (diff)
rename AdtDef -> Adt
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r--crates/ra_hir/src/ty/infer.rs14
-rw-r--r--crates/ra_hir/src/ty/lower.rs24
2 files changed, 18 insertions, 20 deletions
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs
index 725eec834..540a99b15 100644
--- a/crates/ra_hir/src/ty/infer.rs
+++ b/crates/ra_hir/src/ty/infer.rs
@@ -48,7 +48,7 @@ use crate::{
48 resolve::{Resolution, Resolver}, 48 resolve::{Resolution, Resolver},
49 ty::infer::diagnostics::InferenceDiagnostic, 49 ty::infer::diagnostics::InferenceDiagnostic,
50 type_ref::{Mutability, TypeRef}, 50 type_ref::{Mutability, TypeRef},
51 AdtDef, ConstData, DefWithBody, FnData, Function, HasBody, ImplItem, ModuleDef, Name, Path, 51 Adt, ConstData, DefWithBody, FnData, Function, HasBody, ImplItem, ModuleDef, Name, Path,
52 StructField, 52 StructField,
53}; 53};
54 54
@@ -668,7 +668,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
668 // FIXME remove the duplication between here and `Ty::from_path`? 668 // FIXME remove the duplication between here and `Ty::from_path`?
669 let substs = Ty::substs_from_path(self.db, resolver, path, def); 669 let substs = Ty::substs_from_path(self.db, resolver, path, def);
670 match def { 670 match def {
671 TypableDef::AdtDef(AdtDef::Struct(s)) => { 671 TypableDef::Adt(Adt::Struct(s)) => {
672 let ty = s.ty(self.db); 672 let ty = s.ty(self.db);
673 let ty = self.insert_type_vars(ty.apply_substs(substs)); 673 let ty = self.insert_type_vars(ty.apply_substs(substs));
674 (ty, Some(s.into())) 674 (ty, Some(s.into()))
@@ -678,8 +678,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
678 let ty = self.insert_type_vars(ty.apply_substs(substs)); 678 let ty = self.insert_type_vars(ty.apply_substs(substs));
679 (ty, Some(var.into())) 679 (ty, Some(var.into()))
680 } 680 }
681 TypableDef::AdtDef(AdtDef::Enum(_)) 681 TypableDef::Adt(Adt::Enum(_))
682 | TypableDef::AdtDef(AdtDef::Union(_)) 682 | TypableDef::Adt(Adt::Union(_))
683 | TypableDef::TypeAlias(_) 683 | TypableDef::TypeAlias(_)
684 | TypableDef::Function(_) 684 | TypableDef::Function(_)
685 | TypableDef::Const(_) 685 | TypableDef::Const(_)
@@ -1185,7 +1185,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
1185 let i = name.to_string().parse::<usize>().ok(); 1185 let i = name.to_string().parse::<usize>().ok();
1186 i.and_then(|i| a_ty.parameters.0.get(i).cloned()) 1186 i.and_then(|i| a_ty.parameters.0.get(i).cloned())
1187 } 1187 }
1188 TypeCtor::Adt(AdtDef::Struct(s)) => s.field(self.db, name).map(|field| { 1188 TypeCtor::Adt(Adt::Struct(s)) => s.field(self.db, name).map(|field| {
1189 self.write_field_resolution(tgt_expr, field); 1189 self.write_field_resolution(tgt_expr, field);
1190 field.ty(self.db).subst(&a_ty.parameters) 1190 field.ty(self.db).subst(&a_ty.parameters)
1191 }), 1191 }),
@@ -1489,7 +1489,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
1489 trait_.associated_type_by_name(self.db, &name::OUTPUT) 1489 trait_.associated_type_by_name(self.db, &name::OUTPUT)
1490 } 1490 }
1491 1491
1492 fn resolve_boxed_box(&self) -> Option<AdtDef> { 1492 fn resolve_boxed_box(&self) -> Option<Adt> {
1493 let boxed_box_path = Path { 1493 let boxed_box_path = Path {
1494 kind: PathKind::Abs, 1494 kind: PathKind::Abs,
1495 segments: vec![ 1495 segments: vec![
@@ -1499,7 +1499,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
1499 ], 1499 ],
1500 }; 1500 };
1501 let struct_ = self.resolver.resolve_known_struct(self.db, &boxed_box_path)?; 1501 let struct_ = self.resolver.resolve_known_struct(self.db, &boxed_box_path)?;
1502 Some(AdtDef::Struct(struct_)) 1502 Some(Adt::Struct(struct_))
1503 } 1503 }
1504} 1504}
1505 1505
diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs
index 105c893f0..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,7 +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::AdtDef(adt) => Some(adt.into()), 175 TypableDef::Adt(adt) => Some(adt.into()),
176 TypableDef::EnumVariant(var) => Some(var.parent_enum(db).into()), 176 TypableDef::EnumVariant(var) => Some(var.parent_enum(db).into()),
177 TypableDef::TypeAlias(t) => Some(t.into()), 177 TypableDef::TypeAlias(t) => Some(t.into()),
178 TypableDef::Const(_) | TypableDef::Static(_) | TypableDef::BuiltinType(_) => None, 178 TypableDef::Const(_) | TypableDef::Static(_) | TypableDef::BuiltinType(_) => None,
@@ -191,7 +191,7 @@ impl Ty {
191 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");
192 let segment = match resolved { 192 let segment = match resolved {
193 TypableDef::Function(_) 193 TypableDef::Function(_)
194 | TypableDef::AdtDef(_) 194 | TypableDef::Adt(_)
195 | TypableDef::Const(_) 195 | TypableDef::Const(_)
196 | TypableDef::Static(_) 196 | TypableDef::Static(_)
197 | TypableDef::TypeAlias(_) 197 | TypableDef::TypeAlias(_)
@@ -406,10 +406,8 @@ fn assoc_type_bindings_from_type_bound<'a>(
406pub(crate) fn type_for_def(db: &impl HirDatabase, def: TypableDef, ns: Namespace) -> Ty { 406pub(crate) fn type_for_def(db: &impl HirDatabase, def: TypableDef, ns: Namespace) -> Ty {
407 match (def, ns) { 407 match (def, ns) {
408 (TypableDef::Function(f), Namespace::Values) => type_for_fn(db, f), 408 (TypableDef::Function(f), Namespace::Values) => type_for_fn(db, f),
409 (TypableDef::AdtDef(AdtDef::Struct(s)), Namespace::Values) => { 409 (TypableDef::Adt(Adt::Struct(s)), Namespace::Values) => type_for_struct_constructor(db, s),
410 type_for_struct_constructor(db, s) 410 (TypableDef::Adt(adt), Namespace::Types) => type_for_adt(db, adt),
411 }
412 (TypableDef::AdtDef(adt), Namespace::Types) => type_for_adt(db, adt),
413 (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),
414 (TypableDef::TypeAlias(t), Namespace::Types) => type_for_type_alias(db, t), 412 (TypableDef::TypeAlias(t), Namespace::Types) => type_for_type_alias(db, t),
415 (TypableDef::Const(c), Namespace::Values) => type_for_const(db, c), 413 (TypableDef::Const(c), Namespace::Values) => type_for_const(db, c),
@@ -418,8 +416,8 @@ pub(crate) fn type_for_def(db: &impl HirDatabase, def: TypableDef, ns: Namespace
418 416
419 // 'error' cases: 417 // 'error' cases:
420 (TypableDef::Function(_), Namespace::Types) => Ty::Unknown, 418 (TypableDef::Function(_), Namespace::Types) => Ty::Unknown,
421 (TypableDef::AdtDef(AdtDef::Union(_)), Namespace::Values) => Ty::Unknown, 419 (TypableDef::Adt(Adt::Union(_)), Namespace::Values) => Ty::Unknown,
422 (TypableDef::AdtDef(AdtDef::Enum(_)), Namespace::Values) => Ty::Unknown, 420 (TypableDef::Adt(Adt::Enum(_)), Namespace::Values) => Ty::Unknown,
423 (TypableDef::EnumVariant(_), Namespace::Types) => Ty::Unknown, 421 (TypableDef::EnumVariant(_), Namespace::Types) => Ty::Unknown,
424 (TypableDef::TypeAlias(_), Namespace::Values) => Ty::Unknown, 422 (TypableDef::TypeAlias(_), Namespace::Values) => Ty::Unknown,
425 (TypableDef::Const(_), Namespace::Types) => Ty::Unknown, 423 (TypableDef::Const(_), Namespace::Types) => Ty::Unknown,
@@ -587,7 +585,7 @@ fn type_for_enum_variant_constructor(db: &impl HirDatabase, def: EnumVariant) ->
587 Ty::apply(TypeCtor::FnDef(def.into()), substs) 585 Ty::apply(TypeCtor::FnDef(def.into()), substs)
588} 586}
589 587
590fn type_for_adt(db: &impl HirDatabase, adt: impl Into<AdtDef> + HasGenericParams) -> Ty { 588fn type_for_adt(db: &impl HirDatabase, adt: impl Into<Adt> + HasGenericParams) -> Ty {
591 let generics = adt.generic_params(db); 589 let generics = adt.generic_params(db);
592 Ty::apply(TypeCtor::Adt(adt.into()), Substs::identity(&generics)) 590 Ty::apply(TypeCtor::Adt(adt.into()), Substs::identity(&generics))
593} 591}
@@ -604,7 +602,7 @@ fn type_for_type_alias(db: &impl HirDatabase, t: TypeAlias) -> Ty {
604#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] 602#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
605pub enum TypableDef { 603pub enum TypableDef {
606 Function(Function), 604 Function(Function),
607 AdtDef(AdtDef), 605 Adt(Adt),
608 EnumVariant(EnumVariant), 606 EnumVariant(EnumVariant),
609 TypeAlias(TypeAlias), 607 TypeAlias(TypeAlias),
610 Const(Const), 608 Const(Const),
@@ -613,7 +611,7 @@ pub enum TypableDef {
613} 611}
614impl_froms!( 612impl_froms!(
615 TypableDef: Function, 613 TypableDef: Function,
616 AdtDef(Struct, Enum, Union), 614 Adt(Struct, Enum, Union),
617 EnumVariant, 615 EnumVariant,
618 TypeAlias, 616 TypeAlias,
619 Const, 617 Const,
@@ -625,7 +623,7 @@ impl From<ModuleDef> for Option<TypableDef> {
625 fn from(def: ModuleDef) -> Option<TypableDef> { 623 fn from(def: ModuleDef) -> Option<TypableDef> {
626 let res = match def { 624 let res = match def {
627 ModuleDef::Function(f) => f.into(), 625 ModuleDef::Function(f) => f.into(),
628 ModuleDef::AdtDef(adt) => adt.into(), 626 ModuleDef::Adt(adt) => adt.into(),
629 ModuleDef::EnumVariant(v) => v.into(), 627 ModuleDef::EnumVariant(v) => v.into(),
630 ModuleDef::TypeAlias(t) => t.into(), 628 ModuleDef::TypeAlias(t) => t.into(),
631 ModuleDef::Const(v) => v.into(), 629 ModuleDef::Const(v) => v.into(),