From 5b28e9022e6f3f89a2ae44d0f8f1c9ee08438f5a Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 28 May 2025 07:05:48 +0200 Subject: [PATCH] Drop unnecessay code --- crates/hir/src/semantics.rs | 7 +------ crates/hir/src/source_analyzer.rs | 31 ++----------------------------- 2 files changed, 3 insertions(+), 35 deletions(-) diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs index 5823f6260b..0dac64d6f2 100644 --- a/crates/hir/src/semantics.rs +++ b/crates/hir/src/semantics.rs @@ -567,9 +567,7 @@ impl<'db> SemanticsImpl<'db> { speculative_args: &ast::TokenTree, token_to_map: SyntaxToken, ) -> Option<(SyntaxNode, Vec<(SyntaxToken, u8)>)> { - let analyzer = self.analyze_no_infer(actual_macro_call.syntax())?; - let macro_call = InFile::new(analyzer.file_id, actual_macro_call); - let macro_file = analyzer.expansion(self.db, macro_call)?; + let macro_file = self.to_def(actual_macro_call)?; hir_expand::db::expand_speculative( self.db, macro_file, @@ -1535,9 +1533,6 @@ impl<'db> SemanticsImpl<'db> { .and_then(|call| macro_call_to_macro_id(ctx, call)) .map(Into::into) }) - .or_else(|| { - self.analyze(macro_call.value.syntax())?.resolve_macro_call(self.db, macro_call) - }) } pub fn is_proc_macro_call(&self, macro_call: InFile<&ast::MacroCall>) -> bool { diff --git a/crates/hir/src/source_analyzer.rs b/crates/hir/src/source_analyzer.rs index be58129215..d22812d3c6 100644 --- a/crates/hir/src/source_analyzer.rs +++ b/crates/hir/src/source_analyzer.rs @@ -26,12 +26,12 @@ use hir_def::{ }, hir::{BindingId, Expr, ExprId, ExprOrPatId, Pat}, lang_item::LangItem, - nameres::{MacroSubNs, block_def_map, crate_def_map}, + nameres::MacroSubNs, resolver::{HasResolver, Resolver, TypeNs, ValueNs, resolver_for_scope}, type_ref::{Mutability, TypeRefId}, }; use hir_expand::{ - HirFileId, InFile, MacroCallId, + HirFileId, InFile, mod_path::{ModPath, PathKind, path}, name::{AsName, Name}, }; @@ -218,18 +218,6 @@ impl<'db> SourceAnalyzer<'db> { }) } - pub(crate) fn expansion( - &self, - db: &dyn HirDatabase, - macro_call: InFile<&ast::MacroCall>, - ) -> Option { - self.store_sm().and_then(|sm| sm.expansion(macro_call)).or_else(|| { - let ast_id_map = db.ast_id_map(macro_call.file_id); - let call_ast_id = macro_call.with_value(ast_id_map.ast_id(macro_call.value)); - self.resolver.item_scopes().find_map(|scope| scope.macro_invoc(call_ast_id)) - }) - } - fn trait_environment(&self, db: &'db dyn HirDatabase) -> Arc { self.body_().map(|(def, ..)| def).map_or_else( || TraitEnvironment::empty(self.resolver.krate()), @@ -753,21 +741,6 @@ impl<'db> SourceAnalyzer<'db> { )) } - pub(crate) fn resolve_macro_call( - &self, - db: &dyn HirDatabase, - macro_call: InFile<&ast::MacroCall>, - ) -> Option { - self.expansion(db, macro_call).and_then(|it| { - let def = it.lookup(db).def; - let def_map = match def.block { - Some(block) => block_def_map(db, base_db::salsa::plumbing::FromId::from_id(block)), - None => crate_def_map(db, def.krate), - }; - def_map.macro_def_to_macro_id.get(&def.kind.erased_ast_id()).map(|it| (*it).into()) - }) - } - pub(crate) fn resolve_bind_pat_to_const( &self, db: &'db dyn HirDatabase,