diff options
author | Aleksey Kladov <[email protected]> | 2019-12-22 14:28:55 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-12-22 14:28:55 +0000 |
commit | 558956c84be5e8752986bae001c7fd3f06cbe86d (patch) | |
tree | b3234f4895fa63b190a78c0e99679ee52c3df8db /crates/ra_hir_def | |
parent | 2c60f42825e68d8133854d378d9550139c71d9b4 (diff) |
Remove import field
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r-- | crates/ra_hir_def/src/item_scope.rs | 13 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 14 |
2 files changed, 8 insertions, 19 deletions
diff --git a/crates/ra_hir_def/src/item_scope.rs b/crates/ra_hir_def/src/item_scope.rs index b5c07ed5f..81089554f 100644 --- a/crates/ra_hir_def/src/item_scope.rs +++ b/crates/ra_hir_def/src/item_scope.rs | |||
@@ -30,9 +30,7 @@ pub struct ItemScope { | |||
30 | static BUILTIN_SCOPE: Lazy<FxHashMap<Name, Resolution>> = Lazy::new(|| { | 30 | static BUILTIN_SCOPE: Lazy<FxHashMap<Name, Resolution>> = Lazy::new(|| { |
31 | BuiltinType::ALL | 31 | BuiltinType::ALL |
32 | .iter() | 32 | .iter() |
33 | .map(|(name, ty)| { | 33 | .map(|(name, ty)| (name.clone(), Resolution { def: PerNs::types(ty.clone().into()) })) |
34 | (name.clone(), Resolution { def: PerNs::types(ty.clone().into()), import: false }) | ||
35 | }) | ||
36 | .collect() | 34 | .collect() |
37 | }); | 35 | }); |
38 | 36 | ||
@@ -113,29 +111,23 @@ impl ItemScope { | |||
113 | self.legacy_macros.insert(name, mac); | 111 | self.legacy_macros.insert(name, mac); |
114 | } | 112 | } |
115 | 113 | ||
116 | pub(crate) fn push_res(&mut self, name: Name, res: &Resolution, import: bool) -> bool { | 114 | pub(crate) fn push_res(&mut self, name: Name, res: &Resolution, _import: bool) -> bool { |
117 | let mut changed = false; | 115 | let mut changed = false; |
118 | let existing = self.visible.entry(name.clone()).or_default(); | 116 | let existing = self.visible.entry(name.clone()).or_default(); |
119 | 117 | ||
120 | if existing.def.types.is_none() && res.def.types.is_some() { | 118 | if existing.def.types.is_none() && res.def.types.is_some() { |
121 | existing.def.types = res.def.types; | 119 | existing.def.types = res.def.types; |
122 | existing.import = import || res.import; | ||
123 | changed = true; | 120 | changed = true; |
124 | } | 121 | } |
125 | if existing.def.values.is_none() && res.def.values.is_some() { | 122 | if existing.def.values.is_none() && res.def.values.is_some() { |
126 | existing.def.values = res.def.values; | 123 | existing.def.values = res.def.values; |
127 | existing.import = import || res.import; | ||
128 | changed = true; | 124 | changed = true; |
129 | } | 125 | } |
130 | if existing.def.macros.is_none() && res.def.macros.is_some() { | 126 | if existing.def.macros.is_none() && res.def.macros.is_some() { |
131 | existing.def.macros = res.def.macros; | 127 | existing.def.macros = res.def.macros; |
132 | existing.import = import || res.import; | ||
133 | changed = true; | 128 | changed = true; |
134 | } | 129 | } |
135 | 130 | ||
136 | if existing.def.is_none() && res.def.is_none() && !existing.import && res.import { | ||
137 | existing.import = res.import; | ||
138 | } | ||
139 | changed | 131 | changed |
140 | } | 132 | } |
141 | 133 | ||
@@ -152,7 +144,6 @@ impl ItemScope { | |||
152 | pub struct Resolution { | 144 | pub struct Resolution { |
153 | /// None for unresolved | 145 | /// None for unresolved |
154 | pub def: PerNs, | 146 | pub def: PerNs, |
155 | pub(crate) import: bool, | ||
156 | } | 147 | } |
157 | 148 | ||
158 | impl From<ModuleDefId> for PerNs { | 149 | impl From<ModuleDefId> for PerNs { |
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index 745e31c0d..3706c1223 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs | |||
@@ -218,7 +218,7 @@ where | |||
218 | self.update( | 218 | self.update( |
219 | self.def_map.root, | 219 | self.def_map.root, |
220 | None, | 220 | None, |
221 | &[(name, Resolution { def: PerNs::macros(macro_), import: false })], | 221 | &[(name, Resolution { def: PerNs::macros(macro_) })], |
222 | ); | 222 | ); |
223 | } | 223 | } |
224 | } | 224 | } |
@@ -401,10 +401,8 @@ where | |||
401 | .map(|(local_id, variant_data)| { | 401 | .map(|(local_id, variant_data)| { |
402 | let name = variant_data.name.clone(); | 402 | let name = variant_data.name.clone(); |
403 | let variant = EnumVariantId { parent: e, local_id }; | 403 | let variant = EnumVariantId { parent: e, local_id }; |
404 | let res = Resolution { | 404 | let res = |
405 | def: PerNs::both(variant.into(), variant.into()), | 405 | Resolution { def: PerNs::both(variant.into(), variant.into()) }; |
406 | import: true, | ||
407 | }; | ||
408 | (name, res) | 406 | (name, res) |
409 | }) | 407 | }) |
410 | .collect::<Vec<_>>(); | 408 | .collect::<Vec<_>>(); |
@@ -430,7 +428,7 @@ where | |||
430 | } | 428 | } |
431 | } | 429 | } |
432 | 430 | ||
433 | let resolution = Resolution { def, import: true }; | 431 | let resolution = Resolution { def }; |
434 | self.update(module_id, Some(import_id), &[(name, resolution)]); | 432 | self.update(module_id, Some(import_id), &[(name, resolution)]); |
435 | } | 433 | } |
436 | None => tested_by!(bogus_paths), | 434 | None => tested_by!(bogus_paths), |
@@ -717,7 +715,7 @@ where | |||
717 | let module = ModuleId { krate: self.def_collector.def_map.krate, local_id: res }; | 715 | let module = ModuleId { krate: self.def_collector.def_map.krate, local_id: res }; |
718 | let def: ModuleDefId = module.into(); | 716 | let def: ModuleDefId = module.into(); |
719 | self.def_collector.def_map.modules[self.module_id].scope.define_def(def); | 717 | self.def_collector.def_map.modules[self.module_id].scope.define_def(def); |
720 | let resolution = Resolution { def: def.into(), import: false }; | 718 | let resolution = Resolution { def: def.into() }; |
721 | self.def_collector.update(self.module_id, None, &[(name, resolution)]); | 719 | self.def_collector.update(self.module_id, None, &[(name, resolution)]); |
722 | res | 720 | res |
723 | } | 721 | } |
@@ -777,7 +775,7 @@ where | |||
777 | .into(), | 775 | .into(), |
778 | }; | 776 | }; |
779 | self.def_collector.def_map.modules[self.module_id].scope.define_def(def); | 777 | self.def_collector.def_map.modules[self.module_id].scope.define_def(def); |
780 | let resolution = Resolution { def: def.into(), import: false }; | 778 | let resolution = Resolution { def: def.into() }; |
781 | self.def_collector.update(self.module_id, None, &[(name, resolution)]) | 779 | self.def_collector.update(self.module_id, None, &[(name, resolution)]) |
782 | } | 780 | } |
783 | 781 | ||