HirFileId, InFile, MacroDefId,
};
use la_arena::{Arena, ArenaMap};
+use profile::Count;
use rustc_hash::FxHashMap;
use syntax::{ast, AstNode, AstPtr};
use test_utils::mark;
pub(crate) struct Expander {
cfg_expander: CfgExpander,
- crate_def_map: Arc<DefMap>,
+ def_map: Arc<DefMap>,
current_file_id: HirFileId,
ast_id_map: Arc<AstIdMap>,
module: ModuleId,
module: ModuleId,
) -> Expander {
let cfg_expander = CfgExpander::new(db, current_file_id, module.krate);
- let crate_def_map = db.crate_def_map(module.krate);
+ let crate_def_map = module.def_map(db);
let ast_id_map = db.ast_id_map(current_file_id);
Expander {
cfg_expander,
- crate_def_map,
+ def_map: crate_def_map,
current_file_id,
ast_id_map,
module,
pub(crate) fn enter_expand<T: ast::AstNode>(
&mut self,
db: &dyn DefDatabase,
- local_scope: Option<&ItemScope>,
macro_call: ast::MacroCall,
) -> ExpandResult<Option<(Mark, T)>> {
if self.recursion_limit + 1 > EXPANSION_RECURSION_LIMIT {
let macro_call = InFile::new(self.current_file_id, ¯o_call);
- let resolver = |path: ModPath| -> Option<MacroDefId> {
- if let Some(local_scope) = local_scope {
- if let Some(def) = path.as_ident().and_then(|n| local_scope.get_legacy_macro(n)) {
- return Some(def);
- }
- }
- self.resolve_path_as_macro(db, &path)
- };
+ let resolver =
+ |path: ModPath| -> Option<MacroDefId> { self.resolve_path_as_macro(db, &path) };
let mut err = None;
let call_id =
- macro_call.as_call_id_with_errors(db, self.crate_def_map.krate(), resolver, &mut |e| {
+ macro_call.as_call_id_with_errors(db, self.def_map.krate(), resolver, &mut |e| {
err.get_or_insert(e);
});
let call_id = match call_id {
}
fn resolve_path_as_macro(&self, db: &dyn DefDatabase, path: &ModPath) -> Option<MacroDefId> {
- self.crate_def_map
+ self.def_map
.resolve_path(db, self.module.local_id, path, BuiltinShadowMode::Other)
.0
.take_macros()
/// The `ExprId` of the actual body expression.
pub body_expr: ExprId,
pub item_scope: ItemScope,
+ _c: Count<Self>,
}
pub type ExprPtr = AstPtr<ast::Expr>;