use std::cmp;
use std::u32;
-use std::result::Result::Err;
#[derive(Copy, Clone)]
pub enum FnKind<'a> {
fn visit_lifetime(&mut self, lifetime: &'v Lifetime) {
walk_lifetime(self, lifetime)
}
- fn visit_qpath(&mut self, qpath: &'v QPath, id: NodeId, span: Span) {
+ fn visit_qpath(&mut self, qpath: &'v QPath, id: HirId, span: Span) {
walk_qpath(self, qpath, id, span)
}
- fn visit_path(&mut self, path: &'v Path, _id: NodeId) {
+ fn visit_path(&mut self, path: &'v Path, _id: HirId) {
walk_path(self, path)
}
fn visit_path_segment(&mut self, path_span: Span, path_segment: &'v PathSegment) {
where V: Visitor<'v>
{
visitor.visit_id(trait_ref.ref_id);
- visitor.visit_path(&trait_ref.path, trait_ref.ref_id)
+ visitor.visit_path(&trait_ref.path, trait_ref.hir_ref_id)
}
pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
}
ItemKind::Use(ref path, _) => {
visitor.visit_id(item.id);
- visitor.visit_path(path, item.id);
+ visitor.visit_path(path, item.hir_id);
}
ItemKind::Static(ref typ, _, body) |
ItemKind::Const(ref typ, body) => {
visitor.visit_fn_decl(&function_declaration.decl);
}
TyKind::Path(ref qpath) => {
- visitor.visit_qpath(qpath, typ.id, typ.span);
+ visitor.visit_qpath(qpath, typ.hir_id, typ.span);
}
TyKind::Array(ref ty, ref length) => {
visitor.visit_ty(ty);
}
}
-pub fn walk_qpath<'v, V: Visitor<'v>>(visitor: &mut V, qpath: &'v QPath, id: NodeId, span: Span) {
+pub fn walk_qpath<'v, V: Visitor<'v>>(visitor: &mut V, qpath: &'v QPath, id: HirId, span: Span) {
match *qpath {
QPath::Resolved(ref maybe_qself, ref path) => {
if let Some(ref qself) = *maybe_qself {
visitor.visit_id(pattern.id);
match pattern.node {
PatKind::TupleStruct(ref qpath, ref children, _) => {
- visitor.visit_qpath(qpath, pattern.id, pattern.span);
+ visitor.visit_qpath(qpath, pattern.hir_id, pattern.span);
walk_list!(visitor, visit_pat, children);
}
PatKind::Path(ref qpath) => {
- visitor.visit_qpath(qpath, pattern.id, pattern.span);
+ visitor.visit_qpath(qpath, pattern.hir_id, pattern.span);
}
PatKind::Struct(ref qpath, ref fields, _) => {
- visitor.visit_qpath(qpath, pattern.id, pattern.span);
+ visitor.visit_qpath(qpath, pattern.hir_id, pattern.span);
for field in fields {
visitor.visit_id(field.node.id);
visitor.visit_ident(field.node.ident);
visitor.visit_anon_const(count)
}
ExprKind::Struct(ref qpath, ref fields, ref optional_base) => {
- visitor.visit_qpath(qpath, expression.id, expression.span);
+ visitor.visit_qpath(qpath, expression.hir_id, expression.span);
for field in fields {
visitor.visit_id(field.id);
visitor.visit_ident(field.ident);
visitor.visit_expr(index_expression)
}
ExprKind::Path(ref qpath) => {
- visitor.visit_qpath(qpath, expression.id, expression.span);
+ visitor.visit_qpath(qpath, expression.hir_id, expression.span);
}
ExprKind::Break(ref destination, ref opt_expr) => {
if let Some(ref label) = destination.label {
visitor.visit_label(label);
- match destination.target_id {
- Ok(node_id) => visitor.visit_def_mention(Def::Label(node_id)),
- Err(_) => {},
- };
+ if let Ok(node_id) = destination.target_id {
+ visitor.visit_def_mention(Def::Label(node_id))
+ }
}
walk_list!(visitor, visit_expr, opt_expr);
}
ExprKind::Continue(ref destination) => {
if let Some(ref label) = destination.label {
visitor.visit_label(label);
- match destination.target_id {
- Ok(node_id) => visitor.visit_def_mention(Def::Label(node_id)),
- Err(_) => {},
- };
+ if let Ok(node_id) = destination.target_id {
+ visitor.visit_def_mention(Def::Label(node_id))
+ }
}
}
ExprKind::Ret(ref optional_expression) => {
walk_list!(visitor, visit_expr, optional_expression);
}
ExprKind::InlineAsm(_, ref outputs, ref inputs) => {
- for output in outputs {
- visitor.visit_expr(output)
- }
- for input in inputs {
- visitor.visit_expr(input)
+ for expr in outputs.iter().chain(inputs.iter()) {
+ visitor.visit_expr(expr)
}
}
ExprKind::Yield(ref subexpression) => {
pub fn walk_arm<'v, V: Visitor<'v>>(visitor: &mut V, arm: &'v Arm) {
walk_list!(visitor, visit_pat, &arm.pats);
- walk_list!(visitor, visit_expr, &arm.guard);
+ if let Some(ref g) = arm.guard {
+ match g {
+ Guard::If(ref e) => visitor.visit_expr(e),
+ }
+ }
visitor.visit_expr(&arm.body);
walk_list!(visitor, visit_attribute, &arm.attrs);
}
pub fn walk_vis<'v, V: Visitor<'v>>(visitor: &mut V, vis: &'v Visibility) {
- if let VisibilityKind::Restricted { ref path, id } = vis.node {
+ if let VisibilityKind::Restricted { ref path, id, hir_id } = vis.node {
visitor.visit_id(id);
- visitor.visit_path(path, id)
+ visitor.visit_path(path, hir_id)
}
}
self.min = cmp::min(self.min, id);
self.max = cmp::max(self.max, NodeId::from_u32(id.as_u32() + 1));
}
-
}