diff --git a/crates/cpp/tests/native_resources/rust/Cargo.lock b/crates/cpp/tests/native_resources/rust/Cargo.lock index fcfcb721c..5e8e19daf 100644 --- a/crates/cpp/tests/native_resources/rust/Cargo.lock +++ b/crates/cpp/tests/native_resources/rust/Cargo.lock @@ -184,18 +184,18 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "wasm-encoder" -version = "0.201.0" +version = "0.202.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9c7d2731df60006819b013f64ccc2019691deccf6e11a1804bc850cd6748f1a" +checksum = "bfd106365a7f5f7aa3c1916a98cbb3ad477f5ff96ddb130285a91c6e7429e67a" dependencies = [ "leb128", ] [[package]] name = "wasm-metadata" -version = "0.201.0" +version = "0.202.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fd83062c17b9f4985d438603cde0a5e8c5c8198201a6937f778b607924c7da2" +checksum = "094aea3cb90e09f16ee25a4c0e324b3e8c934e7fd838bfa039aef5352f44a917" dependencies = [ "anyhow", "indexmap", @@ -204,24 +204,14 @@ dependencies = [ "serde_json", "spdx", "wasm-encoder", - "wasmparser 0.201.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser", ] [[package]] name = "wasmparser" -version = "0.201.0" +version = "0.202.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84e5df6dba6c0d7fafc63a450f1738451ed7a0b52295d83e868218fa286bf708" -dependencies = [ - "bitflags", - "indexmap", - "semver", -] - -[[package]] -name = "wasmparser" -version = "0.201.0" -source = "git+https://github.com/bytecodealliance/wasm-tools#9c01485c2713d926e8f5b67b3e6f62f792da8ba7" +checksum = "d6998515d3cf3f8b980ef7c11b29a9b1017d4cf86b99ae93b546992df9931413" dependencies = [ "bitflags", "indexmap", @@ -230,16 +220,15 @@ dependencies = [ [[package]] name = "wit-bindgen" -version = "0.22.0" +version = "0.24.0" dependencies = [ - "bitflags", "wit-bindgen-rt", "wit-bindgen-rust-macro", ] [[package]] name = "wit-bindgen-core" -version = "0.22.0" +version = "0.24.0" dependencies = [ "anyhow", "wit-parser", @@ -247,11 +236,14 @@ dependencies = [ [[package]] name = "wit-bindgen-rt" -version = "0.22.0" +version = "0.24.0" +dependencies = [ + "bitflags", +] [[package]] name = "wit-bindgen-rust" -version = "0.22.0" +version = "0.24.0" dependencies = [ "anyhow", "heck", @@ -263,7 +255,7 @@ dependencies = [ [[package]] name = "wit-bindgen-rust-macro" -version = "0.22.0" +version = "0.24.0" dependencies = [ "anyhow", "proc-macro2", @@ -275,9 +267,9 @@ dependencies = [ [[package]] name = "wit-component" -version = "0.201.0" +version = "0.202.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "421c0c848a0660a8c22e2fd217929a0191f14476b68962afd2af89fd22e39825" +checksum = "0c836b1fd9932de0431c1758d8be08212071b6bba0151f7bac826dbc4312a2a9" dependencies = [ "anyhow", "bitflags", @@ -288,14 +280,15 @@ dependencies = [ "serde_json", "wasm-encoder", "wasm-metadata", - "wasmparser 0.201.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser", "wit-parser", ] [[package]] name = "wit-parser" -version = "0.201.0" -source = "git+https://github.com/bytecodealliance/wasm-tools#9c01485c2713d926e8f5b67b3e6f62f792da8ba7" +version = "0.202.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "744237b488352f4f27bca05a10acb79474415951c450e52ebd0da784c1df2bcc" dependencies = [ "anyhow", "id-arena", @@ -306,5 +299,10 @@ dependencies = [ "serde_derive", "serde_json", "unicode-xid", - "wasmparser 0.201.0 (git+https://github.com/bytecodealliance/wasm-tools)", + "wasmparser", ] + +[[patch.unused]] +name = "wit-parser" +version = "0.201.0" +source = "git+https://github.com/bytecodealliance/wasm-tools#9c01485c2713d926e8f5b67b3e6f62f792da8ba7" diff --git a/crates/cpp/tests/native_resources/rust/src/the_world.rs b/crates/cpp/tests/native_resources/rust/src/the_world.rs index 05ed53064..c80b4a3a4 100644 --- a/crates/cpp/tests/native_resources/rust/src/the_world.rs +++ b/crates/cpp/tests/native_resources/rust/src/the_world.rs @@ -1,4 +1,4 @@ -// Generated by `wit-bindgen` 0.23.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.24.0. DO NOT EDIT! // Options used: #[allow(dead_code)] pub mod foo { @@ -294,7 +294,7 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_borrows_cabi(arg0: *mut u8,) {#[cfg(target_arch="wasm32")] + pub unsafe fn _export_borrows_cabi(arg0: *const u8,) {#[cfg(target_arch="wasm32")] _rt::run_ctors_once();T::borrows(RBorrow::lift(arg0 as usize)); } #[doc(hidden)] @@ -314,29 +314,25 @@ pub trait GuestR: 'static { unsafe fn _resource_new(val: *mut u8) -> u32 where Self: Sized { - { - #[link(wasm_import_module = "[export]foo:foo/resources")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "[resource-new]r")] - fn X5BexportX5DfooX3AfooX2FresourcesX00X5Bresource_newX5Dr(_: *mut u8) -> u32; - } - X5BexportX5DfooX3AfooX2FresourcesX00X5Bresource_newX5Dr(val) + #[link(wasm_import_module = "[export]foo:foo/resources")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "[resource-new]r")] + fn X5BexportX5DfooX3AfooX2FresourcesX00X5Bresource_newX5Dr(_: *mut u8) -> u32; } + X5BexportX5DfooX3AfooX2FresourcesX00X5Bresource_newX5Dr(val) } #[doc(hidden)] fn _resource_rep(handle: u32) -> *mut u8 where Self: Sized { - { - #[link(wasm_import_module = "[export]foo:foo/resources")] - extern "C" { - #[cfg_attr(target_arch = "wasm32", link_name = "[resource-rep]r")] - fn X5BexportX5DfooX3AfooX2FresourcesX00X5Bresource_repX5Dr(_: u32) -> *mut u8; - } - unsafe { - X5BexportX5DfooX3AfooX2FresourcesX00X5Bresource_repX5Dr(handle) - } + #[link(wasm_import_module = "[export]foo:foo/resources")] + extern "C" { + #[cfg_attr(target_arch = "wasm32", link_name = "[resource-rep]r")] + fn X5BexportX5DfooX3AfooX2FresourcesX00X5Bresource_repX5Dr(_: u32) -> *mut u8; + } + unsafe { + X5BexportX5DfooX3AfooX2FresourcesX00X5Bresource_repX5Dr(handle) } } @@ -366,7 +362,7 @@ macro_rules! __export_foo_foo_resources_cabi{ } #[cfg_attr(target_arch = "wasm32", export_name = "foo:foo/resources#borrows")] #[cfg_attr(not(target_arch = "wasm32"), no_mangle)] - unsafe extern "C" fn fooX3AfooX2FresourcesX23borrows(arg0: *mut u8,) { + unsafe extern "C" fn fooX3AfooX2FresourcesX23borrows(arg0: *const u8,) { $($path_to_types)*::_export_borrows_cabi::<$ty>(arg0) } #[cfg_attr(target_arch = "wasm32", export_name = "foo:foo/resources#consume")] @@ -601,7 +597,7 @@ macro_rules! __export_the_world_impl { pub(crate) use __export_the_world_impl as export; #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:wit-bindgen:0.23.0:the-world:encoded world"] +#[link_section = "component-type:wit-bindgen:0.24.0:the-world:encoded world"] #[doc(hidden)] pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 460] = *b"\ \0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xcc\x02\x01A\x02\x01\ @@ -615,7 +611,7 @@ r.add\x01\x04\x01@\0\0\x01\x04\0\x06create\x01\x05\x01@\x01\x01o\x03\x01\0\x04\0 \x07borrows\x01\x06\x01@\x01\x01o\x01\x01\0\x04\0\x07consume\x01\x07\x04\x01\x11\ foo:foo/resources\x05\x01\x04\x01\x11foo:foo/the-world\x04\0\x0b\x0f\x01\0\x09th\ e-world\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.20\ -2.0\x10wit-bindgen-rust\x060.23.0"; +2.0\x10wit-bindgen-rust\x060.24.0"; #[inline(never)] #[doc(hidden)] diff --git a/crates/rust/src/interface.rs b/crates/rust/src/interface.rs index 39b60dc96..0c31b77f7 100644 --- a/crates/rust/src/interface.rs +++ b/crates/rust/src/interface.rs @@ -218,43 +218,25 @@ impl InterfaceGenerator<'_> { unsafe fn _resource_new(val: *mut u8) -> u32 where Self: Sized {{ - #[cfg(not(target_arch = "wasm32"))] - {{ - let _ = val; - unreachable!(); - }} - - #[cfg(target_arch = "wasm32")] - {{ - #[link(wasm_import_module = "[export]{module}")] - extern "C" {{ - #[cfg_attr(target_arch = "wasm32", link_name = "[resource-new]{resource_name}")] - fn {external_new}(_: *mut u8) -> u32; - }} - {external_new}(val) + #[link(wasm_import_module = "[export]{module}")] + extern "C" {{ + #[cfg_attr(target_arch = "wasm32", link_name = "[resource-new]{resource_name}")] + fn {external_new}(_: *mut u8) -> u32; }} + {external_new}(val) }} #[doc(hidden)] fn _resource_rep(handle: u32) -> *mut u8 where Self: Sized {{ - #[cfg(not(target_arch = "wasm32"))] - {{ - let _ = handle; - unreachable!(); + #[link(wasm_import_module = "[export]{module}")] + extern "C" {{ + #[cfg_attr(target_arch = "wasm32", link_name = "[resource-rep]{resource_name}")] + fn {external_rep}(_: u32) -> *mut u8; }} - - #[cfg(target_arch = "wasm32")] - {{ - #[link(wasm_import_module = "[export]{module}")] - extern "C" {{ - #[cfg_attr(target_arch = "wasm32", link_name = "[resource-rep]{resource_name}")] - fn {external_rep}(_: u32) -> *mut u8; - }} - unsafe {{ - {external_rep}(handle) - }} + unsafe {{ + {external_rep}(handle) }} }}