Skip to content

Commit 80ef068

Browse files
committed
Produce error message for a few more unsupported signatures
1 parent c39925d commit 80ef068

File tree

5 files changed

+40
-0
lines changed

5 files changed

+40
-0
lines changed

syntax/parse.rs

+12
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,18 @@ fn parse_extern_fn(
379379
"async function is not directly supported yet, but see https://cxx.rs/async.html for a working approach",
380380
));
381381
}
382+
if foreign_fn.sig.constness.is_some() {
383+
return Err(Error::new_spanned(
384+
foreign_fn,
385+
"const extern function is not supported",
386+
));
387+
}
388+
if let Some(abi) = &foreign_fn.sig.abi {
389+
return Err(Error::new_spanned(
390+
abi,
391+
"explicit ABI on extern function is not supported",
392+
));
393+
}
382394

383395
let mut doc = Doc::new();
384396
let mut cxx_name = None;

tests/ui/const_fn.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#[cxx::bridge]
2+
mod ffi {
3+
extern "Rust" {
4+
const fn f();
5+
}
6+
}
7+
8+
const fn f() {}
9+
10+
fn main() {}

tests/ui/const_fn.stderr

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
error: const extern function is not supported
2+
--> $DIR/const_fn.rs:4:9
3+
|
4+
4 | const fn f();
5+
| ^^^^^^^^^^^^^

tests/ui/extern_fn_abi.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#[cxx::bridge]
2+
mod ffi {
3+
extern "C++" {
4+
extern "Java" fn f();
5+
}
6+
}
7+
8+
fn main() {}

tests/ui/extern_fn_abi.stderr

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
error: explicit ABI on extern function is not supported
2+
--> $DIR/extern_fn_abi.rs:4:9
3+
|
4+
4 | extern "Java" fn f();
5+
| ^^^^^^^^^^^^^

0 commit comments

Comments
 (0)