Skip to content

Commit

Permalink
Lint passes: add check_where_predicate and check_poly_trait_ref
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Feb 27, 2018
1 parent 29f5c69 commit d1ed6cc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/librustc/lint/context.rs
Expand Up @@ -793,6 +793,17 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
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);
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);
hir_visit::walk_poly_trait_ref(self, t, m);
}

fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
let generics = self.generics.take();
self.generics = Some(&trait_item.generics);
Expand Down Expand Up @@ -955,6 +966,16 @@ impl<'a> ast_visit::Visitor<'a> for EarlyContext<'a> {
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);
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);
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);
Expand Down
6 changes: 6 additions & 0 deletions src/librustc/lint/mod.rs
Expand Up @@ -158,6 +158,9 @@ pub trait LateLintPass<'a, 'tcx>: LintPass {
fn check_ty(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Ty) { }
fn check_generic_param(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::GenericParam) { }
fn check_generics(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Generics) { }
fn check_where_predicate(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::WherePredicate) { }
fn check_poly_trait_ref(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::PolyTraitRef,
_: hir::TraitBoundModifier) { }
fn check_fn(&mut self,
_: &LateContext<'a, 'tcx>,
_: FnKind<'tcx>,
Expand Down Expand Up @@ -230,6 +233,9 @@ pub trait EarlyLintPass: LintPass {
fn check_ty(&mut self, _: &EarlyContext, _: &ast::Ty) { }
fn check_generic_param(&mut self, _: &EarlyContext, _: &ast::GenericParam) { }
fn check_generics(&mut self, _: &EarlyContext, _: &ast::Generics) { }
fn check_where_predicate(&mut self, _: &EarlyContext, _: &ast::WherePredicate) { }
fn check_poly_trait_ref(&mut self, _: &EarlyContext, _: &ast::PolyTraitRef,
_: &ast::TraitBoundModifier) { }
fn check_fn(&mut self, _: &EarlyContext,
_: ast_visit::FnKind, _: &ast::FnDecl, _: Span, _: ast::NodeId) { }
fn check_fn_post(&mut self, _: &EarlyContext,
Expand Down

0 comments on commit d1ed6cc

Please sign in to comment.