aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/code_model.rs4
-rw-r--r--crates/ra_hir/src/lib.rs2
-rw-r--r--crates/ra_hir/src/source_binder.rs60
3 files changed, 34 insertions, 32 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index c705d1630..7850ea9a7 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -17,7 +17,7 @@ use hir_def::{
17}; 17};
18use hir_expand::{ 18use hir_expand::{
19 diagnostics::DiagnosticSink, 19 diagnostics::DiagnosticSink,
20 name::{self, AsName}, 20 name::{name, AsName},
21 MacroDefId, 21 MacroDefId,
22}; 22};
23use hir_ty::{ 23use hir_ty::{
@@ -723,7 +723,7 @@ impl Local {
723 } 723 }
724 724
725 pub fn is_self(self, db: &impl HirDatabase) -> bool { 725 pub fn is_self(self, db: &impl HirDatabase) -> bool {
726 self.name(db) == Some(name::SELF_PARAM) 726 self.name(db) == Some(name![self])
727 } 727 }
728 728
729 pub fn is_mut(self, db: &impl HirDatabase) -> bool { 729 pub fn is_mut(self, db: &impl HirDatabase) -> bool {
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs
index 8b9562722..2e52a1f5c 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 d3cc5c423..d326169b3 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -15,7 +15,7 @@ use hir_def::{
15 }, 15 },
16 expr::{ExprId, PatId}, 16 expr::{ExprId, PatId},
17 nameres::ModuleSource, 17 nameres::ModuleSource,
18 path::known, 18 path::path,
19 resolver::{self, resolver_for_scope, HasResolver, Resolver, TypeNs, ValueNs}, 19 resolver::{self, resolver_for_scope, HasResolver, Resolver, TypeNs, ValueNs},
20 AssocItemId, DefWithBodyId, 20 AssocItemId, DefWithBodyId,
21}; 21};
@@ -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 }
@@ -418,7 +420,7 @@ impl SourceAnalyzer {
418 /// Checks that particular type `ty` implements `std::future::Future`. 420 /// Checks that particular type `ty` implements `std::future::Future`.
419 /// This function is used in `.await` syntax completion. 421 /// This function is used in `.await` syntax completion.
420 pub fn impls_future(&self, db: &impl HirDatabase, ty: Type) -> bool { 422 pub fn impls_future(&self, db: &impl HirDatabase, ty: Type) -> bool {
421 let std_future_path = known::std_future_future(); 423 let std_future_path = path![std::future::Future];
422 424
423 let std_future_trait = match self.resolver.resolve_known_trait(db, &std_future_path) { 425 let std_future_trait = match self.resolver.resolve_known_trait(db, &std_future_path) {
424 Some(it) => it.into(), 426 Some(it) => it.into(),