Skip to content

Commit 711546a

Browse files
committed
Drop unnecessay code
1 parent cfe488c commit 711546a

File tree

2 files changed

+3
-35
lines changed

2 files changed

+3
-35
lines changed

src/tools/rust-analyzer/crates/hir/src/semantics.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -567,9 +567,7 @@ impl<'db> SemanticsImpl<'db> {
567567
speculative_args: &ast::TokenTree,
568568
token_to_map: SyntaxToken,
569569
) -> Option<(SyntaxNode, Vec<(SyntaxToken, u8)>)> {
570-
let analyzer = self.analyze_no_infer(actual_macro_call.syntax())?;
571-
let macro_call = InFile::new(analyzer.file_id, actual_macro_call);
572-
let macro_file = analyzer.expansion(self.db, macro_call)?;
570+
let macro_file = self.to_def(actual_macro_call)?;
573571
hir_expand::db::expand_speculative(
574572
self.db,
575573
macro_file,
@@ -1535,9 +1533,6 @@ impl<'db> SemanticsImpl<'db> {
15351533
.and_then(|call| macro_call_to_macro_id(ctx, call))
15361534
.map(Into::into)
15371535
})
1538-
.or_else(|| {
1539-
self.analyze(macro_call.value.syntax())?.resolve_macro_call(self.db, macro_call)
1540-
})
15411536
}
15421537

15431538
pub fn is_proc_macro_call(&self, macro_call: InFile<&ast::MacroCall>) -> bool {

src/tools/rust-analyzer/crates/hir/src/source_analyzer.rs

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ use hir_def::{
2626
},
2727
hir::{BindingId, Expr, ExprId, ExprOrPatId, Pat},
2828
lang_item::LangItem,
29-
nameres::{MacroSubNs, block_def_map, crate_def_map},
29+
nameres::MacroSubNs,
3030
resolver::{HasResolver, Resolver, TypeNs, ValueNs, resolver_for_scope},
3131
type_ref::{Mutability, TypeRefId},
3232
};
3333
use hir_expand::{
34-
HirFileId, InFile, MacroCallId,
34+
HirFileId, InFile,
3535
mod_path::{ModPath, PathKind, path},
3636
name::{AsName, Name},
3737
};
@@ -218,18 +218,6 @@ impl<'db> SourceAnalyzer<'db> {
218218
})
219219
}
220220

221-
pub(crate) fn expansion(
222-
&self,
223-
db: &dyn HirDatabase,
224-
macro_call: InFile<&ast::MacroCall>,
225-
) -> Option<MacroCallId> {
226-
self.store_sm().and_then(|sm| sm.expansion(macro_call)).or_else(|| {
227-
let ast_id_map = db.ast_id_map(macro_call.file_id);
228-
let call_ast_id = macro_call.with_value(ast_id_map.ast_id(macro_call.value));
229-
self.resolver.item_scopes().find_map(|scope| scope.macro_invoc(call_ast_id))
230-
})
231-
}
232-
233221
fn trait_environment(&self, db: &'db dyn HirDatabase) -> Arc<TraitEnvironment> {
234222
self.body_().map(|(def, ..)| def).map_or_else(
235223
|| TraitEnvironment::empty(self.resolver.krate()),
@@ -753,21 +741,6 @@ impl<'db> SourceAnalyzer<'db> {
753741
))
754742
}
755743

756-
pub(crate) fn resolve_macro_call(
757-
&self,
758-
db: &dyn HirDatabase,
759-
macro_call: InFile<&ast::MacroCall>,
760-
) -> Option<Macro> {
761-
self.expansion(db, macro_call).and_then(|it| {
762-
let def = it.lookup(db).def;
763-
let def_map = match def.block {
764-
Some(block) => block_def_map(db, base_db::salsa::plumbing::FromId::from_id(block)),
765-
None => crate_def_map(db, def.krate),
766-
};
767-
def_map.macro_def_to_macro_id.get(&def.kind.erased_ast_id()).map(|it| (*it).into())
768-
})
769-
}
770-
771744
pub(crate) fn resolve_bind_pat_to_const(
772745
&self,
773746
db: &'db dyn HirDatabase,

0 commit comments

Comments
 (0)