summaryrefslogtreecommitdiffstats
path: root/tests/ui/rfcs/rfc-2627-raw-dylib
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /tests/ui/rfcs/rfc-2627-raw-dylib
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/rfcs/rfc-2627-raw-dylib')
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.rs19
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.stderr5
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-invalid-format.rs7
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-invalid-format.stderr8
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-multiple.rs8
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-multiple.stderr8
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unknown-value.rs7
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unknown-value.stderr8
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.rs15
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.stderr14
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-x86-only.rs7
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-x86-only.stderr8
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/invalid-dlltool.rs13
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/invalid-dlltool.stderr4
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-and-name.rs13
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-and-name.stderr14
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-invalid-format.rs11
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-invalid-format.stderr18
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-missing-argument.rs11
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-missing-argument.stderr18
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-multiple.rs12
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-multiple.stderr26
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.rs22
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.stderr20
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-large.rs11
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-large.stderr18
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.rs11
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.stderr18
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.rs15
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.stderr14
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/multiple-declarations.rs18
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/multiple-declarations.stderr8
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/raw-dylib-windows-only.rs5
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/raw-dylib-windows-only.stderr9
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/unsupported-abi.rs12
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/unsupported-abi.stderr8
36 files changed, 443 insertions, 0 deletions
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.rs
new file mode 100644
index 000000000..d7a418959
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.rs
@@ -0,0 +1,19 @@
+// Tests that dlltool failing to generate an import library will raise an error.
+
+// only-gnu
+// only-windows
+// needs-dlltool
+// compile-flags: --crate-type lib --emit link
+// normalize-stderr-test: "[^ ']*/dlltool.exe" -> "$$DLLTOOL"
+// normalize-stderr-test: "[^ ]*/foo.def" -> "$$DEF_FILE"
+#[link(name = "foo", kind = "raw-dylib")]
+extern "C" {
+ // `@1` is an invalid name to export, as it usually indicates that something
+ // is being exported via ordinal.
+ #[link_name = "@1"]
+ fn f(x: i32);
+}
+
+pub fn lib_main() {
+ unsafe { f(42); }
+}
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.stderr
new file mode 100644
index 000000000..020ac6a2b
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.stderr
@@ -0,0 +1,5 @@
+error: Dlltool could not create import library:
+ $DLLTOOL: Syntax error in def file $DEF_FILE:1
+
+error: aborting due to previous error
+
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-invalid-format.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-invalid-format.rs
new file mode 100644
index 000000000..7bc44d65b
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-invalid-format.rs
@@ -0,0 +1,7 @@
+// only-windows
+// only-x86
+#[link(name = "foo", kind = "raw-dylib", import_name_type = 6)]
+//~^ ERROR import name type must be of the form `import_name_type = "string"`
+extern "C" { }
+
+fn main() {}
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-invalid-format.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-invalid-format.stderr
new file mode 100644
index 000000000..fb70b987f
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-invalid-format.stderr
@@ -0,0 +1,8 @@
+error: import name type must be of the form `import_name_type = "string"`
+ --> $DIR/import-name-type-invalid-format.rs:3:42
+ |
+LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = 6)]
+ | ^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-multiple.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-multiple.rs
new file mode 100644
index 000000000..b96f61a26
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-multiple.rs
@@ -0,0 +1,8 @@
+// ignore-tidy-linelength
+// only-windows
+// only-x86
+#[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated", import_name_type = "decorated")]
+//~^ ERROR multiple `import_name_type` arguments in a single `#[link]` attribute
+extern "C" { }
+
+fn main() {}
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-multiple.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-multiple.stderr
new file mode 100644
index 000000000..953306189
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-multiple.stderr
@@ -0,0 +1,8 @@
+error: multiple `import_name_type` arguments in a single `#[link]` attribute
+ --> $DIR/import-name-type-multiple.rs:4:74
+ |
+LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated", import_name_type = "decorated")]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unknown-value.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unknown-value.rs
new file mode 100644
index 000000000..067e82a17
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unknown-value.rs
@@ -0,0 +1,7 @@
+// only-windows
+// only-x86
+#[link(name = "foo", kind = "raw-dylib", import_name_type = "unknown")]
+//~^ ERROR unknown import name type `unknown`, expected one of: decorated, noprefix, undecorated
+extern "C" { }
+
+fn main() {}
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unknown-value.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unknown-value.stderr
new file mode 100644
index 000000000..2bce9758e
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unknown-value.stderr
@@ -0,0 +1,8 @@
+error: unknown import name type `unknown`, expected one of: decorated, noprefix, undecorated
+ --> $DIR/import-name-type-unknown-value.rs:3:42
+ |
+LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "unknown")]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.rs
new file mode 100644
index 000000000..34e907bde
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.rs
@@ -0,0 +1,15 @@
+// only-windows
+// only-x86
+#[link(name = "foo", import_name_type = "decorated")]
+//~^ ERROR import name type can only be used with link kind `raw-dylib`
+extern "C" { }
+
+#[link(name = "bar", kind = "static", import_name_type = "decorated")]
+//~^ ERROR import name type can only be used with link kind `raw-dylib`
+extern "C" { }
+
+// Specifying `import_name_type` before `kind` shouldn't raise an error.
+#[link(name = "bar", import_name_type = "decorated", kind = "raw-dylib")]
+extern "C" { }
+
+fn main() {}
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.stderr
new file mode 100644
index 000000000..75cadc471
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.stderr
@@ -0,0 +1,14 @@
+error: import name type can only be used with link kind `raw-dylib`
+ --> $DIR/import-name-type-unsupported-link-kind.rs:3:22
+ |
+LL | #[link(name = "foo", import_name_type = "decorated")]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: import name type can only be used with link kind `raw-dylib`
+ --> $DIR/import-name-type-unsupported-link-kind.rs:7:39
+ |
+LL | #[link(name = "bar", kind = "static", import_name_type = "decorated")]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-x86-only.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-x86-only.rs
new file mode 100644
index 000000000..346ea18a8
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-x86-only.rs
@@ -0,0 +1,7 @@
+// only-windows
+// ignore-x86
+#[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated")]
+//~^ ERROR import name type is only supported on x86
+extern "C" { }
+
+fn main() {}
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-x86-only.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-x86-only.stderr
new file mode 100644
index 000000000..b56449299
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-x86-only.stderr
@@ -0,0 +1,8 @@
+error: import name type is only supported on x86
+ --> $DIR/import-name-type-x86-only.rs:3:42
+ |
+LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated")]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/invalid-dlltool.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/invalid-dlltool.rs
new file mode 100644
index 000000000..a07be9d92
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/invalid-dlltool.rs
@@ -0,0 +1,13 @@
+// Tests that failing to run dlltool will raise an error.
+
+// only-gnu
+// only-windows
+// compile-flags: --crate-type lib --emit link -Cdlltool=does_not_exit.exe
+#[link(name = "foo", kind = "raw-dylib")]
+extern "C" {
+ fn f(x: i32);
+}
+
+pub fn lib_main() {
+ unsafe { f(42); }
+}
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/invalid-dlltool.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/invalid-dlltool.stderr
new file mode 100644
index 000000000..3ae901e0d
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/invalid-dlltool.stderr
@@ -0,0 +1,4 @@
+error: Error calling dlltool 'does_not_exit.exe': program not found
+
+error: aborting due to previous error
+
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-and-name.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-and-name.rs
new file mode 100644
index 000000000..b04c2facb
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-and-name.rs
@@ -0,0 +1,13 @@
+#[link(name="foo")]
+extern "C" {
+ #[link_name="foo"]
+ #[link_ordinal(42)]
+ //~^ ERROR cannot use `#[link_name]` with `#[link_ordinal]`
+ fn foo();
+ #[link_name="foo"]
+ #[link_ordinal(5)]
+ //~^ ERROR cannot use `#[link_name]` with `#[link_ordinal]`
+ static mut imported_variable: i32;
+}
+
+fn main() {}
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-and-name.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-and-name.stderr
new file mode 100644
index 000000000..f1e54d378
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-and-name.stderr
@@ -0,0 +1,14 @@
+error: cannot use `#[link_name]` with `#[link_ordinal]`
+ --> $DIR/link-ordinal-and-name.rs:4:5
+ |
+LL | #[link_ordinal(42)]
+ | ^^^^^^^^^^^^^^^^^^^
+
+error: cannot use `#[link_name]` with `#[link_ordinal]`
+ --> $DIR/link-ordinal-and-name.rs:8:5
+ |
+LL | #[link_ordinal(5)]
+ | ^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-invalid-format.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-invalid-format.rs
new file mode 100644
index 000000000..9b7e8d707
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-invalid-format.rs
@@ -0,0 +1,11 @@
+#[link(name = "foo")]
+extern "C" {
+ #[link_ordinal("JustMonika")]
+ //~^ ERROR illegal ordinal format in `link_ordinal`
+ fn foo();
+ #[link_ordinal("JustMonika")]
+ //~^ ERROR illegal ordinal format in `link_ordinal`
+ static mut imported_variable: i32;
+}
+
+fn main() {}
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-invalid-format.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-invalid-format.stderr
new file mode 100644
index 000000000..6341e57a0
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-invalid-format.stderr
@@ -0,0 +1,18 @@
+error: illegal ordinal format in `link_ordinal`
+ --> $DIR/link-ordinal-invalid-format.rs:3:5
+ |
+LL | #[link_ordinal("JustMonika")]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: an unsuffixed integer value, e.g., `1`, is expected
+
+error: illegal ordinal format in `link_ordinal`
+ --> $DIR/link-ordinal-invalid-format.rs:6:5
+ |
+LL | #[link_ordinal("JustMonika")]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: an unsuffixed integer value, e.g., `1`, is expected
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-missing-argument.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-missing-argument.rs
new file mode 100644
index 000000000..6b8cd4956
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-missing-argument.rs
@@ -0,0 +1,11 @@
+#[link(name = "foo")]
+extern "C" {
+ #[link_ordinal()]
+ //~^ ERROR incorrect number of arguments to `#[link_ordinal]`
+ fn foo();
+ #[link_ordinal()]
+ //~^ ERROR incorrect number of arguments to `#[link_ordinal]`
+ static mut imported_variable: i32;
+}
+
+fn main() {}
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-missing-argument.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-missing-argument.stderr
new file mode 100644
index 000000000..1b04bb228
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-missing-argument.stderr
@@ -0,0 +1,18 @@
+error: incorrect number of arguments to `#[link_ordinal]`
+ --> $DIR/link-ordinal-missing-argument.rs:3:5
+ |
+LL | #[link_ordinal()]
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: the attribute requires exactly one argument
+
+error: incorrect number of arguments to `#[link_ordinal]`
+ --> $DIR/link-ordinal-missing-argument.rs:6:5
+ |
+LL | #[link_ordinal()]
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: the attribute requires exactly one argument
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-multiple.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-multiple.rs
new file mode 100644
index 000000000..8842cb944
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-multiple.rs
@@ -0,0 +1,12 @@
+// only-windows
+#[link(name = "foo", kind = "raw-dylib")]
+extern "C" {
+ #[link_ordinal(1)] //~ ERROR multiple `link_ordinal` attributes
+ #[link_ordinal(2)]
+ fn foo();
+ #[link_ordinal(1)] //~ ERROR multiple `link_ordinal` attributes
+ #[link_ordinal(2)]
+ static mut imported_variable: i32;
+}
+
+fn main() {}
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-multiple.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-multiple.stderr
new file mode 100644
index 000000000..2e6cf3761
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-multiple.stderr
@@ -0,0 +1,26 @@
+error: multiple `link_ordinal` attributes
+ --> $DIR/link-ordinal-multiple.rs:4:5
+ |
+LL | #[link_ordinal(1)]
+ | ^^^^^^^^^^^^^^^^^^ help: remove this attribute
+ |
+note: attribute also specified here
+ --> $DIR/link-ordinal-multiple.rs:5:5
+ |
+LL | #[link_ordinal(2)]
+ | ^^^^^^^^^^^^^^^^^^
+
+error: multiple `link_ordinal` attributes
+ --> $DIR/link-ordinal-multiple.rs:7:5
+ |
+LL | #[link_ordinal(1)]
+ | ^^^^^^^^^^^^^^^^^^ help: remove this attribute
+ |
+note: attribute also specified here
+ --> $DIR/link-ordinal-multiple.rs:8:5
+ |
+LL | #[link_ordinal(2)]
+ | ^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.rs
new file mode 100644
index 000000000..f33a3d62e
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.rs
@@ -0,0 +1,22 @@
+#[link_ordinal(123)]
+//~^ ERROR attribute should be applied to a foreign function or static
+struct Foo {}
+
+#[link_ordinal(123)]
+//~^ ERROR attribute should be applied to a foreign function or static
+fn test() {}
+
+#[link_ordinal(42)]
+//~^ ERROR attribute should be applied to a foreign function or static
+static mut imported_val: i32 = 123;
+
+#[link(name = "exporter", kind = "raw-dylib")]
+extern {
+ #[link_ordinal(13)]
+ fn imported_function();
+
+ #[link_ordinal(42)]
+ static mut imported_variable: i32;
+}
+
+fn main() {}
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.stderr
new file mode 100644
index 000000000..8f2795087
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.stderr
@@ -0,0 +1,20 @@
+error: attribute should be applied to a foreign function or static
+ --> $DIR/link-ordinal-not-foreign-fn.rs:1:1
+ |
+LL | #[link_ordinal(123)]
+ | ^^^^^^^^^^^^^^^^^^^^
+
+error: attribute should be applied to a foreign function or static
+ --> $DIR/link-ordinal-not-foreign-fn.rs:5:1
+ |
+LL | #[link_ordinal(123)]
+ | ^^^^^^^^^^^^^^^^^^^^
+
+error: attribute should be applied to a foreign function or static
+ --> $DIR/link-ordinal-not-foreign-fn.rs:9:1
+ |
+LL | #[link_ordinal(42)]
+ | ^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 3 previous errors
+
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-large.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-large.rs
new file mode 100644
index 000000000..9d741630f
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-large.rs
@@ -0,0 +1,11 @@
+#[link(name = "foo")]
+extern "C" {
+ #[link_ordinal(72436)]
+ //~^ ERROR ordinal value in `link_ordinal` is too large: `72436`
+ fn foo();
+ #[link_ordinal(72436)]
+ //~^ ERROR ordinal value in `link_ordinal` is too large: `72436`
+ static mut imported_variable: i32;
+}
+
+fn main() {}
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-large.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-large.stderr
new file mode 100644
index 000000000..811145e77
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-large.stderr
@@ -0,0 +1,18 @@
+error: ordinal value in `link_ordinal` is too large: `72436`
+ --> $DIR/link-ordinal-too-large.rs:3:5
+ |
+LL | #[link_ordinal(72436)]
+ | ^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: the value may not exceed `u16::MAX`
+
+error: ordinal value in `link_ordinal` is too large: `72436`
+ --> $DIR/link-ordinal-too-large.rs:6:5
+ |
+LL | #[link_ordinal(72436)]
+ | ^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: the value may not exceed `u16::MAX`
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.rs
new file mode 100644
index 000000000..9988115fd
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.rs
@@ -0,0 +1,11 @@
+#[link(name = "foo")]
+extern "C" {
+ #[link_ordinal(3, 4)]
+ //~^ ERROR incorrect number of arguments to `#[link_ordinal]`
+ fn foo();
+ #[link_ordinal(3, 4)]
+ //~^ ERROR incorrect number of arguments to `#[link_ordinal]`
+ static mut imported_variable: i32;
+}
+
+fn main() {}
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.stderr
new file mode 100644
index 000000000..d5ce8aff3
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.stderr
@@ -0,0 +1,18 @@
+error: incorrect number of arguments to `#[link_ordinal]`
+ --> $DIR/link-ordinal-too-many-arguments.rs:3:5
+ |
+LL | #[link_ordinal(3, 4)]
+ | ^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: the attribute requires exactly one argument
+
+error: incorrect number of arguments to `#[link_ordinal]`
+ --> $DIR/link-ordinal-too-many-arguments.rs:6:5
+ |
+LL | #[link_ordinal(3, 4)]
+ | ^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: the attribute requires exactly one argument
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.rs
new file mode 100644
index 000000000..14e915d60
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.rs
@@ -0,0 +1,15 @@
+#[link(name = "foo")]
+extern "C" {
+ #[link_ordinal(3)]
+ //~^ ERROR `#[link_ordinal]` is only supported if link kind is `raw-dylib`
+ fn foo();
+}
+
+#[link(name = "bar", kind = "static")]
+extern "C" {
+ #[link_ordinal(3)]
+ //~^ ERROR `#[link_ordinal]` is only supported if link kind is `raw-dylib`
+ fn bar();
+}
+
+fn main() {}
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.stderr
new file mode 100644
index 000000000..200b8f628
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.stderr
@@ -0,0 +1,14 @@
+error: `#[link_ordinal]` is only supported if link kind is `raw-dylib`
+ --> $DIR/link-ordinal-unsupported-link-kind.rs:3:5
+ |
+LL | #[link_ordinal(3)]
+ | ^^^^^^^^^^^^^^^^^^
+
+error: `#[link_ordinal]` is only supported if link kind is `raw-dylib`
+ --> $DIR/link-ordinal-unsupported-link-kind.rs:10:5
+ |
+LL | #[link_ordinal(3)]
+ | ^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/multiple-declarations.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/multiple-declarations.rs
new file mode 100644
index 000000000..b4173f3b6
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/multiple-declarations.rs
@@ -0,0 +1,18 @@
+// only-x86
+// only-windows
+// compile-flags: --crate-type lib --emit link
+#![allow(clashing_extern_declarations)]
+#[link(name = "foo", kind = "raw-dylib")]
+extern "C" {
+ fn f(x: i32);
+}
+
+pub fn lib_main() {
+ #[link(name = "foo", kind = "raw-dylib")]
+ extern "stdcall" {
+ fn f(x: i32);
+ //~^ ERROR multiple declarations of external function `f` from library `foo.dll` have different calling conventions
+ }
+
+ unsafe { f(42); }
+}
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/multiple-declarations.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/multiple-declarations.stderr
new file mode 100644
index 000000000..510108405
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/multiple-declarations.stderr
@@ -0,0 +1,8 @@
+error: multiple declarations of external function `f` from library `foo.dll` have different calling conventions
+ --> $DIR/multiple-declarations.rs:13:9
+ |
+LL | fn f(x: i32);
+ | ^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/raw-dylib-windows-only.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/raw-dylib-windows-only.rs
new file mode 100644
index 000000000..d4c6658a3
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/raw-dylib-windows-only.rs
@@ -0,0 +1,5 @@
+// ignore-windows
+// compile-flags: --crate-type lib
+#[link(name = "foo", kind = "raw-dylib")]
+//~^ ERROR: link kind `raw-dylib` is only supported on Windows targets
+extern "C" {}
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/raw-dylib-windows-only.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/raw-dylib-windows-only.stderr
new file mode 100644
index 000000000..b635a09af
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/raw-dylib-windows-only.stderr
@@ -0,0 +1,9 @@
+error[E0455]: link kind `raw-dylib` is only supported on Windows targets
+ --> $DIR/raw-dylib-windows-only.rs:3:29
+ |
+LL | #[link(name = "foo", kind = "raw-dylib")]
+ | ^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0455`.
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/unsupported-abi.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/unsupported-abi.rs
new file mode 100644
index 000000000..2f5a23e47
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/unsupported-abi.rs
@@ -0,0 +1,12 @@
+// only-x86_64
+// only-windows
+// compile-flags: --crate-type lib --emit link
+#[link(name = "foo", kind = "raw-dylib")]
+extern "stdcall" {
+ fn f(x: i32);
+ //~^ ERROR ABI not supported by `#[link(kind = "raw-dylib")]` on this architecture
+}
+
+pub fn lib_main() {
+ unsafe { f(42); }
+}
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/unsupported-abi.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/unsupported-abi.stderr
new file mode 100644
index 000000000..f8265ae69
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/unsupported-abi.stderr
@@ -0,0 +1,8 @@
+error: ABI not supported by `#[link(kind = "raw-dylib")]` on this architecture
+ --> $DIR/unsupported-abi.rs:6:5
+ |
+LL | fn f(x: i32);
+ | ^^^^^^^^^^^^^
+
+error: aborting due to previous error
+