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/ui/extern/auxiliary/extern-take-value.rs | 5 +++++ .../extern/auxiliary/extern-types-inherent-impl.rs | 9 ++++++++ .../extern/auxiliary/extern_calling_convention.rs | 26 ++++++++++++++++++++++ .../ui/extern/auxiliary/extern_mod_ordering_lib.rs | 5 +++++ tests/ui/extern/auxiliary/fat_drop.rs | 13 +++++++++++ tests/ui/extern/auxiliary/invalid-utf8.txt | 1 + tests/ui/extern/auxiliary/issue-80074-macro.rs | 4 ++++ tests/ui/extern/auxiliary/m1.rs | 1 + tests/ui/extern/auxiliary/m2.rs | 1 + .../ui/extern/auxiliary/no-mangle-associated-fn.rs | 21 +++++++++++++++++ .../extern/auxiliary/reexport-should-still-link.rs | 5 +++++ 11 files changed, 91 insertions(+) create mode 100644 tests/ui/extern/auxiliary/extern-take-value.rs create mode 100644 tests/ui/extern/auxiliary/extern-types-inherent-impl.rs create mode 100644 tests/ui/extern/auxiliary/extern_calling_convention.rs create mode 100644 tests/ui/extern/auxiliary/extern_mod_ordering_lib.rs create mode 100644 tests/ui/extern/auxiliary/fat_drop.rs create mode 100644 tests/ui/extern/auxiliary/invalid-utf8.txt create mode 100644 tests/ui/extern/auxiliary/issue-80074-macro.rs create mode 100644 tests/ui/extern/auxiliary/m1.rs create mode 100644 tests/ui/extern/auxiliary/m2.rs create mode 100644 tests/ui/extern/auxiliary/no-mangle-associated-fn.rs create mode 100644 tests/ui/extern/auxiliary/reexport-should-still-link.rs (limited to 'tests/ui/extern/auxiliary') diff --git a/tests/ui/extern/auxiliary/extern-take-value.rs b/tests/ui/extern/auxiliary/extern-take-value.rs new file mode 100644 index 000000000..56256aa19 --- /dev/null +++ b/tests/ui/extern/auxiliary/extern-take-value.rs @@ -0,0 +1,5 @@ +pub extern "C" fn f() -> i32 { 1 } +pub extern "C" fn g() -> i32 { 2 } + +pub fn get_f() -> extern "C" fn() -> i32 { f } +pub fn get_g() -> extern "C" fn() -> i32 { g } diff --git a/tests/ui/extern/auxiliary/extern-types-inherent-impl.rs b/tests/ui/extern/auxiliary/extern-types-inherent-impl.rs new file mode 100644 index 000000000..a1efe1818 --- /dev/null +++ b/tests/ui/extern/auxiliary/extern-types-inherent-impl.rs @@ -0,0 +1,9 @@ +#![feature(extern_types)] + +extern "C" { + pub type CrossCrate; +} + +impl CrossCrate { + pub fn foo(&self) {} +} diff --git a/tests/ui/extern/auxiliary/extern_calling_convention.rs b/tests/ui/extern/auxiliary/extern_calling_convention.rs new file mode 100644 index 000000000..e24cf9fda --- /dev/null +++ b/tests/ui/extern/auxiliary/extern_calling_convention.rs @@ -0,0 +1,26 @@ +// Make sure Rust generates the correct calling convention for extern +// functions. + +#[inline(never)] +#[cfg(target_arch = "x86_64")] +pub extern "win64" fn foo(a: isize, b: isize, c: isize, d: isize) { + assert_eq!(a, 1); + assert_eq!(b, 2); + assert_eq!(c, 3); + assert_eq!(d, 4); + + println!("a: {}, b: {}, c: {}, d: {}", + a, b, c, d) +} + +#[inline(never)] +#[cfg(not(target_arch = "x86_64"))] +pub extern "C" fn foo(a: isize, b: isize, c: isize, d: isize) { + assert_eq!(a, 1); + assert_eq!(b, 2); + assert_eq!(c, 3); + assert_eq!(d, 4); + + println!("a: {}, b: {}, c: {}, d: {}", + a, b, c, d) +} diff --git a/tests/ui/extern/auxiliary/extern_mod_ordering_lib.rs b/tests/ui/extern/auxiliary/extern_mod_ordering_lib.rs new file mode 100644 index 000000000..7357f5970 --- /dev/null +++ b/tests/ui/extern/auxiliary/extern_mod_ordering_lib.rs @@ -0,0 +1,5 @@ +#![crate_type="lib"] + +pub mod extern_mod_ordering_lib { + pub fn f() {} +} diff --git a/tests/ui/extern/auxiliary/fat_drop.rs b/tests/ui/extern/auxiliary/fat_drop.rs new file mode 100644 index 000000000..768d29876 --- /dev/null +++ b/tests/ui/extern/auxiliary/fat_drop.rs @@ -0,0 +1,13 @@ +pub static mut DROPPED: bool = false; + +pub struct S { + _unsized: [u8] +} + +impl Drop for S { + fn drop(&mut self) { + unsafe { + DROPPED = true; + } + } +} diff --git a/tests/ui/extern/auxiliary/invalid-utf8.txt b/tests/ui/extern/auxiliary/invalid-utf8.txt new file mode 100644 index 000000000..dc1115b82 --- /dev/null +++ b/tests/ui/extern/auxiliary/invalid-utf8.txt @@ -0,0 +1 @@ +Ã( \ No newline at end of file diff --git a/tests/ui/extern/auxiliary/issue-80074-macro.rs b/tests/ui/extern/auxiliary/issue-80074-macro.rs new file mode 100644 index 000000000..30e0f19ab --- /dev/null +++ b/tests/ui/extern/auxiliary/issue-80074-macro.rs @@ -0,0 +1,4 @@ +// edition:2018 + +macro_rules! foo_ { () => {}; } +use foo_ as foo; diff --git a/tests/ui/extern/auxiliary/m1.rs b/tests/ui/extern/auxiliary/m1.rs new file mode 100644 index 000000000..b76b4321d --- /dev/null +++ b/tests/ui/extern/auxiliary/m1.rs @@ -0,0 +1 @@ +pub fn foo() {} diff --git a/tests/ui/extern/auxiliary/m2.rs b/tests/ui/extern/auxiliary/m2.rs new file mode 100644 index 000000000..c5c0bc606 --- /dev/null +++ b/tests/ui/extern/auxiliary/m2.rs @@ -0,0 +1 @@ +pub fn bar() {} diff --git a/tests/ui/extern/auxiliary/no-mangle-associated-fn.rs b/tests/ui/extern/auxiliary/no-mangle-associated-fn.rs new file mode 100644 index 000000000..7fc73c76c --- /dev/null +++ b/tests/ui/extern/auxiliary/no-mangle-associated-fn.rs @@ -0,0 +1,21 @@ +#![crate_type = "lib"] + +struct Bar; + +impl Bar { + #[no_mangle] + fn bar() -> u8 { + 2 + } +} + +trait Foo { + fn baz() -> u8; +} + +impl Foo for Bar { + #[no_mangle] + fn baz() -> u8 { + 3 + } +} diff --git a/tests/ui/extern/auxiliary/reexport-should-still-link.rs b/tests/ui/extern/auxiliary/reexport-should-still-link.rs new file mode 100644 index 000000000..237ea8dfc --- /dev/null +++ b/tests/ui/extern/auxiliary/reexport-should-still-link.rs @@ -0,0 +1,5 @@ +pub use foo::bar; + +mod foo { + pub fn bar() {} +} -- cgit v1.2.3