Skip to content

Commit 5ddc7b4

Browse files
committed
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).
2 parents 4418664 + 46a3314 commit 5ddc7b4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/librustc/lint/context.rs

+6
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,12 @@ impl<'a> Context<'a> {
317317
&self.tcx.sess
318318
}
319319

320+
/// Get the level of `lint` at the current position of the lint
321+
/// traversal.
322+
pub fn current_level(&self, lint: &'static Lint) -> Level {
323+
self.lints.levels.find(&LintId::of(lint)).map_or(Allow, |&(lvl, _)| lvl)
324+
}
325+
320326
fn lookup_and_emit(&self, lint: &'static Lint, span: Option<Span>, msg: &str) {
321327
let (level, src) = match self.lints.levels.find(&LintId::of(lint)) {
322328
None => return,

0 commit comments

Comments
 (0)