From f6ca6400d6b25f42f502142f21a43eaf96449dd3 Mon Sep 17 00:00:00 2001 From: Roman Volosatovs Date: Fri, 5 Jul 2024 17:07:43 +0200 Subject: [PATCH] fix(rs-bindgen): always use named lifetime for lists Signed-off-by: Roman Volosatovs --- Cargo.lock | 6 +++--- Cargo.toml | 6 +++--- crates/wit-bindgen-rust-macro/Cargo.toml | 2 +- crates/wit-bindgen-rust/Cargo.toml | 2 +- crates/wit-bindgen-rust/src/interface.rs | 6 +++--- crates/wit-bindgen/Cargo.toml | 2 +- src/bin/wit-bindgen-wrpc.rs | 2 +- tests/rust.rs | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e85cd3a72..ee90b0075 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3565,7 +3565,7 @@ dependencies = [ [[package]] name = "wit-bindgen-wrpc" -version = "0.4.3" +version = "0.4.4" dependencies = [ "anyhow", "bitflags 2.6.0", @@ -3593,7 +3593,7 @@ dependencies = [ [[package]] name = "wit-bindgen-wrpc-rust" -version = "0.4.3" +version = "0.4.4" dependencies = [ "anyhow", "clap", @@ -3609,7 +3609,7 @@ dependencies = [ [[package]] name = "wit-bindgen-wrpc-rust-macro" -version = "0.4.3" +version = "0.4.4" dependencies = [ "anyhow", "prettyplease", diff --git a/Cargo.toml b/Cargo.toml index 50fdfad70..0fb976f5e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -128,10 +128,10 @@ wasmtime = { version = "22", default-features = false } wasmtime-wasi = { version = "22", default-features = false } wit-bindgen = { version = "0.27", default-features = false } wit-bindgen-core = { version = "0.27", default-features = false } -wit-bindgen-wrpc = { version = "0.4.3", default-features = false, path = "./crates/wit-bindgen" } +wit-bindgen-wrpc = { version = "0.4.4", default-features = false, path = "./crates/wit-bindgen" } wit-bindgen-wrpc-go = { version = "0.2", default-features = false, path = "./crates/wit-bindgen-go" } -wit-bindgen-wrpc-rust = { version = "0.4.3", default-features = false, path = "./crates/wit-bindgen-rust" } -wit-bindgen-wrpc-rust-macro = { version = "0.4.3", default-features = false, path = "./crates/wit-bindgen-rust-macro" } +wit-bindgen-wrpc-rust = { version = "0.4.4", default-features = false, path = "./crates/wit-bindgen-rust" } +wit-bindgen-wrpc-rust-macro = { version = "0.4.4", default-features = false, path = "./crates/wit-bindgen-rust-macro" } wit-component = { version = "0.212", default-features = false } wit-parser = { version = "0.212", default-features = false } wrpc-cli = { version = "0.2", path = "./crates/cli", default-features = false } diff --git a/crates/wit-bindgen-rust-macro/Cargo.toml b/crates/wit-bindgen-rust-macro/Cargo.toml index f052ca1ed..892ef2882 100644 --- a/crates/wit-bindgen-rust-macro/Cargo.toml +++ b/crates/wit-bindgen-rust-macro/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wit-bindgen-wrpc-rust-macro" -version = "0.4.3" +version = "0.4.4" description = """ Procedural macro paired with the `wit-bindgen-wrpc` crate. """ diff --git a/crates/wit-bindgen-rust/Cargo.toml b/crates/wit-bindgen-rust/Cargo.toml index c34056e50..06c69daab 100644 --- a/crates/wit-bindgen-rust/Cargo.toml +++ b/crates/wit-bindgen-rust/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wit-bindgen-wrpc-rust" -version = "0.4.3" +version = "0.4.4" description = """ Rust bindings generator for wRPC, typically used through the `wit-bindgen-wrpc` crate's `generate!` macro. diff --git a/crates/wit-bindgen-rust/src/interface.rs b/crates/wit-bindgen-rust/src/interface.rs index 0aff90c5a..0ef97b98a 100644 --- a/crates/wit-bindgen-rust/src/interface.rs +++ b/crates/wit-bindgen-rust/src/interface.rs @@ -810,7 +810,7 @@ pub async fn serve_interface( if owned { self.push_str("String"); } else { - self.push_str("&str"); + self.push_str("&'a str"); } } } @@ -916,9 +916,9 @@ pub async fn serve_interface( self.push_str(">"); } } else if is_ty(self.resolve, Type::U8, ty) { - uwrite!(self.src, "&{bytes}::Bytes", bytes = self.gen.bytes_path()); + uwrite!(self.src, "&'a {bytes}::Bytes", bytes = self.gen.bytes_path()); } else { - self.push_str("&["); + self.push_str("&'a ["); self.print_ty(ty, false, submodule); self.push_str("]"); } diff --git a/crates/wit-bindgen/Cargo.toml b/crates/wit-bindgen/Cargo.toml index 8d8fdf80e..9fbfb1d52 100644 --- a/crates/wit-bindgen/Cargo.toml +++ b/crates/wit-bindgen/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wit-bindgen-wrpc" -version = "0.4.3" +version = "0.4.4" description = """ Rust bindings generator for wRPC. """ diff --git a/src/bin/wit-bindgen-wrpc.rs b/src/bin/wit-bindgen-wrpc.rs index 1d3fbd862..0fb7d65bb 100644 --- a/src/bin/wit-bindgen-wrpc.rs +++ b/src/bin/wit-bindgen-wrpc.rs @@ -127,7 +127,7 @@ fn gen_world( files: &mut Files, ) -> Result<()> { let mut resolve = Resolve::default(); - for features in opts.features.iter() { + for features in &opts.features { for feature in features .split(',') .flat_map(|s| s.split_whitespace()) diff --git a/tests/rust.rs b/tests/rust.rs index 744cbf3ce..7246adda2 100644 --- a/tests/rust.rs +++ b/tests/rust.rs @@ -762,7 +762,7 @@ where join!( async { info!("receiving `a`"); - assert_eq!(a.collect::>().await.concat(), [0xc0, 0xff, 0xee]) + assert_eq!(a.collect::>().await.concat(), [0xc0, 0xff, 0xee]); }, async { info!("receiving `b`");