-
Notifications
You must be signed in to change notification settings - Fork 26
Description
I want to use safe extern functions added with rust 1.82: https://doc.rust-lang.org/edition-guide/rust-2024/unsafe-extern.html
#[stabby::import(canaries = "", name = "library")]
#[allow(improper_ctypes)]
unsafe extern "C" {
pub safe fn unstable_fn(v: &[u8]);
}
but I get the following compiler error:
error: custom attribute panicked
--> examples/dynlinkage/src/main.rs:20:1
|
20 | #[stabby::import(canaries = "", name = "library")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: message: called `Result::unwrap()` on an `Err` value: Error("expected `extern`")
The problem is that this crate uses syn version "1.0" which is almost 3 years old. This means that supporting any new rust features would require an upgrade syn version 2.
I'd be happy to create a PR.
In that case I would also like to improve the error reporting. Right now errors are generated using panics which is fine but it means that errors are reported at the macro invocation (#[import]) instead of the exact line where the error originates.
That could be improved with the use of syn::Error::new(span, "error message").to_compile_error() https://docs.rs/syn/latest/syn/struct.Error.html#method.into_compile_error