diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-09-13 14:40:48 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2019-09-13 14:40:48 +0100 |
commit | b8c16ec002d48f4fb9d883d091114ccd1286ba47 (patch) | |
tree | 5fa82899fc15f5739ef80997c04fd9cc8153e786 /crates/ra_hir/src/nameres | |
parent | b31f9872ec67d371d669967f9c95f2d71a9d6bf5 (diff) | |
parent | 7be7f67198c617ad482717d9bf2c7dca9c2cd169 (diff) |
Merge #1838
1838: rename add_resolution -> add_scope_def r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/nameres')
-rw-r--r-- | crates/ra_hir/src/nameres/collector.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir/src/nameres/per_ns.rs | 30 |
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 @@ | |||
1 | use crate::MacroDef; | 1 | use 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)] |
4 | pub enum Namespace { | 4 | pub 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)] |
12 | pub struct PerNs<T> { | 12 | pub 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 | ||
20 | impl<T> Default for PerNs<T> { | 20 | impl 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 | ||
26 | impl<T> PerNs<T> { | 26 | impl 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), |