Add check_attribute

This commit is contained in:
Yuki Okushi 2019-01-09 20:53:33 +09:00
parent 0194bed710
commit 6a90f1414f

View File

@ -227,6 +227,12 @@ impl UnsafeCode {
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnsafeCode {
fn check_attribute(&mut self, cx: &LateContext, attr: &ast::Attribute) {
if attr.check_name("allow_internal_unsafe") {
self.report_unsafe(cx, attr.span, "`allow_internal_unsafe` allows defining macros using unsafe without triggering the `unsafe_code` lint at their call site");
}
}
fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) {
if let hir::ExprKind::Block(ref blk, _) = e.node {
// Don't warn about generated blocks, that'll just pollute the output.