about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLukas Wirth <lukastw97@gmail.com>2025-05-28 07:05:48 +0200
committerLukas Wirth <lukastw97@gmail.com>2025-05-28 07:05:55 +0200
commit711546a329170d741a1f422063d7082e8d8a75e5 (patch)
tree91d4d2b062620694d01c78dcc9aa882723d13c40
parentcfe488c7a0bf154dd060404b35d55a482c307817 (diff)
downloadrust-711546a329170d741a1f422063d7082e8d8a75e5.tar.gz
rust-711546a329170d741a1f422063d7082e8d8a75e5.zip
Drop unnecessay code
-rw-r--r--src/tools/rust-analyzer/crates/hir/src/semantics.rs7
-rw-r--r--src/tools/rust-analyzer/crates/hir/src/source_analyzer.rs31
2 files changed, 3 insertions, 35 deletions
diff --git a/src/tools/rust-analyzer/crates/hir/src/semantics.rs b/src/tools/rust-analyzer/crates/hir/src/semantics.rs
index 5823f6260bf..0dac64d6f2c 100644
--- a/src/tools/rust-analyzer/crates/hir/src/semantics.rs
+++ b/src/tools/rust-analyzer/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/src/tools/rust-analyzer/crates/hir/src/source_analyzer.rs b/src/tools/rust-analyzer/crates/hir/src/source_analyzer.rs
index be581292152..d22812d3c69 100644
--- a/src/tools/rust-analyzer/crates/hir/src/source_analyzer.rs
+++ b/src/tools/rust-analyzer/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<MacroCallId> {
-        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<TraitEnvironment> {
         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<Macro> {
-        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,