From ec56f59ac17ad5ae797ce431883be8f31e795d1b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 21 Dec 2019 17:22:48 +0100 Subject: Remove import from resolution --- crates/ra_hir_def/src/item_scope.rs | 19 +++++++------------ crates/ra_hir_def/src/nameres/collector.rs | 10 +++++----- 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> = Lazy::new(|| { BuiltinType::ALL .iter() .map(|(name, ty)| { - (name.clone(), Resolution { def: PerNs::types(ty.clone().into()), import: None }) + (name.clone(), Resolution { def: PerNs::types(ty.clone().into()), import: false }) }) .collect() }); @@ -54,7 +54,7 @@ impl ItemScope { pub fn declarations(&self) -> impl Iterator + '_ { self.entries() - .filter_map(|(_name, res)| if res.import.is_none() { Some(res.def) } else { None }) + .filter_map(|(_name, res)| if !res.import { Some(res.def) } else { None }) .flat_map(|per_ns| { per_ns.take_types().into_iter().chain(per_ns.take_values().into_iter()) }) @@ -123,25 +123,21 @@ impl ItemScope { if existing.def.types.is_none() && res.def.types.is_some() { existing.def.types = res.def.types; - existing.import = import.or(res.import); + existing.import = import.is_some() || res.import; changed = true; } if existing.def.values.is_none() && res.def.values.is_some() { existing.def.values = res.def.values; - existing.import = import.or(res.import); + existing.import = import.is_some() || res.import; changed = true; } if existing.def.macros.is_none() && res.def.macros.is_some() { existing.def.macros = res.def.macros; - existing.import = import.or(res.import); + existing.import = import.is_some() || res.import; changed = true; } - if existing.def.is_none() - && res.def.is_none() - && existing.import.is_none() - && res.import.is_some() - { + if existing.def.is_none() && res.def.is_none() && !existing.import && res.import { existing.import = res.import; } changed @@ -160,6 +156,5 @@ impl ItemScope { pub struct Resolution { /// None for unresolved pub def: PerNs, - /// ident by which this is imported into local scope. - pub(crate) import: Option, + pub(crate) import: bool, } 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 self.update( self.def_map.root, None, - &[(name, Resolution { def: PerNs::macros(macro_), import: None })], + &[(name, Resolution { def: PerNs::macros(macro_), import: false })], ); } } @@ -404,7 +404,7 @@ where let variant = EnumVariantId { parent: e, local_id }; let res = Resolution { def: PerNs::both(variant.into(), variant.into()), - import: Some(import_id), + import: true, }; (name, res) }) @@ -431,7 +431,7 @@ where } } - let resolution = Resolution { def, import: Some(import_id) }; + let resolution = Resolution { def, import: true }; self.update(module_id, Some(import_id), &[(name, resolution)]); } None => tested_by!(bogus_paths), @@ -719,7 +719,7 @@ where def: PerNs::types( ModuleId { krate: self.def_collector.def_map.krate, local_id: res }.into(), ), - import: None, + import: false, }; self.def_collector.update(self.module_id, None, &[(name, resolution)]); res @@ -791,7 +791,7 @@ where PerNs::types(def.into()) } }; - let resolution = Resolution { def, import: None }; + let resolution = Resolution { def, import: false }; self.def_collector.update(self.module_id, None, &[(name, resolution)]) } -- cgit v1.2.3