Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement check_attribute to forbid #[allow_internal_unsafe] #57467

Merged
merged 10 commits into from Jan 15, 2019
8 changes: 8 additions & 0 deletions src/librustc_lint/builtin.rs
Expand Up @@ -227,6 +227,14 @@ 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 \
JohnTitor marked this conversation as resolved.
Show resolved Hide resolved
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.
Expand Down