Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-def/src/nameres.rs')
| -rw-r--r-- | crates/hir-def/src/nameres.rs | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/crates/hir-def/src/nameres.rs b/crates/hir-def/src/nameres.rs index a85237662c..3f29619bcb 100644 --- a/crates/hir-def/src/nameres.rs +++ b/crates/hir-def/src/nameres.rs @@ -75,7 +75,7 @@ use triomphe::Arc; use tt::TextRange; use crate::{ - AstId, BlockId, BlockIdLt, ExternCrateId, FunctionId, FxIndexMap, Lookup, MacroCallStyles, + AstId, BlockId, BlockLoc, ExternCrateId, FunctionId, FxIndexMap, Lookup, MacroCallStyles, MacroExpander, MacroId, ModuleId, ModuleIdLt, ProcMacroId, UseId, db::DefDatabase, item_scope::{BuiltinShadowMode, ItemScope}, @@ -247,12 +247,12 @@ struct BlockInfo { parent: ModuleId, } -impl std::ops::Index<ModuleIdLt<'_>> for DefMap { +impl std::ops::Index<ModuleId> for DefMap { type Output = ModuleData; - fn index(&self, id: ModuleIdLt<'_>) -> &ModuleData { + fn index(&self, id: ModuleId) -> &ModuleData { self.modules - .get(&unsafe { id.to_static() }) + .get(&id) .unwrap_or_else(|| panic!("ModuleId not found in ModulesMap {:#?}: {id:#?}", self.root)) } } @@ -400,10 +400,8 @@ pub(crate) fn crate_local_def_map(db: &dyn DefDatabase, crate_id: Crate) -> DefM } #[salsa_macros::tracked(returns(ref))] -pub fn block_def_map<'db>(db: &'db dyn DefDatabase, block_id: BlockIdLt<'db>) -> DefMap { - let block_id = unsafe { block_id.to_static() }; - let ast_id = block_id.ast_id(db); - let module = unsafe { block_id.module(db).to_static() }; +pub fn block_def_map(db: &dyn DefDatabase, block_id: BlockId) -> DefMap { + let BlockLoc { ast_id, module } = block_id.lookup(db); let visibility = Visibility::Module(module, VisibilityExplicitness::Implicit); let module_data = @@ -559,7 +557,7 @@ impl DefMap { /// Returns the module containing `local_mod`, either the parent `mod`, or the module (or block) containing /// the block, if `self` corresponds to a block expression. - pub fn containing_module(&self, local_mod: ModuleIdLt<'_>) -> Option<ModuleId> { + pub fn containing_module(&self, local_mod: ModuleId) -> Option<ModuleId> { match self[local_mod].parent { Some(parent) => Some(parent), None => self.block.map(|BlockInfo { parent, .. }| parent), @@ -664,11 +662,11 @@ impl DefMap { /// /// If `f` returns `Some(val)`, iteration is stopped and `Some(val)` is returned. If `f` returns /// `None`, iteration continues. - pub(crate) fn with_ancestor_maps<'db, T>( + pub(crate) fn with_ancestor_maps<T>( &self, - db: &'db dyn DefDatabase, - local_mod: ModuleIdLt<'db>, - f: &mut dyn FnMut(&DefMap, ModuleIdLt<'db>) -> Option<T>, + db: &dyn DefDatabase, + local_mod: ModuleId, + f: &mut dyn FnMut(&DefMap, ModuleId) -> Option<T>, ) -> Option<T> { if let Some(it) = f(self, local_mod) { return Some(it); @@ -854,13 +852,11 @@ impl DerefMut for ModulesMap { } } -impl Index<ModuleIdLt<'_>> for ModulesMap { +impl Index<ModuleId> for ModulesMap { type Output = ModuleData; - fn index(&self, id: ModuleIdLt<'_>) -> &ModuleData { - self.inner - .get(&unsafe { id.to_static() }) - .unwrap_or_else(|| panic!("ModuleId not found in ModulesMap: {id:#?}")) + fn index(&self, id: ModuleId) -> &ModuleData { + self.inner.get(&id).unwrap_or_else(|| panic!("ModuleId not found in ModulesMap: {id:#?}")) } } |