use rustc_front::hir;
use rustc_front::hir::Pat;
-use rustc_front::visit::{self, Visitor, FnKind};
+use rustc_front::intravisit::{self, Visitor, FnKind};
use rustc_front::util as front_util;
use rustc_back::slice;
}
pub fn check_crate(tcx: &ty::ctxt) {
- visit::walk_crate(&mut MatchCheckCtxt {
+ tcx.map.krate().visit_all_items(&mut MatchCheckCtxt {
tcx: tcx,
param_env: tcx.empty_parameter_environment(),
- }, tcx.map.krate());
+ });
tcx.sess.abort_if_errors();
}
fn check_expr(cx: &mut MatchCheckCtxt, ex: &hir::Expr) {
- visit::walk_expr(cx, ex);
+ intravisit::walk_expr(cx, ex);
match ex.node {
hir::ExprMatch(ref scrut, ref arms, source) => {
for arm in arms {
let def = cx.tcx.def_map.borrow().get(&p.id).map(|d| d.full_def());
if let Some(DefLocal(..)) = def {
if edef.variants.iter().any(|variant|
- variant.name == ident.node.name
+ variant.name == ident.node.unhygienic_name
&& variant.kind() == VariantKind::Unit
) {
+ let ty_path = cx.tcx.item_path_str(edef.did);
span_warn!(cx.tcx.sess, p.span, E0170,
"pattern binding `{}` is named the same as one \
of the variants of the type `{}`",
- ident.node, pat_ty);
+ ident.node, ty_path);
fileline_help!(cx.tcx.sess, p.span,
"if you meant to match on a variant, \
consider making the path in the pattern qualified: `{}::{}`",
- pat_ty, ident.node);
+ ty_path, ident.node);
}
}
}
P(hir::Expr {
id: 0,
node: hir::ExprLit(P(Spanned { node: node, span: DUMMY_SP })),
- span: DUMMY_SP
+ span: DUMMY_SP,
+ attrs: None,
})
}
renaming_map: renaming_map,
};
- let mut id_visitor = front_util::IdVisitor {
- operation: &mut renaming_recorder,
- pass_through_items: true,
- visited_outermost: false,
- };
+ let mut id_visitor = front_util::IdVisitor::new(&mut renaming_recorder);
id_visitor.visit_expr(const_expr);
}
}
};
head.map(|mut head| {
- head.push_all(&r[..col]);
- head.push_all(&r[col + 1..]);
+ head.extend_from_slice(&r[..col]);
+ head.extend_from_slice(&r[col + 1..]);
head
})
}
fn check_local(cx: &mut MatchCheckCtxt, loc: &hir::Local) {
- visit::walk_local(cx, loc);
+ intravisit::walk_local(cx, loc);
let pat = StaticInliner::new(cx.tcx, None).fold_pat(loc.pat.clone());
check_irrefutable(cx, &pat, false);
_ => cx.param_env = ParameterEnvironment::for_item(cx.tcx, fn_id),
}
- visit::walk_fn(cx, kind, decl, body, sp);
+ intravisit::walk_fn(cx, kind, decl, body, sp);
for input in &decl.inputs {
check_irrefutable(cx, &input.pat, true);
hir::PatIdent(_, _, Some(_)) => {
let bindings_were_allowed = self.bindings_allowed;
self.bindings_allowed = false;
- visit::walk_pat(self, pat);
+ intravisit::walk_pat(self, pat);
self.bindings_allowed = bindings_were_allowed;
}
- _ => visit::walk_pat(self, pat),
+ _ => intravisit::walk_pat(self, pat),
}
}
}