For various reasons I use a Visitor for the HIR tree traversal instead of
relying on the lint context to walk the tree. However, this means my lint
ignores #[allow/warn/deny(..)]
annotations in the source. How can I get this
back?
I know of ctxt.levels
, but those don't appear to help. The other functions
(like with_lint_attrs(..)
are private to the context.
Since there was no solution with the Rust we had, I created the necessary callbacks in Rustc: With tonight's nightly, our
LateLintPass
has anothercheck_block_post(..)
method. So we can pull the Visitor stuff into the lint, and add a new field of typeOption<&Block>
that is set in thecheck_block(..)
method and unset in thecheck_block_post(..)
if the field is equal the current block, thus ignoring all contained blocks.Edit: The code looks as follows: