From c92c183ed9c965c79df3592dffc4c23f3711815e Mon Sep 17 00:00:00 2001 From: jumbatm <30644300+jumbatm@users.noreply.github.com> Date: Tue, 4 Aug 2020 22:01:06 +1000 Subject: [PATCH 1/3] Deny clashing_extern_declarations by default. --- src/librustc_lint/builtin.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 6515708e115a5..2bf43b86c7c15 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -2067,7 +2067,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue { declare_lint! { pub CLASHING_EXTERN_DECLARATIONS, - Warn, + Deny, "detects when an extern fn has been declared with the same name but different types" } From c2db0de4290c8dc0802af8f3b290cd57c330dec8 Mon Sep 17 00:00:00 2001 From: jumbatm <30644300+jumbatm@users.noreply.github.com> Date: Wed, 5 Aug 2020 22:41:12 +1000 Subject: [PATCH 2/3] Fix test failure. --- src/test/ui/abi/foreign/auxiliary/foreign_lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/ui/abi/foreign/auxiliary/foreign_lib.rs b/src/test/ui/abi/foreign/auxiliary/foreign_lib.rs index de6b0e2118a58..1822822deb26c 100644 --- a/src/test/ui/abi/foreign/auxiliary/foreign_lib.rs +++ b/src/test/ui/abi/foreign/auxiliary/foreign_lib.rs @@ -25,6 +25,9 @@ pub mod rustrt3 { // importing the same symbol under different types. // See https://github.com/rust-lang/rust/issues/32740. extern { + // NOTE: Allow clashing decl here as we want this test case to catch ICE or LLVM assert + // failures if the lint has been allowed. + #[allow(clashing_extern_declarations)] pub fn rust_get_test_int() -> *const u8; } } From 40db56cd76ae38514151e8b6a7cac5a43e2fe8c0 Mon Sep 17 00:00:00 2001 From: jumbatm <30644300+jumbatm@users.noreply.github.com> Date: Wed, 5 Aug 2020 23:12:05 +1000 Subject: [PATCH 3/3] Move invoke extern test to dedupe foreign_lib.rs --- src/test/ui/abi/auxiliary/foreign_lib.rs | 38 ------------------- .../{ => foreign}/invoke-external-foreign.rs | 0 2 files changed, 38 deletions(-) delete mode 100644 src/test/ui/abi/auxiliary/foreign_lib.rs rename src/test/ui/abi/{ => foreign}/invoke-external-foreign.rs (100%) diff --git a/src/test/ui/abi/auxiliary/foreign_lib.rs b/src/test/ui/abi/auxiliary/foreign_lib.rs deleted file mode 100644 index de6b0e2118a58..0000000000000 --- a/src/test/ui/abi/auxiliary/foreign_lib.rs +++ /dev/null @@ -1,38 +0,0 @@ -#![crate_name="foreign_lib"] - -#![feature(rustc_private)] - -pub mod rustrt { - extern crate libc; - - #[link(name = "rust_test_helpers", kind = "static")] - extern { - pub fn rust_get_test_int() -> libc::intptr_t; - } -} - -pub mod rustrt2 { - extern crate libc; - - extern { - pub fn rust_get_test_int() -> libc::intptr_t; - } -} - -pub mod rustrt3 { - // Different type, but same ABI (on all supported platforms). - // Ensures that we don't ICE or trigger LLVM asserts when - // importing the same symbol under different types. - // See https://github.com/rust-lang/rust/issues/32740. - extern { - pub fn rust_get_test_int() -> *const u8; - } -} - -pub fn local_uses() { - unsafe { - let x = rustrt::rust_get_test_int(); - assert_eq!(x, rustrt2::rust_get_test_int()); - assert_eq!(x as *const _, rustrt3::rust_get_test_int()); - } -} diff --git a/src/test/ui/abi/invoke-external-foreign.rs b/src/test/ui/abi/foreign/invoke-external-foreign.rs similarity index 100% rename from src/test/ui/abi/invoke-external-foreign.rs rename to src/test/ui/abi/foreign/invoke-external-foreign.rs