diff options
| author | bors <bors@rust-lang.org> | 2018-08-09 01:38:13 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-08-09 01:38:13 +0000 |
| commit | 76b69a604ee0d70be1edfa2828c769dc1b148d13 (patch) | |
| tree | 2693a589676758c1ff15b3741be2964ee95f35e5 | |
| parent | 80caa7f9f46097d5442d525aea29a435d5daa328 (diff) | |
| parent | 70cafecaba233037bd5df5259140c3167941e70c (diff) | |
| download | rust-76b69a604ee0d70be1edfa2828c769dc1b148d13.tar.gz rust-76b69a604ee0d70be1edfa2828c769dc1b148d13.zip | |
Auto merge of #53100 - VPashkov:issue-52456-improper_ctypes, r=eddyb
Fix improper_ctypes lint for individual foreign items Fixes #52456. r? @eddyb
| -rw-r--r-- | src/librustc_lint/types.rs | 23 | ||||
| -rw-r--r-- | src/test/ui/lint-ctypes.rs | 7 |
2 files changed, 17 insertions, 13 deletions
diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 4dc66fb8121..f1636c4dcb0 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -790,21 +790,18 @@ impl LintPass for ImproperCTypes { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImproperCTypes { - fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { + fn check_foreign_item(&mut self, cx: &LateContext, it: &hir::ForeignItem) { 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 { - match ni.node { - hir::ForeignItemKind::Fn(ref decl, _, _) => { - vis.check_foreign_fn(ni.id, decl); - } - hir::ForeignItemKind::Static(ref ty, _) => { - vis.check_foreign_static(ni.id, ty.span); - } - hir::ForeignItemKind::Type => () - } + let abi = cx.tcx.hir.get_foreign_abi(it.id); + if abi != Abi::RustIntrinsic && abi != Abi::PlatformIntrinsic { + match it.node { + hir::ForeignItemKind::Fn(ref decl, _, _) => { + vis.check_foreign_fn(it.id, decl); + } + hir::ForeignItemKind::Static(ref ty, _) => { + vis.check_foreign_static(it.id, ty.span); } + hir::ForeignItemKind::Type => () } } } diff --git a/src/test/ui/lint-ctypes.rs b/src/test/ui/lint-ctypes.rs index 7f22dc8739e..b8b1a675c5f 100644 --- a/src/test/ui/lint-ctypes.rs +++ b/src/test/ui/lint-ctypes.rs @@ -88,6 +88,13 @@ extern { pub fn good15(p: TransparentLifetime); pub fn good16(p: TransparentUnit<ZeroSize>); pub fn good17(p: TransparentCustomZst); + #[allow(improper_ctypes)] + pub fn good18(_: &String); +} + +#[allow(improper_ctypes)] +extern { + pub fn good19(_: &String); } #[cfg(not(target_arch = "wasm32"))] |
