diff options
Diffstat (limited to 'crates/ra_hir/src/ty.rs')
-rw-r--r-- | crates/ra_hir/src/ty.rs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index e690ae158..4c96579ee 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs | |||
@@ -32,7 +32,7 @@ use rustc_hash::FxHashMap; | |||
32 | 32 | ||
33 | use crate::{ | 33 | use crate::{ |
34 | Def, DefId, Module, Function, Struct, StructField, Enum, EnumVariant, Path, Name, ImplBlock, | 34 | Def, DefId, Module, Function, Struct, StructField, Enum, EnumVariant, Path, Name, ImplBlock, |
35 | FnSignature, FnScopes, | 35 | FnSignature, FnScopes, ModuleDef, |
36 | db::HirDatabase, | 36 | db::HirDatabase, |
37 | type_ref::{TypeRef, Mutability}, | 37 | type_ref::{TypeRef, Mutability}, |
38 | name::KnownName, | 38 | name::KnownName, |
@@ -382,8 +382,8 @@ impl Ty { | |||
382 | 382 | ||
383 | // Resolve in module (in type namespace) | 383 | // Resolve in module (in type namespace) |
384 | let resolved = match module.resolve_path(db, path).take_types() { | 384 | let resolved = match module.resolve_path(db, path).take_types() { |
385 | Some(r) => r, | 385 | Some(ModuleDef::Def(r)) => r, |
386 | None => return Ty::Unknown, | 386 | None | Some(ModuleDef::Module(_)) => return Ty::Unknown, |
387 | }; | 387 | }; |
388 | let ty = db.type_for_def(resolved); | 388 | let ty = db.type_for_def(resolved); |
389 | let substs = Ty::substs_from_path(db, module, impl_block, generics, path, resolved); | 389 | let substs = Ty::substs_from_path(db, module, impl_block, generics, path, resolved); |
@@ -663,10 +663,6 @@ pub(crate) fn type_for_enum_variant(db: &impl HirDatabase, ev: EnumVariant) -> T | |||
663 | pub(super) fn type_for_def(db: &impl HirDatabase, def_id: DefId) -> Ty { | 663 | pub(super) fn type_for_def(db: &impl HirDatabase, def_id: DefId) -> Ty { |
664 | let def = def_id.resolve(db); | 664 | let def = def_id.resolve(db); |
665 | match def { | 665 | match def { |
666 | Def::Module(..) => { | ||
667 | log::debug!("trying to get type for module {:?}", def_id); | ||
668 | Ty::Unknown | ||
669 | } | ||
670 | Def::Function(f) => type_for_fn(db, f), | 666 | Def::Function(f) => type_for_fn(db, f), |
671 | Def::Struct(s) => type_for_struct(db, s), | 667 | Def::Struct(s) => type_for_struct(db, s), |
672 | Def::Enum(e) => type_for_enum(db, e), | 668 | Def::Enum(e) => type_for_enum(db, e), |
@@ -1063,7 +1059,10 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
1063 | }; | 1059 | }; |
1064 | 1060 | ||
1065 | // resolve in module | 1061 | // resolve in module |
1066 | let resolved = self.module.resolve_path(self.db, &path).take_values()?; | 1062 | let resolved = match self.module.resolve_path(self.db, &path).take_values()? { |
1063 | ModuleDef::Def(it) => it, | ||
1064 | ModuleDef::Module(_) => return None, | ||
1065 | }; | ||
1067 | let ty = self.db.type_for_def(resolved); | 1066 | let ty = self.db.type_for_def(resolved); |
1068 | let ty = self.insert_type_vars(ty); | 1067 | let ty = self.insert_type_vars(ty); |
1069 | Some(ty) | 1068 | Some(ty) |
@@ -1075,7 +1074,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
1075 | None => return (Ty::Unknown, None), | 1074 | None => return (Ty::Unknown, None), |
1076 | }; | 1075 | }; |
1077 | let def_id = match self.module.resolve_path(self.db, &path).take_types() { | 1076 | let def_id = match self.module.resolve_path(self.db, &path).take_types() { |
1078 | Some(def_id) => def_id, | 1077 | Some(ModuleDef::Def(def_id)) => def_id, |
1079 | _ => return (Ty::Unknown, None), | 1078 | _ => return (Ty::Unknown, None), |
1080 | }; | 1079 | }; |
1081 | // TODO remove the duplication between here and `Ty::from_path`? | 1080 | // TODO remove the duplication between here and `Ty::from_path`? |
@@ -1216,6 +1215,10 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
1216 | .module | 1215 | .module |
1217 | .resolve_path(self.db, &path) | 1216 | .resolve_path(self.db, &path) |
1218 | .take_values() | 1217 | .take_values() |
1218 | .and_then(|module_def| match module_def { | ||
1219 | ModuleDef::Def(it) => Some(it), | ||
1220 | ModuleDef::Module(_) => None, | ||
1221 | }) | ||
1219 | .map_or(Ty::Unknown, |resolved| self.db.type_for_def(resolved)), | 1222 | .map_or(Ty::Unknown, |resolved| self.db.type_for_def(resolved)), |
1220 | Pat::Bind { | 1223 | Pat::Bind { |
1221 | mode, | 1224 | mode, |