about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-06-21 02:20:07 +0000
committerbors <bors@rust-lang.org>2020-06-21 02:20:07 +0000
commit228a0ed7b0cef2fbfeb781acf6c23015ccc40ba2 (patch)
treecf060cf92c6f6b8c9ca560cc62f1a78e618c58fe /src/libcore
parent7058471adec80a2a1e6092443e08546768c9c894 (diff)
parent556b7baca2cd45a78b1a9a762b4bf66b69747e53 (diff)
downloadrust-228a0ed7b0cef2fbfeb781acf6c23015ccc40ba2.tar.gz
rust-228a0ed7b0cef2fbfeb781acf6c23015ccc40ba2.zip
Auto merge of #70946 - jumbatm:clashing-extern-decl, r=nagisa
Add a lint to catch clashing `extern` fn declarations.

Closes #69390.

Adds lint `clashing_extern_decl` to detect when, within a single crate, an extern function of the same name is declared with different types. Because two symbols of the same name cannot be resolved to two different functions at link time, and one function cannot possibly have two types, a clashing extern declaration is almost certainly a mistake.

This lint does not run between crates because a project may have dependencies which both rely on the same extern function, but declare it in a different (but valid) way. For example, they may both declare an opaque type for one or more of the arguments (which would end up distinct types), or use types that are valid conversions in the language the extern fn is defined in. In these cases, we can't say that the clashing declaration is incorrect.

r? @eddyb
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/lib.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs
index fe05e914e6d..0115c4df2fd 100644
--- a/src/libcore/lib.rs
+++ b/src/libcore/lib.rs
@@ -277,6 +277,9 @@ pub mod primitive;
 // crate uses the this crate as its libcore.
 #[path = "../stdarch/crates/core_arch/src/mod.rs"]
 #[allow(missing_docs, missing_debug_implementations, dead_code, unused_imports)]
+// FIXME: This annotation should be moved into rust-lang/stdarch after clashing_extern_decl is
+// merged. It currently cannot because bootstrap fails as the lint hasn't been defined yet.
+#[cfg_attr(not(bootstrap), allow(clashing_extern_decl))]
 #[unstable(feature = "stdsimd", issue = "48556")]
 mod core_arch;