diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 188b789fc8..29513b2b48 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -23,7 +23,7 @@ jobs: uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: nightly-2023-06-30 + toolchain: nightly-2023-09-14 override: true components: rust-src @@ -113,6 +113,7 @@ jobs: feature--dyn-traits: ['', '--features dyn-traits', '--features futures', '--features tokio'] # feature--log: ['', '--features log'] feature--js: ['', '--features js'] + feature--stabby: ['', '--features stabby'] steps: - name: Install Rust toolchain uses: actions-rs/toolchain@v1 @@ -134,6 +135,7 @@ jobs: ${{ matrix.feature--headers }} ${{ matrix.feature--dyn-traits }} ${{ matrix.feature--js }} + ${{ matrix.feature--stabby }} # == BUILD & TEST == # build-and-test: diff --git a/Cargo.lock b/Cargo.lock index 5cbd24199a..7a336cf76b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -622,7 +622,7 @@ checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "safer-ffi" -version = "0.1.9-rc2" +version = "0.1.9-rc3" dependencies = [ "async-compat", "cratesio-placeholder-package", @@ -653,7 +653,7 @@ dependencies = [ [[package]] name = "safer_ffi-proc_macros" -version = "0.1.8" +version = "0.1.9-rc3" dependencies = [ "macro_rules_attribute", "prettyplease", @@ -732,9 +732,9 @@ checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" [[package]] name = "stabby" -version = "36.1.1-rc5" +version = "36.1.1-rc8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25054b4ee0b62efb04b726c842de469822e465aea288cee48bfb4d609a31a30b" +checksum = "08cc900971922b54e6a2538906ec4bb17ae834d99ff9025741c701edf44006ba" dependencies = [ "rustversion", "stabby-abi", @@ -742,9 +742,9 @@ dependencies = [ [[package]] name = "stabby-abi" -version = "36.1.1-rc5" +version = "36.1.1-rc8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e4a396c54ccfacf796696b1079a3ca73b54f97714e35daa8af5097e652c03d2" +checksum = "ca372c473f8a01399568c4d6d131e6248d71958e38eb2e574b863feedbddac27" dependencies = [ "rustversion", "sha2-const-stable", @@ -753,9 +753,9 @@ dependencies = [ [[package]] name = "stabby-macros" -version = "36.1.1-rc5" +version = "36.1.1-rc8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae489fe740ec3780546c24bcb4970c030364e197f9182739c1aa8ec499761d70" +checksum = "80454eabdc8324ded185cd1c91641127f7f7186be3b21ef5a21202affc4544ce" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -1116,18 +1116,3 @@ dependencies = [ "quote", "syn 1.0.109", ] - -[[patch.unused]] -name = "tracing" -version = "0.1.40" -source = "git+https://github.com/getditto/tracing?branch=ditto#4638ac9c7590a5584cf29c5d1ddb4a249bf48c0d" - -[[patch.unused]] -name = "tracing-core" -version = "0.1.32" -source = "git+https://github.com/getditto/tracing?branch=ditto#4638ac9c7590a5584cf29c5d1ddb4a249bf48c0d" - -[[patch.unused]] -name = "tracing-subscriber" -version = "0.3.18" -source = "git+https://github.com/getditto/tracing?branch=ditto#4638ac9c7590a5584cf29c5d1ddb4a249bf48c0d" diff --git a/Cargo.toml b/Cargo.toml index f01e12843c..b1dbfc0e45 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,11 +3,12 @@ path = "src/_lib.rs" [package] name = "safer-ffi" -version = "0.1.9-rc2" # Keep in sync +version = "0.1.9-rc3" # Keep in sync authors = [ "Daniel Henry-Mantilla ", ] edition = "2021" +rust-version = "1.72.1" description = "Write safer FFI code in Rust without polluting it with unsafe code" keywords = [ @@ -65,7 +66,9 @@ futures = [ "dyn-traits", ] -stabby = ["dep:stabby"] +stabby = [ + "dep:stabby", +] tokio = [ "async-compat", @@ -141,10 +144,10 @@ paste.version = "1.0.12" scopeguard.version = "1.1.0" scopeguard.default-features = false -stabby.version = "36.1.1-rc5" +stabby.version = "36.1.1-rc8" stabby.optional = true stabby.default-features = false -stabby.features = ["experimental-ctypes"] +stabby.features = ["experimental-ctypes", "alloc-rs"] tokio.optional = true tokio.version = "1.26.0" @@ -168,7 +171,7 @@ version = "0.0.3" [dependencies.safer_ffi-proc_macros] path = "src/proc_macro" -version = "=0.1.8" # Keep in sync +version = "=0.1.9-rc3" # Keep in sync [workspace] members = [ diff --git a/ffi_tests/Cargo.lock b/ffi_tests/Cargo.lock index 7b7fb9db4c..56632b2788 100644 --- a/ffi_tests/Cargo.lock +++ b/ffi_tests/Cargo.lock @@ -8,6 +8,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + [[package]] name = "ctor" version = "0.2.7" @@ -18,6 +24,12 @@ dependencies = [ "syn 2.0.12", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "ext-trait" version = "1.0.1" @@ -144,6 +156,17 @@ dependencies = [ "slab", ] +[[package]] +name = "getrandom" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + [[package]] name = "ghost" version = "0.1.12" @@ -155,6 +178,22 @@ dependencies = [ "syn 2.0.12", ] +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown", +] + [[package]] name = "inventory" version = "0.3.5" @@ -211,6 +250,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + [[package]] name = "prettyplease" version = "0.1.24" @@ -221,6 +266,15 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "proc-macro-crate" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +dependencies = [ + "toml_edit", +] + [[package]] name = "proc-macro2" version = "1.0.52" @@ -239,9 +293,45 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rustversion" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" + [[package]] name = "safer-ffi" -version = "0.1.8" +version = "0.1.9-rc3" dependencies = [ "futures", "inventory", @@ -250,6 +340,7 @@ dependencies = [ "paste", "safer_ffi-proc_macros", "scopeguard", + "stabby", "uninit", "unwind_safe", "with_builtin_macros", @@ -257,7 +348,7 @@ dependencies = [ [[package]] name = "safer_ffi-proc_macros" -version = "0.1.8" +version = "0.1.9-rc3" dependencies = [ "macro_rules_attribute", "prettyplease", @@ -272,6 +363,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "sha2-const-stable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f179d4e11094a893b82fff208f74d448a7512f99f5a0acbd5c679b705f83ed9" + [[package]] name = "slab" version = "0.4.8" @@ -281,6 +378,40 @@ dependencies = [ "autocfg", ] +[[package]] +name = "stabby" +version = "36.1.1-rc8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08cc900971922b54e6a2538906ec4bb17ae834d99ff9025741c701edf44006ba" +dependencies = [ + "rustversion", + "stabby-abi", +] + +[[package]] +name = "stabby-abi" +version = "36.1.1-rc8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca372c473f8a01399568c4d6d131e6248d71958e38eb2e574b863feedbddac27" +dependencies = [ + "rustversion", + "sha2-const-stable", + "stabby-macros", +] + +[[package]] +name = "stabby-macros" +version = "36.1.1-rc8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80454eabdc8324ded185cd1c91641127f7f7186be3b21ef5a21202affc4544ce" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "rand", + "syn 1.0.109", +] + [[package]] name = "syn" version = "1.0.109" @@ -303,6 +434,23 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "toml_datetime" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" + +[[package]] +name = "toml_edit" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + [[package]] name = "unicode-ident" version = "1.0.8" @@ -324,6 +472,21 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0976c77def3f1f75c4ef892a292c31c0bbe9e3d0702c63044d7c76db298171a3" +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "winnow" +version = "0.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] + [[package]] name = "with_builtin_macros" version = "0.0.3" diff --git a/js_tests/Cargo.lock b/js_tests/Cargo.lock index 2cd306c91a..9a2684a2eb 100644 --- a/js_tests/Cargo.lock +++ b/js_tests/Cargo.lock @@ -76,6 +76,12 @@ dependencies = [ "syn 2.0.12", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "ext-trait" version = "1.0.1" @@ -213,6 +219,17 @@ dependencies = [ "slab", ] +[[package]] +name = "getrandom" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + [[package]] name = "ghost" version = "0.1.12" @@ -237,6 +254,12 @@ dependencies = [ "web-sys", ] +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + [[package]] name = "hermit-abi" version = "0.2.6" @@ -256,6 +279,16 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown", +] + [[package]] name = "inventory" version = "0.3.5" @@ -462,6 +495,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + [[package]] name = "prettyplease" version = "0.1.24" @@ -472,6 +511,15 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "proc-macro-crate" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +dependencies = [ + "toml_edit", +] + [[package]] name = "proc-macro2" version = "1.0.52" @@ -490,6 +538,36 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + [[package]] name = "ref-cast" version = "1.0.15" @@ -537,6 +615,12 @@ dependencies = [ "webpki", ] +[[package]] +name = "rustversion" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" + [[package]] name = "ryu" version = "1.0.13" @@ -545,7 +629,7 @@ checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "safer-ffi" -version = "0.1.8" +version = "0.1.9-rc3" dependencies = [ "cratesio-placeholder-package", "inventory", @@ -555,6 +639,7 @@ dependencies = [ "paste", "safer_ffi-proc_macros", "scopeguard", + "stabby", "uninit", "unwind_safe", "with_builtin_macros", @@ -569,7 +654,7 @@ dependencies = [ [[package]] name = "safer_ffi-proc_macros" -version = "0.1.8" +version = "0.1.9-rc3" dependencies = [ "macro_rules_attribute", "prettyplease", @@ -625,6 +710,12 @@ dependencies = [ "serde", ] +[[package]] +name = "sha2-const-stable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f179d4e11094a893b82fff208f74d448a7512f99f5a0acbd5c679b705f83ed9" + [[package]] name = "slab" version = "0.4.8" @@ -640,6 +731,40 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "stabby" +version = "36.1.1-rc8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08cc900971922b54e6a2538906ec4bb17ae834d99ff9025741c701edf44006ba" +dependencies = [ + "rustversion", + "stabby-abi", +] + +[[package]] +name = "stabby-abi" +version = "36.1.1-rc8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca372c473f8a01399568c4d6d131e6248d71958e38eb2e574b863feedbddac27" +dependencies = [ + "rustversion", + "sha2-const-stable", + "stabby-macros", +] + +[[package]] +name = "stabby-macros" +version = "36.1.1-rc8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80454eabdc8324ded185cd1c91641127f7f7186be3b21ef5a21202affc4544ce" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "rand", + "syn 1.0.109", +] + [[package]] name = "syn" version = "1.0.109" @@ -689,6 +814,23 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "toml_datetime" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" + +[[package]] +name = "toml_edit" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + [[package]] name = "unicode-bidi" version = "0.3.11" @@ -758,6 +900,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + [[package]] name = "wasm-bindgen" version = "0.2.84" @@ -941,6 +1089,15 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +[[package]] +name = "winnow" +version = "0.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] + [[package]] name = "with_builtin_macros" version = "0.0.3" diff --git a/rust-toolchain b/rust-toolchain deleted file mode 100644 index 0834888f55..0000000000 --- a/rust-toolchain +++ /dev/null @@ -1 +0,0 @@ -1.72.0 diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000000..4e0d9f6590 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,5 @@ +[toolchain] +channel = "1.72.1" +targets = [ + "wasm32-unknown-unknown", +] diff --git a/src/_lib.rs b/src/_lib.rs index d3ac62aad5..61779b1255 100644 --- a/src/_lib.rs +++ b/src/_lib.rs @@ -303,6 +303,9 @@ pub mod slice; #[cfg(feature = "stabby")] +#[cfg_attr(all(docs, feature = "nightly"), + doc(cfg(feature = "stabby")) +)] #[path = "stabby/_mod.rs"] pub mod stabby; diff --git a/src/bytes.rs b/src/bytes.rs index fab46f8175..cf61a4cc75 100644 --- a/src/bytes.rs +++ b/src/bytes.rs @@ -526,7 +526,7 @@ impl<'a> TryFrom> for stabby::sync::ArcSlice { type Error = Bytes<'a>; fn try_from(value: Bytes<'a>) -> Result { let data = value.data.cast(); - match core::ptr::eq(value.vtable, &ARC_BYTES_VT) && core::ptr::eq(value.start, data) { + match core::ptr::eq(value.vtable, &STABBY_ARCSLICE_BYTESVT) && core::ptr::eq(value.start, data) { true => unsafe { let value = core::mem::ManuallyDrop::new(value); let arc = stabby::sync::ArcSlice::from_raw(stabby::alloc::AllocSlice { diff --git a/src/layout/_mod.rs b/src/layout/_mod.rs index 4b2bf025ef..e9f0f5c1dc 100644 --- a/src/layout/_mod.rs +++ b/src/layout/_mod.rs @@ -232,7 +232,7 @@ unsafe trait LegacyCType /// "placeholders" such as when monomorphising generics structs or /// arrays. /// - /// This provides the implementation used by [`CType::c_short_name`]`()`. + /// This provides the implementation used by [`LegacyCType::c_short_name`]`()`. /// /// There are no bad implementations of this method, except, /// of course, for the obligation to provide a valid identifier chunk, @@ -297,7 +297,7 @@ unsafe trait LegacyCType /// [`CType`][`trait@CType`]. /// /// The `Display` logic is auto-derived from the implementation of - /// [`CType::c_short_name_fmt`]`()`. + /// [`LegacyCType::c_short_name_fmt`]`()`. #[inline] fn c_short_name () -> short_name_impl_display::ImplDisplay @@ -305,10 +305,10 @@ unsafe trait LegacyCType short_name_impl_display::ImplDisplay { _phantom: PhantomData } } - /// Necessary one-time code for [`CType::c_var`]`()` to make sense. + /// Necessary one-time code for [`LegacyCType::c_var`]`()` to make sense. /// /// Some types, such as `char`, are part of the language, and can be - /// used directly by [`CType::c_var`]`()`. + /// used directly by [`LegacyCType::c_var`]`()`. /// In that case, there is nothing else to _define_, and all is fine. /// /// - That is the default implementation of this method: doing @@ -346,7 +346,7 @@ unsafe trait LegacyCType /// /// # Safety /// - /// Given that the defined types may be used by [`CType::c_var_fmt`]`()`, + /// Given that the defined types may be used by [`LegacyCType::c_var_fmt`]`()`, /// the same safety disclaimers apply. /// /// ## Examples @@ -416,9 +416,9 @@ unsafe trait LegacyCType // } /// The core method of the trait: it provides the implementation to be - /// used by [`CType::c_var`], by bringing a `Formatter` in scope. + /// used by [`LegacyCType::c_var`], by bringing a `Formatter` in scope. /// - /// This provides the implementation used by [`CType::c_var`]`()`. + /// This provides the implementation used by [`LegacyCType::c_var`]`()`. /// /// The implementations are thus much like any classic `Display` impl, /// except that: @@ -515,10 +515,10 @@ unsafe trait LegacyCType ; /// Convenience function for _callers_ / users of types implementing - /// [`CType`][`trait@CType`]. + /// [`LegacyCType`][`trait@LegacyCType`]. /// /// The `Display` logic is auto-derived from the implementation of - /// [`CType::c_var_fmt`]`()`. + /// [`LegacyCType::c_var_fmt`]`()`. #[inline] fn c_var ( var_name: &'_ str, diff --git a/src/layout/macros.rs b/src/layout/macros.rs index 23a8d38069..9a12eba4d1 100644 --- a/src/layout/macros.rs +++ b/src/layout/macros.rs @@ -90,6 +90,8 @@ match_cfg! { /// /// Note: you rarely need to call this macro directly. Instead, look for the /// [`ReprC!`] macro to safely implement [`ReprC`][`trait@crate::layout::ReprC`]. +/// +/// [`ReprC!`]: crate::ReprC! #[macro_export] macro_rules! CType {( $( diff --git a/src/layout/niche.rs b/src/layout/niche.rs index a4b99aed88..4999abb05f 100644 --- a/src/layout/niche.rs +++ b/src/layout/niche.rs @@ -7,7 +7,11 @@ unsafe trait HasNiche : ReprC { fn is_niche (it: &'_ ::CLayout) -> bool - ; + { + // default implementation (the `is_niche()` heuristic does not need to + // be 100% accurate, since it's just a sanity check helper): + Self::is_valid(it).not() + } } unsafe diff --git a/src/option.rs b/src/option.rs index 93cea52255..525dc193c0 100644 --- a/src/option.rs +++ b/src/option.rs @@ -1,4 +1,4 @@ -use crate::ඞ::ConcreteReprC; +use crate::layout::ConcreteReprC; /// An ABI-stable version of `core::option::Option`. /// Its usage is expected to be the same as a standard Option, converting to and from said Option when necessary. @@ -12,7 +12,7 @@ use crate::ඞ::ConcreteReprC; /// [discriminant elision], wherein the `None` value is represented using /// the null bitpattern (_e.g._, the `NULL` pointer). /// -/// [repr_c::Box]: crate::repr_c::Box +/// [repr_c::Box]: crate::prelude::repr_c::Box /// [discriminant elision]: https://doc.rust-lang.org/1.78.0/core/option/index.html#representation #[cfg_attr(feature = "stabby", stabby::stabby)] #[repr(C, u8)] diff --git a/src/proc_macro/Cargo.toml b/src/proc_macro/Cargo.toml index d86a37df9d..0b0470f60f 100644 --- a/src/proc_macro/Cargo.toml +++ b/src/proc_macro/Cargo.toml @@ -4,7 +4,7 @@ proc-macro = true [package] name = "safer_ffi-proc_macros" -version = "0.1.8" # Keep in sync +version = "0.1.9-rc3" # Keep in sync authors = ["Daniel Henry-Mantilla "] edition = "2021" diff --git a/src/stabby/_mod.rs b/src/stabby/_mod.rs index 7756fca039..9b6ffcee7b 100644 --- a/src/stabby/_mod.rs +++ b/src/stabby/_mod.rs @@ -1,28 +1,56 @@ -use stabby::IStable; +use { + ::core::{ + ops::Not, + }, + ::stabby::{ + IStable, + }, + crate::{ + layout::{CType, ReprC, __HasNiche__}, + }, +}; -use crate::ඞ::{CType, ReprC, __HasNiche__}; - -/// Coherence wrapper for a blanket `ReprC` implementation off +/// Coherence wrapper for a blanket [`ReprC`] implementation off /// a [`stabby::IStable`] one, without running into overlapping impls. +/// +/// # A note about SemVer and stability +/// +/// There is a blanket impl of [`ReprC`] for this type, bounded by +/// [`::stabby::IStable`]. This, technically, is a public dependency on +/// `::stabby`, whose major versions could then be technically perceived as +/// breaking for this crate too. +/// +/// This crate takes the opinionated stance not to be deterred from publicly +/// exposing this wrapper nonetheless, trusting the users to know what they're +/// doing. +/// +/// If you are unsure, **do not use this wrapper**. +/// +/// [`::safer-ffi`][crate] waves any responsibility w.r.t. SemVer breakage that +/// may otherwise ensue. +/// +/// [`ReprC`]: trait@ReprC #[stabby::stabby] -pub struct Stabbied(pub T); -unsafe impl ReprC for Stabbied +pub +struct Stabbied /* = */ ( + pub T, +); + +unsafe +impl ReprC for Stabbied where T::CType: CType, { type CLayout = T::CType; fn is_valid(it: &'_ Self::CLayout) -> bool { - !unsafe { T::is_invalid(it as *const _ as *const u8) } + unsafe { T::is_invalid(it as *const _ as *const u8) }.not() } } + unsafe impl> __HasNiche__ for Stabbied where Self: ReprC, -{ - fn is_niche(it: &'_ ::CLayout) -> bool { - !Self::is_valid(it) - } -} +{} mod boxed_impl; mod fatptr_impl;