aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/resolver.rs
diff options
context:
space:
mode:
authorSeivan Heidari <[email protected]>2019-11-28 07:19:14 +0000
committerSeivan Heidari <[email protected]>2019-11-28 07:19:14 +0000
commit18a0937585b836ec5ed054b9ae48e0156ab6d9ef (patch)
tree9de2c0267ddcc00df717f90034d0843d751a851b /crates/ra_hir_def/src/resolver.rs
parenta7394b44c870f585eacfeb3036a33471aff49ff8 (diff)
parent484acc8a61d599662ed63a4cbda091d38a982551 (diff)
Merge branch 'master' of https://github.com/rust-analyzer/rust-analyzer into feature/themes
Diffstat (limited to 'crates/ra_hir_def/src/resolver.rs')
-rw-r--r--crates/ra_hir_def/src/resolver.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/crates/ra_hir_def/src/resolver.rs b/crates/ra_hir_def/src/resolver.rs
index 95b3c926d..0847f6dcf 100644
--- a/crates/ra_hir_def/src/resolver.rs
+++ b/crates/ra_hir_def/src/resolver.rs
@@ -61,6 +61,8 @@ pub enum TypeNs {
61 GenericParam(u32), 61 GenericParam(u32),
62 AdtId(AdtId), 62 AdtId(AdtId),
63 AdtSelfType(AdtId), 63 AdtSelfType(AdtId),
64 // Yup, enum variants are added to the types ns, but any usage of variant as
65 // type is an error.
64 EnumVariantId(EnumVariantId), 66 EnumVariantId(EnumVariantId),
65 TypeAliasId(TypeAliasId), 67 TypeAliasId(TypeAliasId),
66 BuiltinType(BuiltinType), 68 BuiltinType(BuiltinType),
@@ -323,7 +325,7 @@ impl Resolver {
323 if let Scope::ModuleScope(m) = scope { 325 if let Scope::ModuleScope(m) = scope {
324 if let Some(prelude) = m.crate_def_map.prelude { 326 if let Some(prelude) = m.crate_def_map.prelude {
325 let prelude_def_map = db.crate_def_map(prelude.krate); 327 let prelude_def_map = db.crate_def_map(prelude.krate);
326 traits.extend(prelude_def_map[prelude.module_id].scope.traits()); 328 traits.extend(prelude_def_map[prelude.local_id].scope.traits());
327 } 329 }
328 traits.extend(m.crate_def_map[m.module_id].scope.traits()); 330 traits.extend(m.crate_def_map[m.module_id].scope.traits());
329 } 331 }
@@ -400,7 +402,7 @@ impl Scope {
400 }); 402 });
401 if let Some(prelude) = m.crate_def_map.prelude { 403 if let Some(prelude) = m.crate_def_map.prelude {
402 let prelude_def_map = db.crate_def_map(prelude.krate); 404 let prelude_def_map = db.crate_def_map(prelude.krate);
403 prelude_def_map[prelude.module_id].scope.entries().for_each(|(name, res)| { 405 prelude_def_map[prelude.local_id].scope.entries().for_each(|(name, res)| {
404 f(name.clone(), ScopeDef::PerNs(res.def)); 406 f(name.clone(), ScopeDef::PerNs(res.def));
405 }); 407 });
406 } 408 }
@@ -482,7 +484,7 @@ impl Resolver {
482 } 484 }
483} 485}
484 486
485pub trait HasResolver { 487pub trait HasResolver: Copy {
486 /// Builds a resolver for type references inside this def. 488 /// Builds a resolver for type references inside this def.
487 fn resolver(self, db: &impl DefDatabase) -> Resolver; 489 fn resolver(self, db: &impl DefDatabase) -> Resolver;
488} 490}
@@ -490,7 +492,7 @@ pub trait HasResolver {
490impl HasResolver for ModuleId { 492impl HasResolver for ModuleId {
491 fn resolver(self, db: &impl DefDatabase) -> Resolver { 493 fn resolver(self, db: &impl DefDatabase) -> Resolver {
492 let def_map = db.crate_def_map(self.krate); 494 let def_map = db.crate_def_map(self.krate);
493 Resolver::default().push_module_scope(def_map, self.module_id) 495 Resolver::default().push_module_scope(def_map, self.local_id)
494 } 496 }
495} 497}
496 498
@@ -500,7 +502,7 @@ impl HasResolver for TraitId {
500 } 502 }
501} 503}
502 504
503impl<T: Into<AdtId>> HasResolver for T { 505impl<T: Into<AdtId> + Copy> HasResolver for T {
504 fn resolver(self, db: &impl DefDatabase) -> Resolver { 506 fn resolver(self, db: &impl DefDatabase) -> Resolver {
505 let def = self.into(); 507 let def = self.into();
506 def.module(db) 508 def.module(db)