From 1a8f2aa024c6f1a5e9704c9cbd2e5a020debe2c2 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 21 Dec 2019 17:34:28 +0100 Subject: Move LocalImportId --- crates/ra_hir_def/src/nameres/collector.rs | 13 ++++++------- crates/ra_hir_def/src/nameres/raw.rs | 16 +++++++++------- 2 files changed, 15 insertions(+), 14 deletions(-) (limited to 'crates/ra_hir_def/src/nameres') diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index c2db5472b..2b194f488 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs @@ -26,8 +26,7 @@ use crate::{ path::{ModPath, PathKind}, per_ns::PerNs, AdtId, AstId, ConstLoc, ContainerId, EnumLoc, EnumVariantId, FunctionLoc, ImplLoc, Intern, - LocalImportId, LocalModuleId, ModuleDefId, ModuleId, StaticLoc, StructLoc, TraitLoc, - TypeAliasLoc, UnionLoc, + LocalModuleId, ModuleDefId, ModuleId, StaticLoc, StructLoc, TraitLoc, TypeAliasLoc, UnionLoc, }; pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap { @@ -93,7 +92,7 @@ impl PartialResolvedImport { #[derive(Clone, Debug, Eq, PartialEq)] struct ImportDirective { module_id: LocalModuleId, - import_id: LocalImportId, + import_id: raw::Import, import: raw::ImportData, status: PartialResolvedImport, } @@ -110,7 +109,7 @@ struct MacroDirective { struct DefCollector<'a, DB> { db: &'a DB, def_map: CrateDefMap, - glob_imports: FxHashMap>, + glob_imports: FxHashMap>, unresolved_imports: Vec, resolved_imports: Vec, unexpanded_macros: Vec, @@ -442,7 +441,7 @@ where fn update( &mut self, module_id: LocalModuleId, - import: Option, + import: Option, resolutions: &[(Name, Resolution)], ) { self.update_recursive(module_id, import, resolutions, 0) @@ -451,7 +450,7 @@ where fn update_recursive( &mut self, module_id: LocalModuleId, - import: Option, + import: Option, resolutions: &[(Name, Resolution)], depth: usize, ) { @@ -462,7 +461,7 @@ where let scope = &mut self.def_map.modules[module_id].scope; let mut changed = false; for (name, res) in resolutions { - changed |= scope.push_res(name.clone(), res, import); + changed |= scope.push_res(name.clone(), res, import.is_some()); } if !changed { diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs index 73e57f1e5..1b83b2247 100644 --- a/crates/ra_hir_def/src/nameres/raw.rs +++ b/crates/ra_hir_def/src/nameres/raw.rs @@ -20,9 +20,7 @@ use ra_syntax::{ }; use test_utils::tested_by; -use crate::{ - attr::Attrs, db::DefDatabase, path::ModPath, FileAstId, HirFileId, InFile, LocalImportId, -}; +use crate::{attr::Attrs, db::DefDatabase, path::ModPath, FileAstId, HirFileId, InFile}; /// `RawItems` is a set of top-level items in a file (except for impls). /// @@ -31,7 +29,7 @@ use crate::{ #[derive(Debug, Default, PartialEq, Eq)] pub struct RawItems { modules: Arena, - imports: Arena, + imports: Arena, defs: Arena, macros: Arena, impls: Arena, @@ -73,9 +71,9 @@ impl Index for RawItems { } } -impl Index for RawItems { +impl Index for RawItems { type Output = ImportData; - fn index(&self, idx: LocalImportId) -> &ImportData { + fn index(&self, idx: Import) -> &ImportData { &self.imports[idx] } } @@ -110,7 +108,7 @@ pub(super) struct RawItem { #[derive(Debug, PartialEq, Eq, Clone, Copy)] pub(super) enum RawItemKind { Module(Module), - Import(LocalImportId), + Import(Import), Def(Def), Macro(Macro), Impl(Impl), @@ -126,6 +124,10 @@ pub(super) enum ModuleData { Definition { name: Name, ast_id: FileAstId, items: Vec }, } +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub(crate) struct Import(RawId); +impl_arena_id!(Import); + #[derive(Debug, Clone, PartialEq, Eq)] pub struct ImportData { pub(super) path: ModPath, -- cgit v1.2.3