auto merge of #15737 : huonw/rust/lint-level-here, r=pnkfelix

This allows lint traversals to emit more information (when a lint is
non-allow), or avoid doing expensive computations (when a lint is
allow).
This commit is contained in:
bors 2014-07-18 13:31:22 +00:00
commit 5ddc7b4a25

View File

@ -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,