From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/incremental/hashes/extern_mods.rs | 221 ++++++++++++++++++++++++++++++++ 1 file changed, 221 insertions(+) create mode 100644 tests/incremental/hashes/extern_mods.rs (limited to 'tests/incremental/hashes/extern_mods.rs') 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; + } +} -- cgit v1.2.3