// The attribute around the whole FFI block works.
#[allow(improper_ctypes)]
extern {
// But this one on an individual FFI item doesn't.
#[allow(improper_ctypes)]
fn exit(_: &String);
}
The problem arises because the lint iterates over the children of ForeignMod (extern {...}):
|
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { |
|
let mut vis = ImproperCTypesVisitor { cx: cx }; |
|
if let hir::ItemKind::ForeignMod(ref nmod) = it.node { |
|
if nmod.abi != Abi::RustIntrinsic && nmod.abi != Abi::PlatformIntrinsic { |
|
for ni in &nmod.items { |
and it does so through
check_item, but only
check_foreign_item would be affected by attributes on the individual foreign
fn /
static /
type children of the
extern {...} block.
check_foreign_item could be used instead, with the small change that the
abi has to be obtained from
cx.tcx.hir.get_foreign_abi(ni.id), instead of
nmod's field (as
nmod would be gone).
cc @nikomatsakis @Manishearth
The problem arises because the lint iterates over the children of
ForeignMod(extern {...}):rust/src/librustc_lint/types.rs
Lines 788 to 792 in 2ddc0cb
and it does so through
check_item, but onlycheck_foreign_itemwould be affected by attributes on the individual foreignfn/static/typechildren of theextern {...}block.check_foreign_itemcould be used instead, with the small change that theabihas to be obtained fromcx.tcx.hir.get_foreign_abi(ni.id), instead ofnmod's field (asnmodwould be gone).cc @nikomatsakis @Manishearth