Add checking for no_mangle to unsafe_code lint

This commit is contained in:
Wim Looman 2020-05-14 17:31:06 +02:00
parent 85fbf49ce0
commit 06a0269c11
3 changed files with 80 additions and 24 deletions

View file

@ -277,6 +277,22 @@ impl EarlyLintPass for UnsafeCode {
})
}
ast::ItemKind::Fn(..) => {
if attr::contains_name(&it.attrs, sym::no_mangle) {
self.report_unsafe(cx, it.span, |lint| {
lint.build("declaration of a `no_mangle` function").emit();
})
}
}
ast::ItemKind::Static(..) => {
if attr::contains_name(&it.attrs, sym::no_mangle) {
self.report_unsafe(cx, it.span, |lint| {
lint.build("declaration of a `no_mangle` static").emit();
})
}
}
_ => {}
}
}