/// Each method of the Visitor trait is a hook to be potentially
/// overridden. Each method's default implementation recursively visits
/// the substructure of the input via the corresponding `walk` method;
-/// e.g. the `visit_mod` method by default calls `visit::walk_mod`.
+/// e.g., the `visit_mod` method by default calls `visit::walk_mod`.
///
/// If you want to ensure that your code handles every variant
/// explicitly, you need to override each method. (And you also need
}
fn visit_mac(&mut self, _mac: &'ast Mac) {
panic!("visit_mac disabled by default");
- // NB: see note about macros above.
+ // N.B., see note about macros above.
// if you really want a visitor that
// works on macros, use this
// definition in your trait impl:
pub fn walk_arm<'a, V: Visitor<'a>>(visitor: &mut V, arm: &'a 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);
}