aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-12-21 16:22:48 +0000
committerAleksey Kladov <[email protected]>2019-12-21 16:26:28 +0000
commitec56f59ac17ad5ae797ce431883be8f31e795d1b (patch)
tree82cfed150ad966674e6291010b9b976239351a42
parent6d8a2ec3dd350541d7c0e5aa08795a42c4dbd8f8 (diff)
Remove import from resolution
-rw-r--r--crates/ra_hir_def/src/item_scope.rs19
-rw-r--r--crates/ra_hir_def/src/nameres/collector.rs10
2 files changed, 12 insertions, 17 deletions
diff --git a/crates/ra_hir_def/src/item_scope.rs b/crates/ra_hir_def/src/item_scope.rs
index ad104bb3d..8b70e13c4 100644
--- a/crates/ra_hir_def/src/item_scope.rs
+++ b/crates/ra_hir_def/src/item_scope.rs
@@ -30,7 +30,7 @@ static BUILTIN_SCOPE: Lazy<FxHashMap<Name, Resolution>> = Lazy::new(|| {
30 BuiltinType::ALL 30 BuiltinType::ALL
31 .iter() 31 .iter()
32 .map(|(name, ty)| { 32 .map(|(name, ty)| {
33 (name.clone(), Resolution { def: PerNs::types(ty.clone().into()), import: None }) 33 (name.clone(), Resolution { def: PerNs::types(ty.clone().into()), import: false })
34 }) 34 })
35 .collect() 35 .collect()
36}); 36});
@@ -54,7 +54,7 @@ impl ItemScope {
54 54
55 pub fn declarations(&self) -> impl Iterator<Item = ModuleDefId> + '_ { 55 pub fn declarations(&self) -> impl Iterator<Item = ModuleDefId> + '_ {
56 self.entries() 56 self.entries()
57 .filter_map(|(_name, res)| if res.import.is_none() { Some(res.def) } else { None }) 57 .filter_map(|(_name, res)| if !res.import { Some(res.def) } else { None })
58 .flat_map(|per_ns| { 58 .flat_map(|per_ns| {
59 per_ns.take_types().into_iter().chain(per_ns.take_values().into_iter()) 59 per_ns.take_types().into_iter().chain(per_ns.take_values().into_iter())
60 }) 60 })
@@ -123,25 +123,21 @@ impl ItemScope {
123 123
124 if existing.def.types.is_none() && res.def.types.is_some() { 124 if existing.def.types.is_none() && res.def.types.is_some() {
125 existing.def.types = res.def.types; 125 existing.def.types = res.def.types;
126 existing.import = import.or(res.import); 126 existing.import = import.is_some() || res.import;
127 changed = true; 127 changed = true;
128 } 128 }
129 if existing.def.values.is_none() && res.def.values.is_some() { 129 if existing.def.values.is_none() && res.def.values.is_some() {
130 existing.def.values = res.def.values; 130 existing.def.values = res.def.values;
131 existing.import = import.or(res.import); 131 existing.import = import.is_some() || res.import;
132 changed = true; 132 changed = true;
133 } 133 }
134 if existing.def.macros.is_none() && res.def.macros.is_some() { 134 if existing.def.macros.is_none() && res.def.macros.is_some() {
135 existing.def.macros = res.def.macros; 135 existing.def.macros = res.def.macros;
136 existing.import = import.or(res.import); 136 existing.import = import.is_some() || res.import;
137 changed = true; 137 changed = true;
138 } 138 }
139 139
140 if existing.def.is_none() 140 if existing.def.is_none() && res.def.is_none() && !existing.import && res.import {
141 && res.def.is_none()
142 && existing.import.is_none()
143 && res.import.is_some()
144 {
145 existing.import = res.import; 141 existing.import = res.import;
146 } 142 }
147 changed 143 changed
@@ -160,6 +156,5 @@ impl ItemScope {
160pub struct Resolution { 156pub struct Resolution {
161 /// None for unresolved 157 /// None for unresolved
162 pub def: PerNs, 158 pub def: PerNs,
163 /// ident by which this is imported into local scope. 159 pub(crate) import: bool,
164 pub(crate) import: Option<LocalImportId>,
165} 160}
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs
index 45199fa11..c2db5472b 100644
--- a/crates/ra_hir_def/src/nameres/collector.rs
+++ b/crates/ra_hir_def/src/nameres/collector.rs
@@ -219,7 +219,7 @@ where
219 self.update( 219 self.update(
220 self.def_map.root, 220 self.def_map.root,
221 None, 221 None,
222 &[(name, Resolution { def: PerNs::macros(macro_), import: None })], 222 &[(name, Resolution { def: PerNs::macros(macro_), import: false })],
223 ); 223 );
224 } 224 }
225 } 225 }
@@ -404,7 +404,7 @@ where
404 let variant = EnumVariantId { parent: e, local_id }; 404 let variant = EnumVariantId { parent: e, local_id };
405 let res = Resolution { 405 let res = Resolution {
406 def: PerNs::both(variant.into(), variant.into()), 406 def: PerNs::both(variant.into(), variant.into()),
407 import: Some(import_id), 407 import: true,
408 }; 408 };
409 (name, res) 409 (name, res)
410 }) 410 })
@@ -431,7 +431,7 @@ where
431 } 431 }
432 } 432 }
433 433
434 let resolution = Resolution { def, import: Some(import_id) }; 434 let resolution = Resolution { def, import: true };
435 self.update(module_id, Some(import_id), &[(name, resolution)]); 435 self.update(module_id, Some(import_id), &[(name, resolution)]);
436 } 436 }
437 None => tested_by!(bogus_paths), 437 None => tested_by!(bogus_paths),
@@ -719,7 +719,7 @@ where
719 def: PerNs::types( 719 def: PerNs::types(
720 ModuleId { krate: self.def_collector.def_map.krate, local_id: res }.into(), 720 ModuleId { krate: self.def_collector.def_map.krate, local_id: res }.into(),
721 ), 721 ),
722 import: None, 722 import: false,
723 }; 723 };
724 self.def_collector.update(self.module_id, None, &[(name, resolution)]); 724 self.def_collector.update(self.module_id, None, &[(name, resolution)]);
725 res 725 res
@@ -791,7 +791,7 @@ where
791 PerNs::types(def.into()) 791 PerNs::types(def.into())
792 } 792 }
793 }; 793 };
794 let resolution = Resolution { def, import: None }; 794 let resolution = Resolution { def, import: false };
795 self.def_collector.update(self.module_id, None, &[(name, resolution)]) 795 self.def_collector.update(self.module_id, None, &[(name, resolution)])
796 } 796 }
797 797