aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/lib.rs2
-rw-r--r--crates/ra_hir/src/source_binder.rs56
2 files changed, 30 insertions, 28 deletions
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs
index e7602ee30..451b227a6 100644
--- a/crates/ra_hir/src/lib.rs
+++ b/crates/ra_hir/src/lib.rs
@@ -54,7 +54,7 @@ pub use hir_def::{
54 builtin_type::BuiltinType, 54 builtin_type::BuiltinType,
55 docs::Documentation, 55 docs::Documentation,
56 nameres::ModuleSource, 56 nameres::ModuleSource,
57 path::{Path, PathKind}, 57 path::{ModPath, Path, PathKind},
58 type_ref::Mutability, 58 type_ref::Mutability,
59}; 59};
60pub use hir_expand::{ 60pub use hir_expand::{
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs
index f82242c3a..d326169b3 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -258,7 +258,7 @@ impl SourceAnalyzer {
258 ) -> Option<MacroDef> { 258 ) -> Option<MacroDef> {
259 let hygiene = Hygiene::new(db, macro_call.file_id); 259 let hygiene = Hygiene::new(db, macro_call.file_id);
260 let path = macro_call.value.path().and_then(|ast| Path::from_src(ast, &hygiene))?; 260 let path = macro_call.value.path().and_then(|ast| Path::from_src(ast, &hygiene))?;
261 self.resolver.resolve_path_as_macro(db, &path).map(|it| it.into()) 261 self.resolver.resolve_path_as_macro(db, path.mod_path()).map(|it| it.into())
262 } 262 }
263 263
264 pub fn resolve_hir_path( 264 pub fn resolve_hir_path(
@@ -266,40 +266,42 @@ impl SourceAnalyzer {
266 db: &impl HirDatabase, 266 db: &impl HirDatabase,
267 path: &crate::Path, 267 path: &crate::Path,
268 ) -> Option<PathResolution> { 268 ) -> Option<PathResolution> {
269 let types = self.resolver.resolve_path_in_type_ns_fully(db, &path).map(|ty| match ty { 269 let types =
270 TypeNs::SelfType(it) => PathResolution::SelfType(it.into()), 270 self.resolver.resolve_path_in_type_ns_fully(db, path.mod_path()).map(|ty| match ty {
271 TypeNs::GenericParam(id) => PathResolution::TypeParam(TypeParam { id }), 271 TypeNs::SelfType(it) => PathResolution::SelfType(it.into()),
272 TypeNs::AdtSelfType(it) | TypeNs::AdtId(it) => { 272 TypeNs::GenericParam(id) => PathResolution::TypeParam(TypeParam { id }),
273 PathResolution::Def(Adt::from(it).into()) 273 TypeNs::AdtSelfType(it) | TypeNs::AdtId(it) => {
274 } 274 PathResolution::Def(Adt::from(it).into())
275 TypeNs::EnumVariantId(it) => PathResolution::Def(EnumVariant::from(it).into()),
276 TypeNs::TypeAliasId(it) => PathResolution::Def(TypeAlias::from(it).into()),
277 TypeNs::BuiltinType(it) => PathResolution::Def(it.into()),
278 TypeNs::TraitId(it) => PathResolution::Def(Trait::from(it).into()),
279 });
280 let values = self.resolver.resolve_path_in_value_ns_fully(db, &path).and_then(|val| {
281 let res = match val {
282 ValueNs::LocalBinding(pat_id) => {
283 let var = Local { parent: self.body_owner?, pat_id };
284 PathResolution::Local(var)
285 } 275 }
286 ValueNs::FunctionId(it) => PathResolution::Def(Function::from(it).into()), 276 TypeNs::EnumVariantId(it) => PathResolution::Def(EnumVariant::from(it).into()),
287 ValueNs::ConstId(it) => PathResolution::Def(Const::from(it).into()), 277 TypeNs::TypeAliasId(it) => PathResolution::Def(TypeAlias::from(it).into()),
288 ValueNs::StaticId(it) => PathResolution::Def(Static::from(it).into()), 278 TypeNs::BuiltinType(it) => PathResolution::Def(it.into()),
289 ValueNs::StructId(it) => PathResolution::Def(Struct::from(it).into()), 279 TypeNs::TraitId(it) => PathResolution::Def(Trait::from(it).into()),
290 ValueNs::EnumVariantId(it) => PathResolution::Def(EnumVariant::from(it).into()), 280 });
291 }; 281 let values =
292 Some(res) 282 self.resolver.resolve_path_in_value_ns_fully(db, path.mod_path()).and_then(|val| {
293 }); 283 let res = match val {
284 ValueNs::LocalBinding(pat_id) => {
285 let var = Local { parent: self.body_owner?, pat_id };
286 PathResolution::Local(var)
287 }
288 ValueNs::FunctionId(it) => PathResolution::Def(Function::from(it).into()),
289 ValueNs::ConstId(it) => PathResolution::Def(Const::from(it).into()),
290 ValueNs::StaticId(it) => PathResolution::Def(Static::from(it).into()),
291 ValueNs::StructId(it) => PathResolution::Def(Struct::from(it).into()),
292 ValueNs::EnumVariantId(it) => PathResolution::Def(EnumVariant::from(it).into()),
293 };
294 Some(res)
295 });
294 296
295 let items = self 297 let items = self
296 .resolver 298 .resolver
297 .resolve_module_path_in_items(db, &path) 299 .resolve_module_path_in_items(db, path.mod_path())
298 .take_types() 300 .take_types()
299 .map(|it| PathResolution::Def(it.into())); 301 .map(|it| PathResolution::Def(it.into()));
300 types.or(values).or(items).or_else(|| { 302 types.or(values).or(items).or_else(|| {
301 self.resolver 303 self.resolver
302 .resolve_path_as_macro(db, &path) 304 .resolve_path_as_macro(db, path.mod_path())
303 .map(|def| PathResolution::Macro(def.into())) 305 .map(|def| PathResolution::Macro(def.into()))
304 }) 306 })
305 } 307 }