]> git.lizzy.rs Git - rust.git/commitdiff
Allow lints to check Bodys directly
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Tue, 7 Mar 2017 11:51:09 +0000 (12:51 +0100)
committerAlex Crichton <alex@alexcrichton.com>
Fri, 10 Mar 2017 16:24:43 +0000 (08:24 -0800)
src/librustc/lint/context.rs
src/librustc/lint/mod.rs

index 32bc81e947037afaef2030b2f9250f35dd6da22f..9279f24a57ab32d3892a5bd1b0ac54171efd69f5 100644 (file)
@@ -806,6 +806,12 @@ fn visit_nested_body(&mut self, body: hir::BodyId) {
         self.tables = old_tables;
     }
 
+    fn visit_body(&mut self, body: &'tcx hir::Body) {
+        run_lints!(self, check_body, late_passes, body);
+        hir_visit::walk_body(self, body);
+        run_lints!(self, check_body_post, late_passes, body);
+    }
+
     fn visit_item(&mut self, it: &'tcx hir::Item) {
         self.with_lint_attrs(&it.attrs, |cx| {
             run_lints!(cx, check_item, late_passes, it);
index e9f603db15d6214b538c29a71a5aa55454641997..e81d09773701cb7f3e5c90fe8f607bf0d89f844c 100644 (file)
@@ -133,6 +133,8 @@ pub trait LintPass {
 // FIXME: eliminate the duplication with `Visitor`. But this also
 // contains a few lint-specific methods with no equivalent in `Visitor`.
 pub trait LateLintPass<'a, 'tcx>: LintPass {
+    fn check_body(&mut self, _: &LateContext, _: &'tcx hir::Body) { }
+    fn check_body_post(&mut self, _: &LateContext, _: &'tcx hir::Body) { }
     fn check_name(&mut self, _: &LateContext, _: Span, _: ast::Name) { }
     fn check_crate(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Crate) { }
     fn check_crate_post(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx hir::Crate) { }