Skip to content

Commit

Permalink
Rollup merge of rust-lang#40315 - oli-obk:lint_body, r=eddyb
Browse files Browse the repository at this point in the history
Allow lints to check Bodys directly

r? @eddyb

babysteps towards fixing https://github.com/Manishearth/rust-clippy/issues/1580 (disable certain lints in const environments, since they make no sense there (yet))
  • Loading branch information
Ariel Ben-Yehuda committed Mar 10, 2017
2 parents 78be7d2 + b959d13 commit cd8de69
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,12 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
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);
Expand Down
2 changes: 2 additions & 0 deletions src/librustc/lint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) { }
Expand Down

0 comments on commit cd8de69

Please sign in to comment.