]> git.lizzy.rs Git - rust.git/commitdiff
Add check_attribute
authorYuki Okushi <huyuumi.dev@gmail.com>
Wed, 9 Jan 2019 11:53:33 +0000 (20:53 +0900)
committerYuki Okushi <huyuumi.dev@gmail.com>
Wed, 9 Jan 2019 11:53:33 +0000 (20:53 +0900)
src/librustc_lint/builtin.rs

index a555b7790971f5426fd89147268cd8b0a6d1295b..f41954f56500e3828dd0e0b3f174a4503de92e99 100644 (file)
@@ -227,6 +227,12 @@ fn report_unsafe(&self, cx: &LateContext, span: Span, desc: &'static str) {
 }
 
 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.