Skip to content

Commit 071299d

Browse files
committed
merge: wit-bindgen 0.42
Merge upstream wit-bindgen 0.42.0 into the vendored bindgen subtree. - Bump wit-bindgen-core 0.41 -> 0.42 and wit-parser 0.227 -> 0.230. - Adapt to the wit-parser 0.230 API break: `TypeDefKind` gained a `FixedSizeList(Type, u32)` variant. Handle it in the introspection async-path walk like a `List` (element indexed by a wildcard path), and add arms to the Rust and Go generators' type/codec matches. Full fixed-size-list code generation is not supported yet (upstream adds Rust support in bytecodealliance/wit-bindgen#1277, ported later at 0.52), so the generator arms panic with an "unsupported" message; no fixture exercises them. - Port upstream features bytecodealliance/wit-bindgen#1244 + bytecodealliance/wit-bindgen#1270 (`serde::Deserialize` for the bindgen config): gate `serde::Deserialize` derives on `Opts` (`serde(default, rename_all = "kebab-case")`) and `WithOption` (`rename_all = "kebab-case"`) behind a new optional `serde` feature, matching upstream. wRPC has neither `ExportKey`/`AsyncConfig`/`Ownership` config types nor an `async_` option, so only `Opts`/`WithOption` apply. Non-carries (not applicable to wRPC, dropped from the merge): - more `wit-bindgen test` subcommand backends (`crates/test/src/{csharp, moonbit}.rs`, `crates/test/LICENSE-*`) and the new `tests/runtime-async/` guest runtime test tree; wRPC keeps its own `wrpc-test` crate. - the async-task / futures-stream-ABI refactors (bytecodealliance/wit-bindgen#1233/bytecodealliance/wit-bindgen#1241/bytecodealliance/wit-bindgen#1249/bytecodealliance/wit-bindgen#1260/bytecodealliance/wit-bindgen#1264/ bytecodealliance/wit-bindgen#1268/bytecodealliance/wit-bindgen#1278/bytecodealliance/wit-bindgen#1279/bytecodealliance/wit-bindgen#1247/bytecodealliance/wit-bindgen#1240/bytecodealliance/wit-bindgen#1291/bytecodealliance/wit-bindgen#1306 etc.) and bytecodealliance/wit-bindgen#1214's canonical-ABI guest-code warning squashing do not apply to wRPC's transport-stub generator. rust codegen (237) and go codegen (79) tests pass; `cargo clippy --workspace` (and `--features serde`) and `cargo doc --workspace` are clean; wasmtime and all examples build. Assisted-by: claude:claude-opus-4-8 Upstream diff: bytecodealliance/wit-bindgen@v0.41.0...v0.42.0
2 parents fe2745d + 52556d6 commit 071299d

13 files changed

Lines changed: 168 additions & 56 deletions

File tree

Cargo.lock

Lines changed: 22 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,14 @@ wasmtime-cli-flags = { version = "45", default-features = false }
184184
wasmtime-wasi = { version = "45", default-features = false }
185185
wasmtime-wasi-http = { version = "45", default-features = false }
186186
wit-bindgen = { version = "0.45", default-features = false }
187-
wit-bindgen-core = { version = "0.41", default-features = false }
187+
wit-bindgen-core = { version = "0.42", default-features = false }
188188
wit-bindgen-wrpc = { version = "0.11", default-features = false, path = "./crates/wit-bindgen" }
189189
wit-bindgen-wrpc-go = { version = "0.13", default-features = false, path = "./crates/wit-bindgen-go" }
190190
wit-bindgen-wrpc-rust = { version = "0.11", default-features = false, path = "./crates/wit-bindgen-rust" }
191191
wit-bindgen-wrpc-rust-macro = { version = "0.11", default-features = false, path = "./crates/wit-bindgen-rust-macro" }
192192
wit-bindgen-wrpc-test = { version = "0.1", default-features = false, path = "./crates/wit-bindgen-test" }
193193
wit-component = { version = "0.252", default-features = false }
194-
wit-parser = { version = "0.227", default-features = false }
194+
wit-parser = { version = "0.230", default-features = false }
195195
wrpc-cli = { version = "0.8", path = "./crates/cli", default-features = false }
196196
wrpc-introspect = { version = "0.7", default-features = false, path = "./crates/introspect" }
197197
wrpc-nats = { version = "0.1", path = "./crates/nats", default-features = false }

