about summary refs log tree commit diff
diff options
context:
space:
mode:
authorinquisitivecrystal <22333129+inquisitivecrystal@users.noreply.github.com>2023-01-24 04:11:00 -0800
committerinquisitivecrystal <22333129+inquisitivecrystal@users.noreply.github.com>2023-01-27 05:28:52 -0800
commitbc23e9aa4c78066043be246a47627746341480dd (patch)
tree3903548cd6f7db9c003a9a314a30f5c88cb83585
parent6e04e678dca99db95c28a3aa7091d4fa800dfb61 (diff)
downloadrust-bc23e9aa4c78066043be246a47627746341480dd.tar.gz
rust-bc23e9aa4c78066043be246a47627746341480dd.zip
Improve tests for FFI attr validation
-rw-r--r--tests/ui/ffi_const.rs10
-rw-r--r--tests/ui/ffi_const.stderr14
-rw-r--r--tests/ui/ffi_pure.rs10
-rw-r--r--tests/ui/ffi_pure.stderr14
-rw-r--r--tests/ui/ffi_returns_twice.rs10
-rw-r--r--tests/ui/ffi_returns_twice.stderr14
6 files changed, 69 insertions, 3 deletions
diff --git a/tests/ui/ffi_const.rs b/tests/ui/ffi_const.rs
index 7aeb5a49a1b..aa20a4d4c65 100644
--- a/tests/ui/ffi_const.rs
+++ b/tests/ui/ffi_const.rs
@@ -3,3 +3,13 @@
 
 #[ffi_const] //~ ERROR `#[ffi_const]` may only be used on foreign functions
 pub fn foo() {}
+
+#[ffi_const] //~ ERROR `#[ffi_const]` may only be used on foreign functions
+macro_rules! bar {
+    () => ()
+}
+
+extern "C" {
+    #[ffi_const] //~ ERROR `#[ffi_const]` may only be used on foreign functions
+    static INT: i32;
+}
diff --git a/tests/ui/ffi_const.stderr b/tests/ui/ffi_const.stderr
index bc3c12eaf98..394b98f8971 100644
--- a/tests/ui/ffi_const.stderr
+++ b/tests/ui/ffi_const.stderr
@@ -4,6 +4,18 @@ error[E0756]: `#[ffi_const]` may only be used on foreign functions
 LL | #[ffi_const]
    | ^^^^^^^^^^^^
 
-error: aborting due to previous error
+error[E0756]: `#[ffi_const]` may only be used on foreign functions
+  --> $DIR/ffi_const.rs:7:1
+   |
+LL | #[ffi_const]
+   | ^^^^^^^^^^^^
+
+error[E0756]: `#[ffi_const]` may only be used on foreign functions
+  --> $DIR/ffi_const.rs:13:5
+   |
+LL |     #[ffi_const]
+   |     ^^^^^^^^^^^^
+
+error: aborting due to 3 previous errors
 
 For more information about this error, try `rustc --explain E0756`.
diff --git a/tests/ui/ffi_pure.rs b/tests/ui/ffi_pure.rs
index c37d34c8784..6d2f3a614ec 100644
--- a/tests/ui/ffi_pure.rs
+++ b/tests/ui/ffi_pure.rs
@@ -3,3 +3,13 @@
 
 #[ffi_pure] //~ ERROR `#[ffi_pure]` may only be used on foreign functions
 pub fn foo() {}
+
+#[ffi_pure] //~ ERROR `#[ffi_pure]` may only be used on foreign functions
+macro_rules! bar {
+    () => ()
+}
+
+extern "C" {
+    #[ffi_pure] //~ ERROR `#[ffi_pure]` may only be used on foreign functions
+    static INT: i32;
+}
diff --git a/tests/ui/ffi_pure.stderr b/tests/ui/ffi_pure.stderr
index bc911c85ddb..8b61a4b609f 100644
--- a/tests/ui/ffi_pure.stderr
+++ b/tests/ui/ffi_pure.stderr
@@ -4,6 +4,18 @@ error[E0755]: `#[ffi_pure]` may only be used on foreign functions
 LL | #[ffi_pure]
    | ^^^^^^^^^^^
 
-error: aborting due to previous error
+error[E0755]: `#[ffi_pure]` may only be used on foreign functions
+  --> $DIR/ffi_pure.rs:7:1
+   |
+LL | #[ffi_pure]
+   | ^^^^^^^^^^^
+
+error[E0755]: `#[ffi_pure]` may only be used on foreign functions
+  --> $DIR/ffi_pure.rs:13:5
+   |
+LL |     #[ffi_pure]
+   |     ^^^^^^^^^^^
+
+error: aborting due to 3 previous errors
 
 For more information about this error, try `rustc --explain E0755`.
diff --git a/tests/ui/ffi_returns_twice.rs b/tests/ui/ffi_returns_twice.rs
index 845e18df11b..8195d0e4863 100644
--- a/tests/ui/ffi_returns_twice.rs
+++ b/tests/ui/ffi_returns_twice.rs
@@ -3,3 +3,13 @@
 
 #[ffi_returns_twice] //~ ERROR `#[ffi_returns_twice]` may only be used on foreign functions
 pub fn foo() {}
+
+#[ffi_returns_twice] //~ ERROR `#[ffi_returns_twice]` may only be used on foreign functions
+macro_rules! bar {
+    () => ()
+}
+
+extern "C" {
+    #[ffi_returns_twice] //~ ERROR `#[ffi_returns_twice]` may only be used on foreign functions
+    static INT: i32;
+}
diff --git a/tests/ui/ffi_returns_twice.stderr b/tests/ui/ffi_returns_twice.stderr
index 2b7f5694f02..0abe7613f14 100644
--- a/tests/ui/ffi_returns_twice.stderr
+++ b/tests/ui/ffi_returns_twice.stderr
@@ -4,6 +4,18 @@ error[E0724]: `#[ffi_returns_twice]` may only be used on foreign functions
 LL | #[ffi_returns_twice]
    | ^^^^^^^^^^^^^^^^^^^^
 
-error: aborting due to previous error
+error[E0724]: `#[ffi_returns_twice]` may only be used on foreign functions
+  --> $DIR/ffi_returns_twice.rs:7:1
+   |
+LL | #[ffi_returns_twice]
+   | ^^^^^^^^^^^^^^^^^^^^
+
+error[E0724]: `#[ffi_returns_twice]` may only be used on foreign functions
+  --> $DIR/ffi_returns_twice.rs:13:5
+   |
+LL |     #[ffi_returns_twice]
+   |     ^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 3 previous errors
 
 For more information about this error, try `rustc --explain E0724`.