diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 61aaf068c1098..7d9ec29d70144 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -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, msg: &str) { let (level, src) = match self.lints.levels.find(&LintId::of(lint)) { None => return,