diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..1c50873 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,108 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "libc" +version = "0.2.134" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "329c933548736bc49fd575ee68c89e8be4d260064184389a5b77517cddd99ffb" + +[[package]] +name = "mini_paste" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2499b7bd9834270bf24cfc4dd96be59020ba6fd7f3276b772aee2de66e82b63" +dependencies = [ + "mini_paste-proc_macro", +] + +[[package]] +name = "mini_paste-proc_macro" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c5f1f52e39b728e73af4b454f1b29173d4544607bd395dafe1918fd149db67" + +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + +[[package]] +name = "proc-macro2" +version = "1.0.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94e2ef8dbfc347b10c094890f778ee2e36ca9bb4262e86dc99cd217e35f3470b" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "ra-bug" +version = "0.0.0" +dependencies = [ + "safer-ffi", +] + +[[package]] +name = "require_unsafe_in_body" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "296446f2214753e33792f632262451e8d037cd9697df15db2fd531bdce5a0138" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "safer-ffi" +version = "0.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c710243617290d86a49a30564d94d0b646eacf6d7b67035e20d6e8a21f1193" +dependencies = [ + "libc", + "mini_paste", + "proc-macro-hack", + "require_unsafe_in_body", + "safer_ffi-proc_macro", +] + +[[package]] +name = "safer_ffi-proc_macro" +version = "0.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc02dc034daa0944eb133b448f261ef7422ccae768e30f30ce5cdeb4ae4e506c" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "syn" +version = "1.0.101" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e90cde112c4b9690b8cbe810cba9ddd8bc1d7472e2cae317b69e9438c1cba7d2" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..901746c --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "ra-bug" +version = "0.0.0" +edition = "2021" +license = "MIT OR Apache-2.0" + +[features] +default = ["c_api"] +c_api = [] + +[dependencies] +safer-ffi = { version = "0.0.10", features = ["proc_macros"] } diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..c02159e --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,30 @@ +// This one works +#[safer_ffi::derive_ReprC] +#[ReprC::opaque] +pub struct NotGated { + bar: String, +} + +// This one doesn't work +#[cfg_attr(feature = "c_api", safer_ffi::derive_ReprC, ReprC::opaque)] +pub struct Gated { + bar: String, +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_foobar() { + let not_gated = NotGated { + bar: "yeet".to_string(), + }; + let gated = Gated { + bar: "yeet".to_string(), + }; + // Intellisense works for `not_gated` but fails on `gated`, go ahead and try it + assert_eq!(gated.bar, "yeet"); + assert_eq!(not_gated.bar, "yeet"); + } +}