Skip to content

Commit

Permalink
auto merge of #15737 : huonw/rust/lint-level-here, r=pnkfelix
Browse files Browse the repository at this point in the history
This allows lint traversals to emit more information (when a lint is
non-allow), or avoid doing expensive computations (when a lint is
allow).
  • Loading branch information
bors committed Jul 18, 2014
2 parents 4418664 + 46a3314 commit 5ddc7b4
Showing 1 changed file with 6 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 @@ -317,6 +317,12 @@ impl<'a> Context<'a> {
&self.tcx.sess
}

/// Get the level of `lint` at the current position of the lint
/// traversal.
pub fn current_level(&self, lint: &'static Lint) -> Level {
self.lints.levels.find(&LintId::of(lint)).map_or(Allow, |&(lvl, _)| lvl)
}

fn lookup_and_emit(&self, lint: &'static Lint, span: Option<Span>, msg: &str) {
let (level, src) = match self.lints.levels.find(&LintId::of(lint)) {
None => return,
Expand Down

0 comments on commit 5ddc7b4

Please sign in to comment.