summaryrefslogtreecommitdiffstats
path: root/tests/incremental/hashes/extern_mods.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/incremental/hashes/extern_mods.rs
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/incremental/hashes/extern_mods.rs')
-rw-r--r--tests/incremental/hashes/extern_mods.rs221
1 files changed, 221 insertions, 0 deletions
diff --git a/tests/incremental/hashes/extern_mods.rs b/tests/incremental/hashes/extern_mods.rs
new file mode 100644
index 000000000..1906843c7
--- /dev/null
+++ b/tests/incremental/hashes/extern_mods.rs
@@ -0,0 +1,221 @@
+// This test case tests the incremental compilation hash (ICH) implementation
+// for `extern` modules.
+
+// The general pattern followed here is: Change one thing between rev1 and rev2
+// and make sure that the hash has changed, then change nothing between rev2 and
+// rev3 and make sure that the hash has not changed.
+
+// build-pass (FIXME(62277): could be check-pass?)
+// revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6
+// compile-flags: -Z query-dep-graph -O
+// [cfail1]compile-flags: -Zincremental-ignore-spans
+// [cfail2]compile-flags: -Zincremental-ignore-spans
+// [cfail3]compile-flags: -Zincremental-ignore-spans
+
+#![allow(warnings)]
+#![feature(rustc_attrs)]
+#![feature(unboxed_closures)]
+#![crate_type = "rlib"]
+
+// Change function name --------------------------------------------------------
+#[cfg(any(cfail1,cfail4))]
+extern "C" {
+ pub fn change_function_name1(c: i64) -> i32;
+}
+
+#[cfg(not(any(cfail1,cfail4)))]
+#[rustc_clean(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")]
+#[rustc_clean(cfg = "cfail3")]
+#[rustc_clean(cfg = "cfail5", except = "hir_owner,hir_owner_nodes")]
+#[rustc_clean(cfg = "cfail6")]
+extern "C" {
+ pub fn change_function_name2(c: i64) -> i32;
+}
+
+// Change parameter name -------------------------------------------------------
+#[cfg(any(cfail1,cfail4))]
+extern "C" {
+ pub fn change_parameter_name(c: i64) -> i32;
+}
+
+#[cfg(not(any(cfail1,cfail4)))]
+#[rustc_clean(cfg = "cfail2")]
+#[rustc_clean(cfg = "cfail3")]
+#[rustc_clean(cfg = "cfail5")]
+#[rustc_clean(cfg = "cfail6")]
+extern "C" {
+ pub fn change_parameter_name(d: i64) -> i32;
+}
+
+// Change parameter type -------------------------------------------------------
+#[cfg(any(cfail1,cfail4))]
+extern "C" {
+ pub fn change_parameter_type(c: i64) -> i32;
+}
+
+#[cfg(not(any(cfail1,cfail4)))]
+#[rustc_clean(cfg = "cfail2")]
+#[rustc_clean(cfg = "cfail3")]
+#[rustc_clean(cfg = "cfail5")]
+#[rustc_clean(cfg = "cfail6")]
+extern "C" {
+ pub fn change_parameter_type(c: i32) -> i32;
+}
+
+// Change return type ----------------------------------------------------------
+#[cfg(any(cfail1,cfail4))]
+extern "C" {
+ pub fn change_return_type(c: i32) -> i32;
+}
+
+#[cfg(not(any(cfail1,cfail4)))]
+#[rustc_clean(cfg = "cfail2")]
+#[rustc_clean(cfg = "cfail3")]
+#[rustc_clean(cfg = "cfail5")]
+#[rustc_clean(cfg = "cfail6")]
+extern "C" {
+ pub fn change_return_type(c: i32) -> i8 ;
+}
+
+// Add parameter ---------------------------------------------------------------
+#[cfg(any(cfail1,cfail4))]
+extern "C" {
+ pub fn add_parameter(c: i32 ) -> i32;
+}
+
+#[cfg(not(any(cfail1,cfail4)))]
+#[rustc_clean(cfg = "cfail2")]
+#[rustc_clean(cfg = "cfail3")]
+#[rustc_clean(cfg = "cfail5")]
+#[rustc_clean(cfg = "cfail6")]
+extern "C" {
+ pub fn add_parameter(c: i32, d: i32) -> i32;
+}
+
+// Add return type -------------------------------------------------------------
+#[cfg(any(cfail1,cfail4))]
+extern "C" {
+ pub fn add_return_type(c: i32) ;
+}
+
+#[cfg(not(any(cfail1,cfail4)))]
+#[rustc_clean(cfg = "cfail2")]
+#[rustc_clean(cfg = "cfail3")]
+#[rustc_clean(cfg = "cfail5")]
+#[rustc_clean(cfg = "cfail6")]
+extern "C" {
+ pub fn add_return_type(c: i32) -> i32;
+}
+
+// Make function variadic ------------------------------------------------------
+#[cfg(any(cfail1,cfail4))]
+extern "C" {
+ pub fn make_function_variadic(c: i32 );
+}
+
+#[cfg(not(any(cfail1,cfail4)))]
+#[rustc_clean(cfg = "cfail2")]
+#[rustc_clean(cfg = "cfail3")]
+#[rustc_clean(cfg = "cfail5")]
+#[rustc_clean(cfg = "cfail6")]
+extern "C" {
+ pub fn make_function_variadic(c: i32, ...);
+}
+
+// Change calling convention ---------------------------------------------------
+#[cfg(any(cfail1,cfail4))]
+extern "C" {
+ pub fn change_calling_convention(c: (i32,));
+}
+
+#[cfg(not(any(cfail1,cfail4)))]
+#[rustc_clean(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")]
+#[rustc_clean(cfg = "cfail3")]
+#[rustc_clean(cfg = "cfail5", except = "hir_owner,hir_owner_nodes")]
+#[rustc_clean(cfg = "cfail6")]
+extern "rust-call" {
+ pub fn change_calling_convention(c: (i32,));
+}
+
+// Make function public --------------------------------------------------------
+#[cfg(any(cfail1,cfail4))]
+extern "C" {
+ fn make_function_public(c: i32);
+}
+
+#[cfg(not(any(cfail1,cfail4)))]
+#[rustc_clean(cfg = "cfail2")]
+#[rustc_clean(cfg = "cfail3")]
+#[rustc_clean(cfg = "cfail5")]
+#[rustc_clean(cfg = "cfail6")]
+extern "C" {
+ pub fn make_function_public(c: i32);
+}
+
+// Add function ----------------------------------------------------------------
+#[cfg(any(cfail1,cfail4))]
+extern "C" {
+ pub fn add_function1(c: i32);
+}
+
+#[cfg(not(any(cfail1,cfail4)))]
+#[rustc_clean(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")]
+#[rustc_clean(cfg = "cfail3")]
+#[rustc_clean(cfg = "cfail5", except = "hir_owner,hir_owner_nodes")]
+#[rustc_clean(cfg = "cfail6")]
+extern "C" {
+ pub fn add_function1(c: i32);
+ pub fn add_function2();
+}
+
+// Change link-name ------------------------------------------------------------
+#[cfg(any(cfail1,cfail4))]
+#[link(name = "foo")]
+extern "C" {
+ pub fn change_link_name(c: i32);
+}
+
+#[cfg(not(any(cfail1,cfail4)))]
+#[rustc_clean(cfg = "cfail2")]
+#[rustc_clean(cfg = "cfail3")]
+#[rustc_clean(cfg = "cfail5")]
+#[rustc_clean(cfg = "cfail6")]
+#[link(name = "bar")]
+extern "C" {
+ pub fn change_link_name(c: i32);
+}
+
+type c_i32 = i32;
+type c_i64 = i64;
+
+// Indirectly change parameter type --------------------------------------------
+mod indirectly_change_parameter_type {
+ #[cfg(any(cfail1,cfail4))]
+ use super::c_i32 as c_int;
+ #[cfg(not(any(cfail1,cfail4)))]
+ use super::c_i64 as c_int;
+
+ #[rustc_clean(cfg = "cfail2")]
+ #[rustc_clean(cfg = "cfail3")]
+ #[rustc_clean(cfg = "cfail5")]
+ #[rustc_clean(cfg = "cfail6")]
+ extern "C" {
+ pub fn indirectly_change_parameter_type(c: c_int);
+ }
+}
+
+// Indirectly change return type --------------------------------------------
+mod indirectly_change_return_type {
+ #[cfg(any(cfail1,cfail4))]
+ use super::c_i32 as c_int;
+ #[cfg(not(any(cfail1,cfail4)))]
+ use super::c_i64 as c_int;
+
+ #[rustc_clean(cfg = "cfail2")]
+ #[rustc_clean(cfg = "cfail3")]
+ #[rustc_clean(cfg = "cfail5")]
+ #[rustc_clean(cfg = "cfail6")]
+ extern "C" {
+ pub fn indirectly_change_return_type() -> c_int;
+ }
+}