this.insert(struct_def.id(), NodeStructCtor(struct_def));
}
}
- ItemTrait(.., ref bounds, _) => {
- for b in bounds.iter() {
- if let TraitTyParamBound(ref t, TraitBoundModifier::None) = *b {
- this.insert(t.trait_ref.ref_id, NodeItem(i));
- }
- }
- }
ItemUse(ref view_path) => {
match view_path.node {
ViewPathList(_, ref paths) => {
});
}
+ fn visit_trait_ref(&mut self, tr: &'ast TraitRef) {
+ self.insert(tr.ref_id, NodeTraitRef(tr));
+
+ self.with_parent(tr.ref_id, |this| {
+ intravisit::walk_trait_ref(this, tr);
+ });
+ }
+
fn visit_fn(&mut self, fk: intravisit::FnKind<'ast>, fd: &'ast FnDecl,
b: &'ast Expr, s: Span, id: NodeId) {
assert_eq!(self.parent_node, id);
self.insert(lifetime.id, NodeLifetime(lifetime));
}
+ fn visit_vis(&mut self, visibility: &'ast Visibility) {
+ match *visibility {
+ Visibility::Public |
+ Visibility::Crate |
+ Visibility::Inherited => {}
+ Visibility::Restricted { id, .. } => {
+ self.insert(id, NodeVisibility(visibility));
+ self.with_parent(id, |this| {
+ intravisit::walk_vis(this, visibility);
+ });
+ }
+ }
+ }
+
fn visit_macro_def(&mut self, macro_def: &'ast MacroDef) {
self.insert_entry(macro_def.id, NotPresent);
}
NodeExpr(&'ast Expr),
NodeStmt(&'ast Stmt),
NodeTy(&'ast Ty),
+ NodeTraitRef(&'ast TraitRef),
NodeLocal(&'ast Pat),
NodePat(&'ast Pat),
NodeBlock(&'ast Block),
NodeStructCtor(&'ast VariantData),
NodeLifetime(&'ast Lifetime),
- NodeTyParam(&'ast TyParam)
+ NodeTyParam(&'ast TyParam),
+ NodeVisibility(&'ast Visibility),
}
/// Represents an entry and its parent NodeID.
EntryExpr(NodeId, &'ast Expr),
EntryStmt(NodeId, &'ast Stmt),
EntryTy(NodeId, &'ast Ty),
+ EntryTraitRef(NodeId, &'ast TraitRef),
EntryLocal(NodeId, &'ast Pat),
EntryPat(NodeId, &'ast Pat),
EntryBlock(NodeId, &'ast Block),
EntryStructCtor(NodeId, &'ast VariantData),
EntryLifetime(NodeId, &'ast Lifetime),
EntryTyParam(NodeId, &'ast TyParam),
+ EntryVisibility(NodeId, &'ast Visibility),
/// Roots for node trees.
RootCrate,
NodeExpr(n) => EntryExpr(p, n),
NodeStmt(n) => EntryStmt(p, n),
NodeTy(n) => EntryTy(p, n),
+ NodeTraitRef(n) => EntryTraitRef(p, n),
NodeLocal(n) => EntryLocal(p, n),
NodePat(n) => EntryPat(p, n),
NodeBlock(n) => EntryBlock(p, n),
NodeStructCtor(n) => EntryStructCtor(p, n),
NodeLifetime(n) => EntryLifetime(p, n),
NodeTyParam(n) => EntryTyParam(p, n),
+ NodeVisibility(n) => EntryVisibility(p, n),
}
}
EntryExpr(id, _) => id,
EntryStmt(id, _) => id,
EntryTy(id, _) => id,
+ EntryTraitRef(id, _) => id,
EntryLocal(id, _) => id,
EntryPat(id, _) => id,
EntryBlock(id, _) => id,
EntryStructCtor(id, _) => id,
EntryLifetime(id, _) => id,
EntryTyParam(id, _) => id,
+ EntryVisibility(id, _) => id,
NotPresent |
RootCrate |
EntryExpr(_, n) => NodeExpr(n),
EntryStmt(_, n) => NodeStmt(n),
EntryTy(_, n) => NodeTy(n),
+ EntryTraitRef(_, n) => NodeTraitRef(n),
EntryLocal(_, n) => NodeLocal(n),
EntryPat(_, n) => NodePat(n),
EntryBlock(_, n) => NodeBlock(n),
EntryStructCtor(_, n) => NodeStructCtor(n),
EntryLifetime(_, n) => NodeLifetime(n),
EntryTyParam(_, n) => NodeTyParam(n),
+ EntryVisibility(_, n) => NodeVisibility(n),
_ => return None
})
}
EntryExpr(p, _) |
EntryStmt(p, _) |
EntryTy(p, _) |
+ EntryTraitRef(p, _) |
EntryLocal(p, _) |
EntryPat(p, _) |
EntryBlock(p, _) |
EntryStructCtor(p, _) |
EntryLifetime(p, _) |
- EntryTyParam(p, _) =>
+ EntryTyParam(p, _) |
+ EntryVisibility(p, _) =>
id = p,
RootCrate =>
EntryExpr(p, _) |
EntryStmt(p, _) |
EntryTy(p, _) |
+ EntryTraitRef(p, _) |
EntryLocal(p, _) |
EntryPat(p, _) |
EntryBlock(p, _) |
EntryStructCtor(p, _) |
EntryLifetime(p, _) |
- EntryTyParam(p, _) =>
+ EntryTyParam(p, _) |
+ EntryVisibility(p, _) =>
id = p,
RootInlinedParent(parent) => match *parent {
Some(NodeExpr(expr)) => expr.span,
Some(NodeStmt(stmt)) => stmt.span,
Some(NodeTy(ty)) => ty.span,
+ Some(NodeTraitRef(tr)) => tr.path.span,
Some(NodeLocal(pat)) => pat.span,
Some(NodePat(pat)) => pat.span,
Some(NodeBlock(block)) => block.span,
Some(NodeStructCtor(_)) => self.expect_item(self.get_parent(id)).span,
Some(NodeTyParam(ty_param)) => ty_param.span,
+ Some(NodeVisibility(&Visibility::Restricted { ref path, .. })) => path.span,
_ => return None,
};
Some(sp)
NodeExpr(a) => self.print_expr(&a),
NodeStmt(a) => self.print_stmt(&a),
NodeTy(a) => self.print_type(&a),
+ NodeTraitRef(a) => self.print_trait_ref(&a),
NodePat(a) => self.print_pat(&a),
NodeBlock(a) => self.print_block(&a),
NodeLifetime(a) => self.print_lifetime(&a),
+ NodeVisibility(a) => self.print_visibility(&a),
NodeTyParam(_) => bug!("cannot print TyParam"),
// these cases do not carry enough information in the
// ast_map to reconstruct their full structure for pretty
Some(NodeTy(ref ty)) => {
format!("type {}{}", pprust::ty_to_string(&ty), id_str)
}
+ Some(NodeTraitRef(ref tr)) => {
+ format!("trait_ref {}{}", pprust::path_to_string(&tr.path), id_str)
+ }
Some(NodeLocal(ref pat)) => {
format!("local {}{}", pprust::pat_to_string(&pat), id_str)
}
Some(NodeTyParam(ref ty_param)) => {
format!("typaram {:?}{}", ty_param, id_str)
}
+ Some(NodeVisibility(ref vis)) => {
+ format!("visibility {:?}{}", vis, id_str)
+ }
None => {
format!("unknown node{}", id_str)
}