aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-24 20:39:39 +0000
committerAleksey Kladov <[email protected]>2019-01-24 20:39:39 +0000
commitf3a37522a027a10c257f4dfdc2369e7853e0c80e (patch)
tree392414cbc9a4ecbcf7a597f43d489e97fc568a6a /crates/ra_hir/src
parent6a5a1f590201ba962a1f77ce1a7ff5870712728d (diff)
removed untyped typabledef
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/ty.rs29
1 files changed, 3 insertions, 26 deletions
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs
index 66cf2bd64..9a1a90eed 100644
--- a/crates/ra_hir/src/ty.rs
+++ b/crates/ra_hir/src/ty.rs
@@ -24,14 +24,13 @@ use std::ops::Index;
24use std::sync::Arc; 24use std::sync::Arc;
25use std::{fmt, mem}; 25use std::{fmt, mem};
26 26
27use log;
28use ena::unify::{InPlaceUnificationTable, UnifyKey, UnifyValue, NoError}; 27use ena::unify::{InPlaceUnificationTable, UnifyKey, UnifyValue, NoError};
29use ra_arena::map::ArenaMap; 28use ra_arena::map::ArenaMap;
30use join_to_string::join; 29use join_to_string::join;
31use rustc_hash::FxHashMap; 30use rustc_hash::FxHashMap;
32 31
33use crate::{ 32use crate::{
34 Def, DefId, Module, Function, Struct, StructField, Enum, EnumVariant, Path, Name, ImplBlock, 33 Module, Function, Struct, StructField, Enum, EnumVariant, Path, Name, ImplBlock,
35 FnSignature, FnScopes, ModuleDef, Crate, 34 FnSignature, FnScopes, ModuleDef, Crate,
36 db::HirDatabase, 35 db::HirDatabase,
37 type_ref::{TypeRef, Mutability}, 36 type_ref::{TypeRef, Mutability},
@@ -447,10 +446,6 @@ impl Ty {
447 }; 446 };
448 (var.parent_enum(db).generic_params(db), segment) 447 (var.parent_enum(db).generic_params(db), segment)
449 } 448 }
450 TypableDef::Def(def_id) => match def_id.resolve(db) {
451 Def::Trait(t) => (t.generic_params(db), last),
452 _ => return Substs::empty(),
453 },
454 }; 449 };
455 // substs_from_path 450 // substs_from_path
456 if let Some(generic_args) = &segment.args_and_bindings { 451 if let Some(generic_args) = &segment.args_and_bindings {
@@ -688,25 +683,17 @@ pub enum TypableDef {
688 Struct(Struct), 683 Struct(Struct),
689 Enum(Enum), 684 Enum(Enum),
690 EnumVariant(EnumVariant), 685 EnumVariant(EnumVariant),
691 Def(DefId),
692} 686}
693impl_froms!(TypableDef: Function, Struct, Enum, EnumVariant); 687impl_froms!(TypableDef: Function, Struct, Enum, EnumVariant);
694 688
695impl From<DefId> for TypableDef {
696 fn from(func: DefId) -> TypableDef {
697 TypableDef::Def(func)
698 }
699}
700
701impl From<ModuleDef> for Option<TypableDef> { 689impl From<ModuleDef> for Option<TypableDef> {
702 fn from(def: ModuleDef) -> Option<TypableDef> { 690 fn from(def: ModuleDef) -> Option<TypableDef> {
703 let res = match def { 691 let res = match def {
704 ModuleDef::Def(r) => r.into(),
705 ModuleDef::Function(f) => f.into(), 692 ModuleDef::Function(f) => f.into(),
706 ModuleDef::Struct(s) => s.into(), 693 ModuleDef::Struct(s) => s.into(),
707 ModuleDef::Enum(e) => e.into(), 694 ModuleDef::Enum(e) => e.into(),
708 ModuleDef::EnumVariant(v) => v.into(), 695 ModuleDef::EnumVariant(v) => v.into(),
709 ModuleDef::Module(_) => return None, 696 ModuleDef::Def(_) | ModuleDef::Module(_) => return None,
710 }; 697 };
711 Some(res) 698 Some(res)
712 } 699 }
@@ -718,14 +705,6 @@ pub(super) fn type_for_def(db: &impl HirDatabase, def: TypableDef) -> Ty {
718 TypableDef::Struct(s) => type_for_struct(db, s), 705 TypableDef::Struct(s) => type_for_struct(db, s),
719 TypableDef::Enum(e) => type_for_enum(db, e), 706 TypableDef::Enum(e) => type_for_enum(db, e),
720 TypableDef::EnumVariant(v) => type_for_enum_variant(db, v), 707 TypableDef::EnumVariant(v) => type_for_enum_variant(db, v),
721 TypableDef::Def(def_id) => {
722 log::debug!(
723 "trying to get type for item of unknown type {:?} {:?}",
724 def_id,
725 def
726 );
727 Ty::Unknown
728 }
729 } 708 }
730} 709}
731 710
@@ -1152,9 +1131,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
1152 let ty = self.insert_type_vars(ty.apply_substs(substs)); 1131 let ty = self.insert_type_vars(ty.apply_substs(substs));
1153 (ty, Some(var.into())) 1132 (ty, Some(var.into()))
1154 } 1133 }
1155 TypableDef::Def(_) | TypableDef::Enum(_) | TypableDef::Function(_) => { 1134 TypableDef::Enum(_) | TypableDef::Function(_) => (Ty::Unknown, None),
1156 (Ty::Unknown, None)
1157 }
1158 } 1135 }
1159 } 1136 }
1160 1137