Skip to content

Commit 501fc2d

Browse files
committed
Lint passes: add check_where_predicate and check_poly_trait_ref
1 parent 1ad094d commit 501fc2d

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

Diff for: src/librustc/lint/context.rs

+21
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,17 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
793793
hir_visit::walk_generics(self, g);
794794
}
795795

796+
fn visit_where_predicate(&mut self, p: &'tcx hir::WherePredicate) {
797+
run_lints!(self, check_where_predicate, late_passes, p);
798+
hir_visit::walk_where_predicate(self, p);
799+
}
800+
801+
fn visit_poly_trait_ref(&mut self, t: &'tcx hir::PolyTraitRef,
802+
m: hir::TraitBoundModifier) {
803+
run_lints!(self, check_poly_trait_ref, late_passes, t, m);
804+
hir_visit::walk_poly_trait_ref(self, t, m);
805+
}
806+
796807
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
797808
let generics = self.generics.take();
798809
self.generics = Some(&trait_item.generics);
@@ -955,6 +966,16 @@ impl<'a> ast_visit::Visitor<'a> for EarlyContext<'a> {
955966
ast_visit::walk_generics(self, g);
956967
}
957968

969+
fn visit_where_predicate(&mut self, p: &'a ast::WherePredicate) {
970+
run_lints!(self, check_where_predicate, early_passes, p);
971+
ast_visit::walk_where_predicate(self, p);
972+
}
973+
974+
fn visit_poly_trait_ref(&mut self, t: &'a ast::PolyTraitRef, m: &'a ast::TraitBoundModifier) {
975+
run_lints!(self, check_poly_trait_ref, early_passes, t, m);
976+
ast_visit::walk_poly_trait_ref(self, t, m);
977+
}
978+
958979
fn visit_trait_item(&mut self, trait_item: &'a ast::TraitItem) {
959980
self.with_lint_attrs(trait_item.id, &trait_item.attrs, |cx| {
960981
run_lints!(cx, check_trait_item, early_passes, trait_item);

Diff for: src/librustc/lint/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ pub trait LateLintPass<'a, 'tcx>: LintPass {
158158
fn check_ty(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Ty) { }
159159
fn check_generic_param(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::GenericParam) { }
160160
fn check_generics(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Generics) { }
161+
fn check_where_predicate(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::WherePredicate) { }
162+
fn check_poly_trait_ref(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::PolyTraitRef,
163+
_: hir::TraitBoundModifier) { }
161164
fn check_fn(&mut self,
162165
_: &LateContext<'a, 'tcx>,
163166
_: FnKind<'tcx>,
@@ -230,6 +233,9 @@ pub trait EarlyLintPass: LintPass {
230233
fn check_ty(&mut self, _: &EarlyContext, _: &ast::Ty) { }
231234
fn check_generic_param(&mut self, _: &EarlyContext, _: &ast::GenericParam) { }
232235
fn check_generics(&mut self, _: &EarlyContext, _: &ast::Generics) { }
236+
fn check_where_predicate(&mut self, _: &EarlyContext, _: &ast::WherePredicate) { }
237+
fn check_poly_trait_ref(&mut self, _: &EarlyContext, _: &ast::PolyTraitRef,
238+
_: &ast::TraitBoundModifier) { }
233239
fn check_fn(&mut self, _: &EarlyContext,
234240
_: ast_visit::FnKind, _: &ast::FnDecl, _: Span, _: ast::NodeId) { }
235241
fn check_fn_post(&mut self, _: &EarlyContext,

0 commit comments

Comments
 (0)