summaryrefslogtreecommitdiffstats
path: root/tests/ui/extern/auxiliary
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/ui/extern/auxiliary
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/ui/extern/auxiliary')
-rw-r--r--tests/ui/extern/auxiliary/extern-take-value.rs5
-rw-r--r--tests/ui/extern/auxiliary/extern-types-inherent-impl.rs9
-rw-r--r--tests/ui/extern/auxiliary/extern_calling_convention.rs26
-rw-r--r--tests/ui/extern/auxiliary/extern_mod_ordering_lib.rs5
-rw-r--r--tests/ui/extern/auxiliary/fat_drop.rs13
-rw-r--r--tests/ui/extern/auxiliary/invalid-utf8.txt1
-rw-r--r--tests/ui/extern/auxiliary/issue-80074-macro.rs4
-rw-r--r--tests/ui/extern/auxiliary/m1.rs1
-rw-r--r--tests/ui/extern/auxiliary/m2.rs1
-rw-r--r--tests/ui/extern/auxiliary/no-mangle-associated-fn.rs21
-rw-r--r--tests/ui/extern/auxiliary/reexport-should-still-link.rs5
11 files changed, 91 insertions, 0 deletions
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() {}
+}