aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/nameres
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/nameres')
-rw-r--r--crates/ra_hir/src/nameres/collector.rs6
-rw-r--r--crates/ra_hir/src/nameres/per_ns.rs30
2 files changed, 18 insertions, 18 deletions
diff --git a/crates/ra_hir/src/nameres/collector.rs b/crates/ra_hir/src/nameres/collector.rs
index 7d2f313c1..1446c49a0 100644
--- a/crates/ra_hir/src/nameres/collector.rs
+++ b/crates/ra_hir/src/nameres/collector.rs
@@ -243,7 +243,7 @@ where
243 &self, 243 &self,
244 module_id: CrateModuleId, 244 module_id: CrateModuleId,
245 import: &raw::ImportData, 245 import: &raw::ImportData,
246 ) -> (PerNs<ModuleDef>, ReachedFixedPoint) { 246 ) -> (PerNs, ReachedFixedPoint) {
247 log::debug!("resolving import: {:?} ({:?})", import, self.def_map.edition); 247 log::debug!("resolving import: {:?} ({:?})", import, self.def_map.edition);
248 if import.is_extern_crate { 248 if import.is_extern_crate {
249 let res = self.def_map.resolve_name_in_extern_prelude( 249 let res = self.def_map.resolve_name_in_extern_prelude(
@@ -268,7 +268,7 @@ where
268 fn record_resolved_import( 268 fn record_resolved_import(
269 &mut self, 269 &mut self,
270 module_id: CrateModuleId, 270 module_id: CrateModuleId,
271 def: PerNs<ModuleDef>, 271 def: PerNs,
272 import_id: raw::ImportId, 272 import_id: raw::ImportId,
273 import: &raw::ImportData, 273 import: &raw::ImportData,
274 ) { 274 ) {
@@ -662,7 +662,7 @@ where
662 }; 662 };
663 } 663 }
664 let name = def.name.clone(); 664 let name = def.name.clone();
665 let def: PerNs<ModuleDef> = match def.kind { 665 let def: PerNs = match def.kind {
666 raw::DefKind::Function(ast_id) => PerNs::values(def!(Function, ast_id)), 666 raw::DefKind::Function(ast_id) => PerNs::values(def!(Function, ast_id)),
667 raw::DefKind::Struct(ast_id) => { 667 raw::DefKind::Struct(ast_id) => {
668 let s = def!(Struct, ast_id); 668 let s = def!(Struct, ast_id);
diff --git a/crates/ra_hir/src/nameres/per_ns.rs b/crates/ra_hir/src/nameres/per_ns.rs
index b0f4dff33..964da2794 100644
--- a/crates/ra_hir/src/nameres/per_ns.rs
+++ b/crates/ra_hir/src/nameres/per_ns.rs
@@ -1,4 +1,4 @@
1use crate::MacroDef; 1use crate::{MacroDef, ModuleDef};
2 2
3#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 3#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
4pub enum Namespace { 4pub enum Namespace {
@@ -9,38 +9,38 @@ pub enum Namespace {
9} 9}
10 10
11#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] 11#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
12pub struct PerNs<T> { 12pub struct PerNs {
13 pub types: Option<T>, 13 pub types: Option<ModuleDef>,
14 pub values: Option<T>, 14 pub values: Option<ModuleDef>,
15 /// Since macros has different type, many methods simply ignore it. 15 /// Since macros has different type, many methods simply ignore it.
16 /// We can only use special method like `get_macros` to access it. 16 /// We can only use special method like `get_macros` to access it.
17 pub macros: Option<MacroDef>, 17 pub macros: Option<MacroDef>,
18} 18}
19 19
20impl<T> Default for PerNs<T> { 20impl Default for PerNs {
21 fn default() -> Self { 21 fn default() -> Self {
22 PerNs { types: None, values: None, macros: None } 22 PerNs { types: None, values: None, macros: None }
23 } 23 }
24} 24}
25 25
26impl<T> PerNs<T> { 26impl PerNs {
27 pub fn none() -> PerNs<T> { 27 pub fn none() -> PerNs {
28 PerNs { types: None, values: None, macros: None } 28 PerNs { types: None, values: None, macros: None }
29 } 29 }
30 30
31 pub fn values(t: T) -> PerNs<T> { 31 pub fn values(t: ModuleDef) -> PerNs {
32 PerNs { types: None, values: Some(t), macros: None } 32 PerNs { types: None, values: Some(t), macros: None }
33 } 33 }
34 34
35 pub fn types(t: T) -> PerNs<T> { 35 pub fn types(t: ModuleDef) -> PerNs {
36 PerNs { types: Some(t), values: None, macros: None } 36 PerNs { types: Some(t), values: None, macros: None }
37 } 37 }
38 38
39 pub fn both(types: T, values: T) -> PerNs<T> { 39 pub fn both(types: ModuleDef, values: ModuleDef) -> PerNs {
40 PerNs { types: Some(types), values: Some(values), macros: None } 40 PerNs { types: Some(types), values: Some(values), macros: None }
41 } 41 }
42 42
43 pub fn macros(macro_: MacroDef) -> PerNs<T> { 43 pub fn macros(macro_: MacroDef) -> PerNs {
44 PerNs { types: None, values: None, macros: Some(macro_) } 44 PerNs { types: None, values: None, macros: Some(macro_) }
45 } 45 }
46 46
@@ -52,11 +52,11 @@ impl<T> PerNs<T> {
52 self.types.is_some() && self.values.is_some() && self.macros.is_some() 52 self.types.is_some() && self.values.is_some() && self.macros.is_some()
53 } 53 }
54 54
55 pub fn take_types(self) -> Option<T> { 55 pub fn take_types(self) -> Option<ModuleDef> {
56 self.types 56 self.types
57 } 57 }
58 58
59 pub fn take_values(self) -> Option<T> { 59 pub fn take_values(self) -> Option<ModuleDef> {
60 self.values 60 self.values
61 } 61 }
62 62
@@ -64,11 +64,11 @@ impl<T> PerNs<T> {
64 self.macros 64 self.macros
65 } 65 }
66 66
67 pub fn only_macros(&self) -> PerNs<T> { 67 pub fn only_macros(&self) -> PerNs {
68 PerNs { types: None, values: None, macros: self.macros } 68 PerNs { types: None, values: None, macros: self.macros }
69 } 69 }
70 70
71 pub fn or(self, other: PerNs<T>) -> PerNs<T> { 71 pub fn or(self, other: PerNs) -> PerNs {
72 PerNs { 72 PerNs {
73 types: self.types.or(other.types), 73 types: self.types.or(other.types),
74 values: self.values.or(other.values), 74 values: self.values.or(other.values),