提交 46a33149 编写于 作者: H Huon Wilson

lint: add method to get level of a specific lint.

This allows lint traversals to emit more information (when a lint is
non-allow), or avoid doing expensive computations (when a lint is
allow).
上级 32cb44bf
......@@ -317,6 +317,12 @@ pub fn sess(&'a self) -> &'a Session {
&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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册