mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-14 01:41:26 +00:00
Drop unnecessay code
This commit is contained in:
parent
bbbcfaab8b
commit
5b28e9022e
2 changed files with 3 additions and 35 deletions
|
|
@ -567,9 +567,7 @@ impl<'db> SemanticsImpl<'db> {
|
||||||
speculative_args: &ast::TokenTree,
|
speculative_args: &ast::TokenTree,
|
||||||
token_to_map: SyntaxToken,
|
token_to_map: SyntaxToken,
|
||||||
) -> Option<(SyntaxNode, Vec<(SyntaxToken, u8)>)> {
|
) -> Option<(SyntaxNode, Vec<(SyntaxToken, u8)>)> {
|
||||||
let analyzer = self.analyze_no_infer(actual_macro_call.syntax())?;
|
let macro_file = self.to_def(actual_macro_call)?;
|
||||||
let macro_call = InFile::new(analyzer.file_id, actual_macro_call);
|
|
||||||
let macro_file = analyzer.expansion(self.db, macro_call)?;
|
|
||||||
hir_expand::db::expand_speculative(
|
hir_expand::db::expand_speculative(
|
||||||
self.db,
|
self.db,
|
||||||
macro_file,
|
macro_file,
|
||||||
|
|
@ -1535,9 +1533,6 @@ impl<'db> SemanticsImpl<'db> {
|
||||||
.and_then(|call| macro_call_to_macro_id(ctx, call))
|
.and_then(|call| macro_call_to_macro_id(ctx, call))
|
||||||
.map(Into::into)
|
.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 {
|
pub fn is_proc_macro_call(&self, macro_call: InFile<&ast::MacroCall>) -> bool {
|
||||||
|
|
|
||||||
|
|
@ -26,12 +26,12 @@ use hir_def::{
|
||||||
},
|
},
|
||||||
hir::{BindingId, Expr, ExprId, ExprOrPatId, Pat},
|
hir::{BindingId, Expr, ExprId, ExprOrPatId, Pat},
|
||||||
lang_item::LangItem,
|
lang_item::LangItem,
|
||||||
nameres::{MacroSubNs, block_def_map, crate_def_map},
|
nameres::MacroSubNs,
|
||||||
resolver::{HasResolver, Resolver, TypeNs, ValueNs, resolver_for_scope},
|
resolver::{HasResolver, Resolver, TypeNs, ValueNs, resolver_for_scope},
|
||||||
type_ref::{Mutability, TypeRefId},
|
type_ref::{Mutability, TypeRefId},
|
||||||
};
|
};
|
||||||
use hir_expand::{
|
use hir_expand::{
|
||||||
HirFileId, InFile, MacroCallId,
|
HirFileId, InFile,
|
||||||
mod_path::{ModPath, PathKind, path},
|
mod_path::{ModPath, PathKind, path},
|
||||||
name::{AsName, Name},
|
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> {
|
fn trait_environment(&self, db: &'db dyn HirDatabase) -> Arc<TraitEnvironment> {
|
||||||
self.body_().map(|(def, ..)| def).map_or_else(
|
self.body_().map(|(def, ..)| def).map_or_else(
|
||||||
|| TraitEnvironment::empty(self.resolver.krate()),
|
|| 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(
|
pub(crate) fn resolve_bind_pat_to_const(
|
||||||
&self,
|
&self,
|
||||||
db: &'db dyn HirDatabase,
|
db: &'db dyn HirDatabase,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue