Remove unused macro argument

This commit is contained in:
Oliver Schneider 2018-07-13 15:03:05 +02:00
parent c946c2539e
commit 22d21b1575
1 changed files with 80 additions and 80 deletions

View File

@ -395,7 +395,7 @@ pub struct EarlyContext<'a> {
}
/// Convenience macro for calling a `LintPass` method on every pass in the context.
macro_rules! run_lints { ($cx:expr, $f:ident, $ps:ident, $($args:expr),*) => ({
macro_rules! run_lints { ($cx:expr, $f:ident, $($args:expr),*) => ({
// Move the vector of passes out of `$cx` so that we can
// iterate over it mutably while passing `$cx` to the methods.
let mut passes = $cx.lint_sess_mut().passes.take().unwrap();
@ -558,12 +558,12 @@ impl<'a, 'tcx> LintContext<'tcx> for LateContext<'a, 'tcx> {
fn enter_attrs(&mut self, attrs: &'tcx [ast::Attribute]) {
debug!("late context: enter_attrs({:?})", attrs);
run_lints!(self, enter_lint_attrs, late_passes, attrs);
run_lints!(self, enter_lint_attrs, attrs);
}
fn exit_attrs(&mut self, attrs: &'tcx [ast::Attribute]) {
debug!("late context: exit_attrs({:?})", attrs);
run_lints!(self, exit_lint_attrs, late_passes, attrs);
run_lints!(self, exit_lint_attrs, attrs);
}
fn lookup<S: Into<MultiSpan>>(&self,
@ -615,12 +615,12 @@ impl<'a> LintContext<'a> for EarlyContext<'a> {
fn enter_attrs(&mut self, attrs: &'a [ast::Attribute]) {
debug!("early context: enter_attrs({:?})", attrs);
run_lints!(self, enter_lint_attrs, early_passes, attrs);
run_lints!(self, enter_lint_attrs, attrs);
}
fn exit_attrs(&mut self, attrs: &'a [ast::Attribute]) {
debug!("early context: exit_attrs({:?})", attrs);
run_lints!(self, exit_lint_attrs, early_passes, attrs);
run_lints!(self, exit_lint_attrs, attrs);
}
fn lookup<S: Into<MultiSpan>>(&self,
@ -686,9 +686,9 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
}
fn visit_body(&mut self, body: &'tcx hir::Body) {
run_lints!(self, check_body, late_passes, body);
run_lints!(self, check_body, body);
hir_visit::walk_body(self, body);
run_lints!(self, check_body_post, late_passes, body);
run_lints!(self, check_body_post, body);
}
fn visit_item(&mut self, it: &'tcx hir::Item) {
@ -696,9 +696,9 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
self.generics = it.node.generics();
self.with_lint_attrs(it.id, &it.attrs, |cx| {
cx.with_param_env(it.id, |cx| {
run_lints!(cx, check_item, late_passes, it);
run_lints!(cx, check_item, it);
hir_visit::walk_item(cx, it);
run_lints!(cx, check_item_post, late_passes, it);
run_lints!(cx, check_item_post, it);
});
});
self.generics = generics;
@ -707,23 +707,23 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
fn visit_foreign_item(&mut self, it: &'tcx hir::ForeignItem) {
self.with_lint_attrs(it.id, &it.attrs, |cx| {
cx.with_param_env(it.id, |cx| {
run_lints!(cx, check_foreign_item, late_passes, it);
run_lints!(cx, check_foreign_item, it);
hir_visit::walk_foreign_item(cx, it);
run_lints!(cx, check_foreign_item_post, late_passes, it);
run_lints!(cx, check_foreign_item_post, it);
});
})
}
fn visit_pat(&mut self, p: &'tcx hir::Pat) {
run_lints!(self, check_pat, late_passes, p);
run_lints!(self, check_pat, p);
hir_visit::walk_pat(self, p);
}
fn visit_expr(&mut self, e: &'tcx hir::Expr) {
self.with_lint_attrs(e.id, &e.attrs, |cx| {
run_lints!(cx, check_expr, late_passes, e);
run_lints!(cx, check_expr, e);
hir_visit::walk_expr(cx, e);
run_lints!(cx, check_expr_post, late_passes, e);
run_lints!(cx, check_expr_post, e);
})
}
@ -733,7 +733,7 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
// - local
// - expression
// so we keep track of lint levels there
run_lints!(self, check_stmt, late_passes, s);
run_lints!(self, check_stmt, s);
hir_visit::walk_stmt(self, s);
}
@ -744,9 +744,9 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
let old_tables = self.tables;
self.tables = self.tcx.body_tables(body_id);
let body = self.tcx.hir.body(body_id);
run_lints!(self, check_fn, late_passes, fk, decl, body, span, id);
run_lints!(self, check_fn, fk, decl, body, span, id);
hir_visit::walk_fn(self, fk, decl, body_id, span, id);
run_lints!(self, check_fn_post, late_passes, fk, decl, body, span, id);
run_lints!(self, check_fn_post, fk, decl, body, span, id);
self.tables = old_tables;
}
@ -756,14 +756,14 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
g: &'tcx hir::Generics,
item_id: ast::NodeId,
_: Span) {
run_lints!(self, check_struct_def, late_passes, s, name, g, item_id);
run_lints!(self, check_struct_def, s, name, g, item_id);
hir_visit::walk_struct_def(self, s);
run_lints!(self, check_struct_def_post, late_passes, s, name, g, item_id);
run_lints!(self, check_struct_def_post, s, name, g, item_id);
}
fn visit_struct_field(&mut self, s: &'tcx hir::StructField) {
self.with_lint_attrs(s.id, &s.attrs, |cx| {
run_lints!(cx, check_struct_field, late_passes, s);
run_lints!(cx, check_struct_field, s);
hir_visit::walk_struct_field(cx, s);
})
}
@ -773,68 +773,68 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
g: &'tcx hir::Generics,
item_id: ast::NodeId) {
self.with_lint_attrs(v.node.data.id(), &v.node.attrs, |cx| {
run_lints!(cx, check_variant, late_passes, v, g);
run_lints!(cx, check_variant, v, g);
hir_visit::walk_variant(cx, v, g, item_id);
run_lints!(cx, check_variant_post, late_passes, v, g);
run_lints!(cx, check_variant_post, v, g);
})
}
fn visit_ty(&mut self, t: &'tcx hir::Ty) {
run_lints!(self, check_ty, late_passes, t);
run_lints!(self, check_ty, t);
hir_visit::walk_ty(self, t);
}
fn visit_name(&mut self, sp: Span, name: ast::Name) {
run_lints!(self, check_name, late_passes, sp, name);
run_lints!(self, check_name, sp, name);
}
fn visit_mod(&mut self, m: &'tcx hir::Mod, s: Span, n: ast::NodeId) {
run_lints!(self, check_mod, late_passes, m, s, n);
run_lints!(self, check_mod, m, s, n);
hir_visit::walk_mod(self, m, n);
run_lints!(self, check_mod_post, late_passes, m, s, n);
run_lints!(self, check_mod_post, m, s, n);
}
fn visit_local(&mut self, l: &'tcx hir::Local) {
self.with_lint_attrs(l.id, &l.attrs, |cx| {
run_lints!(cx, check_local, late_passes, l);
run_lints!(cx, check_local, l);
hir_visit::walk_local(cx, l);
})
}
fn visit_block(&mut self, b: &'tcx hir::Block) {
run_lints!(self, check_block, late_passes, b);
run_lints!(self, check_block, b);
hir_visit::walk_block(self, b);
run_lints!(self, check_block_post, late_passes, b);
run_lints!(self, check_block_post, b);
}
fn visit_arm(&mut self, a: &'tcx hir::Arm) {
run_lints!(self, check_arm, late_passes, a);
run_lints!(self, check_arm, a);
hir_visit::walk_arm(self, a);
}
fn visit_decl(&mut self, d: &'tcx hir::Decl) {
run_lints!(self, check_decl, late_passes, d);
run_lints!(self, check_decl, d);
hir_visit::walk_decl(self, d);
}
fn visit_generic_param(&mut self, p: &'tcx hir::GenericParam) {
run_lints!(self, check_generic_param, late_passes, p);
run_lints!(self, check_generic_param, p);
hir_visit::walk_generic_param(self, p);
}
fn visit_generics(&mut self, g: &'tcx hir::Generics) {
run_lints!(self, check_generics, late_passes, g);
run_lints!(self, check_generics, g);
hir_visit::walk_generics(self, g);
}
fn visit_where_predicate(&mut self, p: &'tcx hir::WherePredicate) {
run_lints!(self, check_where_predicate, late_passes, p);
run_lints!(self, check_where_predicate, p);
hir_visit::walk_where_predicate(self, p);
}
fn visit_poly_trait_ref(&mut self, t: &'tcx hir::PolyTraitRef,
m: hir::TraitBoundModifier) {
run_lints!(self, check_poly_trait_ref, late_passes, t, m);
run_lints!(self, check_poly_trait_ref, t, m);
hir_visit::walk_poly_trait_ref(self, t, m);
}
@ -843,9 +843,9 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
self.generics = Some(&trait_item.generics);
self.with_lint_attrs(trait_item.id, &trait_item.attrs, |cx| {
cx.with_param_env(trait_item.id, |cx| {
run_lints!(cx, check_trait_item, late_passes, trait_item);
run_lints!(cx, check_trait_item, trait_item);
hir_visit::walk_trait_item(cx, trait_item);
run_lints!(cx, check_trait_item_post, late_passes, trait_item);
run_lints!(cx, check_trait_item_post, trait_item);
});
});
self.generics = generics;
@ -856,71 +856,71 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
self.generics = Some(&impl_item.generics);
self.with_lint_attrs(impl_item.id, &impl_item.attrs, |cx| {
cx.with_param_env(impl_item.id, |cx| {
run_lints!(cx, check_impl_item, late_passes, impl_item);
run_lints!(cx, check_impl_item, impl_item);
hir_visit::walk_impl_item(cx, impl_item);
run_lints!(cx, check_impl_item_post, late_passes, impl_item);
run_lints!(cx, check_impl_item_post, impl_item);
});
});
self.generics = generics;
}
fn visit_lifetime(&mut self, lt: &'tcx hir::Lifetime) {
run_lints!(self, check_lifetime, late_passes, lt);
run_lints!(self, check_lifetime, lt);
hir_visit::walk_lifetime(self, lt);
}
fn visit_path(&mut self, p: &'tcx hir::Path, id: ast::NodeId) {
run_lints!(self, check_path, late_passes, p, id);
run_lints!(self, check_path, p, id);
hir_visit::walk_path(self, p);
}
fn visit_attribute(&mut self, attr: &'tcx ast::Attribute) {
run_lints!(self, check_attribute, late_passes, attr);
run_lints!(self, check_attribute, attr);
}
}
impl<'a> ast_visit::Visitor<'a> for EarlyContext<'a> {
fn visit_item(&mut self, it: &'a ast::Item) {
self.with_lint_attrs(it.id, &it.attrs, |cx| {
run_lints!(cx, check_item, early_passes, it);
run_lints!(cx, check_item, it);
ast_visit::walk_item(cx, it);
run_lints!(cx, check_item_post, early_passes, it);
run_lints!(cx, check_item_post, it);
})
}
fn visit_foreign_item(&mut self, it: &'a ast::ForeignItem) {
self.with_lint_attrs(it.id, &it.attrs, |cx| {
run_lints!(cx, check_foreign_item, early_passes, it);
run_lints!(cx, check_foreign_item, it);
ast_visit::walk_foreign_item(cx, it);
run_lints!(cx, check_foreign_item_post, early_passes, it);
run_lints!(cx, check_foreign_item_post, it);
})
}
fn visit_pat(&mut self, p: &'a ast::Pat) {
run_lints!(self, check_pat, early_passes, p);
run_lints!(self, check_pat, p);
self.check_id(p.id);
ast_visit::walk_pat(self, p);
}
fn visit_expr(&mut self, e: &'a ast::Expr) {
self.with_lint_attrs(e.id, &e.attrs, |cx| {
run_lints!(cx, check_expr, early_passes, e);
run_lints!(cx, check_expr, e);
ast_visit::walk_expr(cx, e);
})
}
fn visit_stmt(&mut self, s: &'a ast::Stmt) {
run_lints!(self, check_stmt, early_passes, s);
run_lints!(self, check_stmt, s);
self.check_id(s.id);
ast_visit::walk_stmt(self, s);
}
fn visit_fn(&mut self, fk: ast_visit::FnKind<'a>, decl: &'a ast::FnDecl,
span: Span, id: ast::NodeId) {
run_lints!(self, check_fn, early_passes, fk, decl, span, id);
run_lints!(self, check_fn, fk, decl, span, id);
self.check_id(id);
ast_visit::walk_fn(self, fk, decl, span);
run_lints!(self, check_fn_post, early_passes, fk, decl, span, id);
run_lints!(self, check_fn_post, fk, decl, span, id);
}
fn visit_variant_data(&mut self,
@ -929,116 +929,116 @@ impl<'a> ast_visit::Visitor<'a> for EarlyContext<'a> {
g: &'a ast::Generics,
item_id: ast::NodeId,
_: Span) {
run_lints!(self, check_struct_def, early_passes, s, ident, g, item_id);
run_lints!(self, check_struct_def, s, ident, g, item_id);
self.check_id(s.id());
ast_visit::walk_struct_def(self, s);
run_lints!(self, check_struct_def_post, early_passes, s, ident, g, item_id);
run_lints!(self, check_struct_def_post, s, ident, g, item_id);
}
fn visit_struct_field(&mut self, s: &'a ast::StructField) {
self.with_lint_attrs(s.id, &s.attrs, |cx| {
run_lints!(cx, check_struct_field, early_passes, s);
run_lints!(cx, check_struct_field, s);
ast_visit::walk_struct_field(cx, s);
})
}
fn visit_variant(&mut self, v: &'a ast::Variant, g: &'a ast::Generics, item_id: ast::NodeId) {
self.with_lint_attrs(item_id, &v.node.attrs, |cx| {
run_lints!(cx, check_variant, early_passes, v, g);
run_lints!(cx, check_variant, v, g);
ast_visit::walk_variant(cx, v, g, item_id);
run_lints!(cx, check_variant_post, early_passes, v, g);
run_lints!(cx, check_variant_post, v, g);
})
}
fn visit_ty(&mut self, t: &'a ast::Ty) {
run_lints!(self, check_ty, early_passes, t);
run_lints!(self, check_ty, t);
self.check_id(t.id);
ast_visit::walk_ty(self, t);
}
fn visit_ident(&mut self, ident: ast::Ident) {
run_lints!(self, check_ident, early_passes, ident);
run_lints!(self, check_ident, ident);
}
fn visit_mod(&mut self, m: &'a ast::Mod, s: Span, _a: &[ast::Attribute], n: ast::NodeId) {
run_lints!(self, check_mod, early_passes, m, s, n);
run_lints!(self, check_mod, m, s, n);
self.check_id(n);
ast_visit::walk_mod(self, m);
run_lints!(self, check_mod_post, early_passes, m, s, n);
run_lints!(self, check_mod_post, m, s, n);
}
fn visit_local(&mut self, l: &'a ast::Local) {
self.with_lint_attrs(l.id, &l.attrs, |cx| {
run_lints!(cx, check_local, early_passes, l);
run_lints!(cx, check_local, l);
ast_visit::walk_local(cx, l);
})
}
fn visit_block(&mut self, b: &'a ast::Block) {
run_lints!(self, check_block, early_passes, b);
run_lints!(self, check_block, b);
self.check_id(b.id);
ast_visit::walk_block(self, b);
run_lints!(self, check_block_post, early_passes, b);
run_lints!(self, check_block_post, b);
}
fn visit_arm(&mut self, a: &'a ast::Arm) {
run_lints!(self, check_arm, early_passes, a);
run_lints!(self, check_arm, a);
ast_visit::walk_arm(self, a);
}
fn visit_expr_post(&mut self, e: &'a ast::Expr) {
run_lints!(self, check_expr_post, early_passes, e);
run_lints!(self, check_expr_post, e);
}
fn visit_generic_param(&mut self, param: &'a ast::GenericParam) {
run_lints!(self, check_generic_param, early_passes, param);
run_lints!(self, check_generic_param, param);
ast_visit::walk_generic_param(self, param);
}
fn visit_generics(&mut self, g: &'a ast::Generics) {
run_lints!(self, check_generics, early_passes, g);
run_lints!(self, check_generics, g);
ast_visit::walk_generics(self, g);
}
fn visit_where_predicate(&mut self, p: &'a ast::WherePredicate) {
run_lints!(self, check_where_predicate, early_passes, p);
run_lints!(self, check_where_predicate, p);
ast_visit::walk_where_predicate(self, p);
}
fn visit_poly_trait_ref(&mut self, t: &'a ast::PolyTraitRef, m: &'a ast::TraitBoundModifier) {
run_lints!(self, check_poly_trait_ref, early_passes, t, m);
run_lints!(self, check_poly_trait_ref, t, m);
ast_visit::walk_poly_trait_ref(self, t, m);
}
fn visit_trait_item(&mut self, trait_item: &'a ast::TraitItem) {
self.with_lint_attrs(trait_item.id, &trait_item.attrs, |cx| {
run_lints!(cx, check_trait_item, early_passes, trait_item);
run_lints!(cx, check_trait_item, trait_item);
ast_visit::walk_trait_item(cx, trait_item);
run_lints!(cx, check_trait_item_post, early_passes, trait_item);
run_lints!(cx, check_trait_item_post, trait_item);
});
}
fn visit_impl_item(&mut self, impl_item: &'a ast::ImplItem) {
self.with_lint_attrs(impl_item.id, &impl_item.attrs, |cx| {
run_lints!(cx, check_impl_item, early_passes, impl_item);
run_lints!(cx, check_impl_item, impl_item);
ast_visit::walk_impl_item(cx, impl_item);
run_lints!(cx, check_impl_item_post, early_passes, impl_item);
run_lints!(cx, check_impl_item_post, impl_item);
});
}
fn visit_lifetime(&mut self, lt: &'a ast::Lifetime) {
run_lints!(self, check_lifetime, early_passes, lt);
run_lints!(self, check_lifetime, lt);
self.check_id(lt.id);
}
fn visit_path(&mut self, p: &'a ast::Path, id: ast::NodeId) {
run_lints!(self, check_path, early_passes, p, id);
run_lints!(self, check_path, p, id);
self.check_id(id);
ast_visit::walk_path(self, p);
}
fn visit_attribute(&mut self, attr: &'a ast::Attribute) {
run_lints!(self, check_attribute, early_passes, attr);
run_lints!(self, check_attribute, attr);
}
fn visit_mac_def(&mut self, _mac: &'a ast::MacroDef, id: ast::NodeId) {
@ -1069,11 +1069,11 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
cx.with_lint_attrs(ast::CRATE_NODE_ID, &krate.attrs, |cx| {
// since the root module isn't visited as an item (because it isn't an
// item), warn for it here.
run_lints!(cx, check_crate, late_passes, krate);
run_lints!(cx, check_crate, krate);
hir_visit::walk_crate(cx, krate);
run_lints!(cx, check_crate_post, late_passes, krate);
run_lints!(cx, check_crate_post, krate);
});
// Put the lint store levels and passes back in the session.
@ -1087,11 +1087,11 @@ pub fn check_ast_crate(sess: &Session, krate: &ast::Crate) {
cx.with_lint_attrs(ast::CRATE_NODE_ID, &krate.attrs, |cx| {
// since the root module isn't visited as an item (because it isn't an
// item), warn for it here.
run_lints!(cx, check_crate, early_passes, krate);
run_lints!(cx, check_crate, krate);
ast_visit::walk_crate(cx, krate);
run_lints!(cx, check_crate_post, early_passes, krate);
run_lints!(cx, check_crate_post, krate);
});
// Put the lint store levels and passes back in the session.