mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
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).
This commit is contained in:
parent
32cb44bfff
commit
46a3314943
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user