Produce error message for a few more unsupported signatures
diff --git a/syntax/parse.rs b/syntax/parse.rs
index 78e6a3f..25d95e6 100644
--- a/syntax/parse.rs
+++ b/syntax/parse.rs
@@ -379,6 +379,18 @@
"async function is not directly supported yet, but see https://cxx.rs/async.html for a working approach",
));
}
+ if foreign_fn.sig.constness.is_some() {
+ return Err(Error::new_spanned(
+ foreign_fn,
+ "const extern function is not supported",
+ ));
+ }
+ if let Some(abi) = &foreign_fn.sig.abi {
+ return Err(Error::new_spanned(
+ abi,
+ "explicit ABI on extern function is not supported",
+ ));
+ }
let mut doc = Doc::new();
let mut cxx_name = None;
diff --git a/tests/ui/const_fn.rs b/tests/ui/const_fn.rs
new file mode 100644
index 0000000..1ad4894
--- /dev/null
+++ b/tests/ui/const_fn.rs
@@ -0,0 +1,10 @@
+#[cxx::bridge]
+mod ffi {
+ extern "Rust" {
+ const fn f();
+ }
+}
+
+const fn f() {}
+
+fn main() {}
diff --git a/tests/ui/const_fn.stderr b/tests/ui/const_fn.stderr
new file mode 100644
index 0000000..a62ca83
--- /dev/null
+++ b/tests/ui/const_fn.stderr
@@ -0,0 +1,5 @@
+error: const extern function is not supported
+ --> $DIR/const_fn.rs:4:9
+ |
+4 | const fn f();
+ | ^^^^^^^^^^^^^
diff --git a/tests/ui/extern_fn_abi.rs b/tests/ui/extern_fn_abi.rs
new file mode 100644
index 0000000..1f93338
--- /dev/null
+++ b/tests/ui/extern_fn_abi.rs
@@ -0,0 +1,8 @@
+#[cxx::bridge]
+mod ffi {
+ extern "C++" {
+ extern "Java" fn f();
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/extern_fn_abi.stderr b/tests/ui/extern_fn_abi.stderr
new file mode 100644
index 0000000..3abf47a
--- /dev/null
+++ b/tests/ui/extern_fn_abi.stderr
@@ -0,0 +1,5 @@
+error: explicit ABI on extern function is not supported
+ --> $DIR/extern_fn_abi.rs:4:9
+ |
+4 | extern "Java" fn f();
+ | ^^^^^^^^^^^^^