From f6f2d69bb8318815ff87cd1bfe504fe5aa09ed63 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 26 Mar 2019 14:54:05 +0300 Subject: simplify --- crates/ra_hir/src/nameres.rs | 6 ++---- crates/ra_hir/src/source_binder.rs | 6 +++--- crates/ra_hir/src/source_id.rs | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) (limited to 'crates') diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs index d8fa2383f..36ef615a3 100644 --- a/crates/ra_hir/src/nameres.rs +++ b/crates/ra_hir/src/nameres.rs @@ -61,9 +61,8 @@ use ra_db::{FileId, Edition}; use test_utils::tested_by; use crate::{ - ModuleDef, Name, Crate, Module, + ModuleDef, Name, Crate, Module, SourceItemId, DefDatabase, Path, PathKind, HirFileId, Trait, - SourceItemId, SourceFileItemId, ids::{MacroCallId, MacroDefId}, diagnostics::DiagnosticSink, nameres::diagnostics::DefDiagnostic, @@ -242,9 +241,8 @@ impl CrateDefMap { pub(crate) fn find_module_by_source( &self, file_id: HirFileId, - decl_id: Option, + decl_id: Option, ) -> Option { - let decl_id = decl_id.map(|it| it.with_file_id(file_id)); let (module_id, _module_data) = self.modules.iter().find(|(_module_id, module_data)| { if decl_id.is_some() { module_data.declaration == decl_id diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 6e157007f..db9e3a22e 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs @@ -13,7 +13,7 @@ use ra_syntax::{ }; use crate::{ - HirDatabase, Function, Struct, Enum, SourceFileItemId, + HirDatabase, Function, Struct, Enum, SourceItemId, AsName, Module, HirFileId, Crate, Trait, Resolver, ids::LocationCtx, expr @@ -55,7 +55,7 @@ fn module_from_inline( assert!(!module.has_semi()); let file_id = file_id.into(); let file_items = db.file_items(file_id); - let item_id = file_items.id_of(file_id, module.syntax()); + let item_id = file_items.id_of(file_id, module.syntax()).with_file_id(file_id); module_from_source(db, file_id, Some(item_id)) } @@ -75,7 +75,7 @@ pub fn module_from_child_node( fn module_from_source( db: &impl HirDatabase, file_id: HirFileId, - decl_id: Option, + decl_id: Option, ) -> Option { let source_root_id = db.file_source_root(file_id.as_original_file()); db.source_root_crates(source_root_id).iter().map(|&crate_id| Crate { crate_id }).find_map( diff --git a/crates/ra_hir/src/source_id.rs b/crates/ra_hir/src/source_id.rs index f961adf8b..62707ba6a 100644 --- a/crates/ra_hir/src/source_id.rs +++ b/crates/ra_hir/src/source_id.rs @@ -8,7 +8,7 @@ use crate::{HirFileId, DefDatabase}; /// Identifier of item within a specific file. This is stable over reparses, so /// it's OK to use it as a salsa key/value. #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct SourceFileItemId(RawId); +pub(crate) struct SourceFileItemId(RawId); impl_arena_id!(SourceFileItemId); impl SourceFileItemId { -- cgit v1.2.3