use rustc_ast::token::{self, Token};
use rustc_ast::visit::{self, FnKind};
use rustc_expand::expand::AstFragment;
-use rustc_hir::def_id::DefIndex;
+use rustc_hir::def_id::LocalDefId;
use rustc_span::hygiene::ExpnId;
use rustc_span::symbol::{kw, sym};
use rustc_span::Span;
/// Creates `DefId`s for nodes in the AST.
struct DefCollector<'a> {
definitions: &'a mut Definitions,
- parent_def: DefIndex,
+ parent_def: LocalDefId,
expansion: ExpnId,
}
impl<'a> DefCollector<'a> {
- fn create_def(&mut self, node_id: NodeId, data: DefPathData, span: Span) -> DefIndex {
+ fn create_def(&mut self, node_id: NodeId, data: DefPathData, span: Span) -> LocalDefId {
let parent_def = self.parent_def;
debug!("create_def(node_id={:?}, data={:?}, parent_def={:?})", node_id, data, parent_def);
self.definitions.create_def_with_parent(parent_def, node_id, data, self.expansion, span)
}
- fn with_parent<F: FnOnce(&mut Self)>(&mut self, parent_def: DefIndex, f: F) {
+ fn with_parent<F: FnOnce(&mut Self)>(&mut self, parent_def: LocalDefId, f: F) {
let orig_parent_def = std::mem::replace(&mut self.parent_def, parent_def);
f(self);
self.parent_def = orig_parent_def;
DefPathData::ValueNs(i.ident.name)
}
ItemKind::MacroDef(..) => DefPathData::MacroNs(i.ident.name),
- ItemKind::Mac(..) => return self.visit_macro_invoc(i.id),
+ ItemKind::MacCall(..) => return self.visit_macro_invoc(i.id),
ItemKind::GlobalAsm(..) => DefPathData::Misc,
ItemKind::Use(..) => {
return visit::walk_item(self, i);
}
fn visit_foreign_item(&mut self, foreign_item: &'a ForeignItem) {
- if let ForeignItemKind::Macro(_) = foreign_item.kind {
+ if let ForeignItemKind::MacCall(_) = foreign_item.kind {
return self.visit_macro_invoc(foreign_item.id);
}
let def_data = match &i.kind {
AssocItemKind::Fn(..) | AssocItemKind::Const(..) => DefPathData::ValueNs(i.ident.name),
AssocItemKind::TyAlias(..) => DefPathData::TypeNs(i.ident.name),
- AssocItemKind::Macro(..) => return self.visit_macro_invoc(i.id),
+ AssocItemKind::MacCall(..) => return self.visit_macro_invoc(i.id),
};
let def = self.create_def(i.id, def_data, i.span);
fn visit_pat(&mut self, pat: &'a Pat) {
match pat.kind {
- PatKind::Mac(..) => return self.visit_macro_invoc(pat.id),
+ PatKind::MacCall(..) => return self.visit_macro_invoc(pat.id),
_ => visit::walk_pat(self, pat),
}
}
fn visit_expr(&mut self, expr: &'a Expr) {
let parent_def = match expr.kind {
- ExprKind::Mac(..) => return self.visit_macro_invoc(expr.id),
+ ExprKind::MacCall(..) => return self.visit_macro_invoc(expr.id),
ExprKind::Closure(_, asyncness, ..) => {
// Async closures desugar to closures inside of closures, so
// we must create two defs.
fn visit_ty(&mut self, ty: &'a Ty) {
match ty.kind {
- TyKind::Mac(..) => return self.visit_macro_invoc(ty.id),
+ TyKind::MacCall(..) => return self.visit_macro_invoc(ty.id),
TyKind::ImplTrait(node_id, _) => {
self.create_def(node_id, DefPathData::ImplTrait, ty.span);
}
fn visit_stmt(&mut self, stmt: &'a Stmt) {
match stmt.kind {
- StmtKind::Mac(..) => self.visit_macro_invoc(stmt.id),
+ StmtKind::MacCall(..) => self.visit_macro_invoc(stmt.id),
_ => visit::walk_stmt(self, stmt),
}
}
fn visit_token(&mut self, t: Token) {
if let token::Interpolated(nt) = t.kind {
if let token::NtExpr(ref expr) = *nt {
- if let ExprKind::Mac(..) = expr.kind {
+ if let ExprKind::MacCall(..) = expr.kind {
self.visit_macro_invoc(expr.id);
}
}