crates/introspect/src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,18 @@ pub fn async_paths_tyid(resolve: &Resolve, id: TypeId) -> (BTreeSet<VecDeque<Opt
123123
}
124124
(paths, false)
125125
}
126+
TypeDefKind::FixedSizeList(ty, _) => {
127+
let mut paths = BTreeSet::default();
128+
let (nested, fut) = async_paths_ty(resolve, ty);
129+
for mut path in nested {
130+
path.push_front(None);
131+
paths.insert(path);
132+
}
133+
if fut {
134+
paths.insert(vec![None].into());
135+
}
136+
(paths, false)
137+
}
126138
TypeDefKind::Option(ty) => async_paths_ty(resolve, ty),
127139
TypeDefKind::Result(ty) => {
128140
let mut paths = BTreeSet::default();

crates/wit-bindgen-go/src/interface.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,7 @@ impl InterfaceGenerator<'_> {
14031403
TypeDefKind::Option(ty) => self.print_read_option(ty, reader, path),
14041404
TypeDefKind::Result(ty) => self.print_read_result(ty, reader, path),
14051405
TypeDefKind::List(ty) => self.print_read_list(ty, reader, path),
1406+
TypeDefKind::FixedSizeList(..) => panic!("unsupported type: fixed size list"),
14061407
TypeDefKind::Future(ty) => self.print_read_future(ty, reader, path),
14071408
TypeDefKind::Stream(ty) => self.print_read_stream(ty, reader, path),
14081409
TypeDefKind::Type(ty) => {
@@ -3332,6 +3333,9 @@ func ServeInterface(s {wrpc}.Server, h Handler) (stop func() error, err error) {
33323333
}
33333334
match &ty.kind {
33343335
TypeDefKind::List(ty) => self.print_list(ty),
3336+
TypeDefKind::FixedSizeList(..) => {
3337+
panic!("unsupported anonymous type reference: fixed size list")
3338+
}
33353339
TypeDefKind::Option(ty) => self.print_option(ty, decl),
33363340
TypeDefKind::Result(ty) => self.print_result(ty),
33373341
TypeDefKind::Variant(_) => panic!("unsupported anonymous variant"),

crates/wit-bindgen-rust/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@ repository.workspace = true
1717
test = false
1818
doctest = false
1919

20+
[features]
21+
serde = ["dep:serde"]
22+
2023
[dependencies]
2124
anyhow = { workspace = true }
2225
clap = { workspace = true, features = ["derive", "std"], optional = true }
2326
heck = { workspace = true }
2427
prettyplease = { workspace = true }
28+
serde = { workspace = true, features = ["derive"], optional = true }
2529
syn = { workspace = true, features = ["parsing"] }
2630
wit-bindgen-core = { workspace = true }
2731
wrpc-introspect = { workspace = true }

crates/wit-bindgen-rust/src/interface.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,9 @@ pub fn serve_interface<'a, T: {wrpc_transport}::Serve>(
10561056
}
10571057
match &ty.kind {
10581058
TypeDefKind::List(ty) => self.print_list(ty, owned, submodule),
1059+
TypeDefKind::FixedSizeList(..) => {
1060+
panic!("unsupported anonymous type reference: fixed size list")
1061+
}
10591062
TypeDefKind::Option(ty) => self.print_option(ty, owned, submodule),
10601063
TypeDefKind::Result(ty) => self.print_result(ty, owned, submodule),
10611064
TypeDefKind::Variant(_) => panic!("unsupported anonymous variant"),
@@ -2279,7 +2282,7 @@ mod {mod_name} {{
22792282
.additional_derive_ignore
22802283
.contains(&name.to_kebab_case())
22812284
{
2282-
derives.extend(self.r#gen.opts.additional_derive_attributes.to_vec());
2285+
derives.extend(self.r#gen.opts.additional_derive_attributes.iter().cloned());
22832286
}
22842287
derives.extend(
22852288
[

crates/wit-bindgen-rust/src/lib.rs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,18 @@ fn parse_with(s: &str) -> Result<(String, WithOption), String> {
101101

102102
#[derive(Default, Debug, Clone)]
103103
#[cfg_attr(feature = "clap", derive(clap::Parser))]
104+
#[cfg_attr(
105+
feature = "serde",
106+
derive(serde::Deserialize),
107+
serde(default, rename_all = "kebab-case")
108+
)]
104109
pub struct Opts {
105110
/// Whether or not a formatter is executed to format generated code.
106111
#[cfg_attr(feature = "clap", arg(long))]
107112
pub format: bool,
108113

109114
/// Names of functions to skip generating bindings for.
110-
#[cfg_attr(feature = "clap", arg(long))]
115+
#[cfg_attr(feature = "clap", arg(long, value_name = "NAME"))]
111116
pub skip: Vec<String>,
112117

113118
/// The optional path to the bitflags crate to use.
@@ -120,7 +125,7 @@ pub struct Opts {
120125
/// specified multiple times to add multiple attributes.
121126
///
122127
/// These derive attributes will be added to any generated structs or enums
123-
#[cfg_attr(feature = "clap", arg(long, short = 'd'))]
128+
#[cfg_attr(feature = "clap", arg(long, short = 'd', value_name = "DERIVE"))]
124129
pub additional_derive_attributes: Vec<String>,
125130

126131
/// Variants and records to ignore when applying additional derive attributes.
@@ -129,7 +134,7 @@ pub struct Opts {
129134
/// This feature allows some variants and records to use types for which adding traits will cause
130135
/// compilation to fail, such as serde::Deserialize on wasi:io/streams.
131136
///
132-
#[cfg_attr(feature = "clap", arg(long))]
137+
#[cfg_attr(feature = "clap", arg(long, value_name = "NAME"))]
133138
pub additional_derive_ignore: Vec<String>,
134139

135140
/// Remapping of interface names to rust module names.
@@ -152,31 +157,31 @@ pub struct Opts {
152157
/// The optional path to the `anyhow` crate to use.
153158
///
154159
/// This defaults to `wit_bindgen_wrpc::anyhow`.
155-
#[cfg_attr(feature = "clap", arg(long))]
160+
#[cfg_attr(feature = "clap", arg(long, value_name = "PATH"))]
156161
pub anyhow_path: Option<String>,
157162

158163
/// The optional path to the `bytes` crate to use.
159164
///
160165
/// This defaults to `wit_bindgen_wrpc::bytes`.
161-
#[cfg_attr(feature = "clap", arg(long))]
166+
#[cfg_attr(feature = "clap", arg(long, value_name = "PATH"))]
162167
pub bytes_path: Option<String>,
163168

164169
/// The optional path to the `futures` crate to use.
165170
///
166171
/// This defaults to `wit_bindgen_wrpc::futures`.
167-
#[cfg_attr(feature = "clap", arg(long))]
172+
#[cfg_attr(feature = "clap", arg(long, value_name = "PATH"))]
168173
pub futures_path: Option<String>,
169174

170175
/// The optional path to the `tokio` crate to use.
171176
///
172177
/// This defaults to `wit_bindgen_wrpc::tokio`.
173-
#[cfg_attr(feature = "clap", arg(long))]
178+
#[cfg_attr(feature = "clap", arg(long, value_name = "PATH"))]
174179
pub tokio_path: Option<String>,
175180

176181
/// The optional path to the `tokio-util` crate to use.
177182
///
178183
/// This defaults to `wit_bindgen_wrpc::tokio_util`.
179-
#[cfg_attr(feature = "clap", arg(long))]
184+
#[cfg_attr(feature = "clap", arg(long, value_name = "PATH"))]
180185
pub tokio_util_path: Option<String>,
181186

182187
/// The optional path to the `tracing` crate to use.
@@ -773,6 +778,11 @@ enum Identifier<'a> {
773778

774779
/// Options for with "with" remappings.
775780
#[derive(Debug, Clone)]
781+
#[cfg_attr(
782+
feature = "serde",
783+
derive(serde::Deserialize),
784+
serde(rename_all = "kebab-case")
785+
)]
776786
pub enum WithOption {
777787
Path(String),
778788
Generate,

0 commit comments

Comments
 (0)