Update to the latest wit-parser (#5694)
This notably pulls in support in WIT for types-in-worlds.
This commit is contained in:
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -4062,9 +4062,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wit-parser"
|
name = "wit-parser"
|
||||||
version = "0.4.1"
|
version = "0.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2e60c4242d4cf4394fac7587c0d96c39b3c0fb09e638815c3f244f6bb5356f04"
|
checksum = "896b2d88f139eb303e8e76fd72925115b11aad1944887ec2e5b2eeac1e58526f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"id-arena",
|
"id-arena",
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ wasmprinter = "0.2.49"
|
|||||||
wasm-encoder = "0.22.0"
|
wasm-encoder = "0.22.0"
|
||||||
wasm-smith = "0.12.0"
|
wasm-smith = "0.12.0"
|
||||||
wasm-mutate = "0.2.16"
|
wasm-mutate = "0.2.16"
|
||||||
wit-parser = "0.4.1"
|
wit-parser = "0.5.0"
|
||||||
windows-sys = "0.42.0"
|
windows-sys = "0.42.0"
|
||||||
env_logger = "0.9"
|
env_logger = "0.9"
|
||||||
rustix = "0.36.7"
|
rustix = "0.36.7"
|
||||||
|
|||||||
14
crates/component-macro/tests/codegen/worlds-with-types.wit
Normal file
14
crates/component-macro/tests/codegen/worlds-with-types.wit
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
interface i {
|
||||||
|
type t = u16
|
||||||
|
}
|
||||||
|
|
||||||
|
default world foo {
|
||||||
|
use self.i.{t as u}
|
||||||
|
|
||||||
|
type t = u32
|
||||||
|
|
||||||
|
record r {
|
||||||
|
}
|
||||||
|
|
||||||
|
export f: func() -> tuple<t, u, r>
|
||||||
|
}
|
||||||
@@ -132,6 +132,7 @@ impl Wasmtime {
|
|||||||
);
|
);
|
||||||
Import::Interface { snake }
|
Import::Interface { snake }
|
||||||
}
|
}
|
||||||
|
WorldItem::Type(_) => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.imports.push(import);
|
self.imports.push(import);
|
||||||
@@ -149,6 +150,12 @@ impl Wasmtime {
|
|||||||
self.exports.funcs.push(body);
|
self.exports.funcs.push(body);
|
||||||
(format!("wasmtime::component::Func"), getter)
|
(format!("wasmtime::component::Func"), getter)
|
||||||
}
|
}
|
||||||
|
WorldItem::Type(ty) => {
|
||||||
|
gen.define_type(name, *ty);
|
||||||
|
let body = mem::take(&mut gen.src);
|
||||||
|
self.src.push_str(&body);
|
||||||
|
return;
|
||||||
|
}
|
||||||
WorldItem::Interface(id) => {
|
WorldItem::Interface(id) => {
|
||||||
gen.current_interface = Some(*id);
|
gen.current_interface = Some(*id);
|
||||||
gen.types(*id);
|
gen.types(*id);
|
||||||
@@ -465,7 +472,11 @@ impl<'a> InterfaceGenerator<'a> {
|
|||||||
|
|
||||||
fn types(&mut self, id: InterfaceId) {
|
fn types(&mut self, id: InterfaceId) {
|
||||||
for (name, id) in self.resolve.interfaces[id].types.iter() {
|
for (name, id) in self.resolve.interfaces[id].types.iter() {
|
||||||
let id = *id;
|
self.define_type(name, *id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn define_type(&mut self, name: &str, id: TypeId) {
|
||||||
let ty = &self.resolve.types[id];
|
let ty = &self.resolve.types[id];
|
||||||
match &ty.kind {
|
match &ty.kind {
|
||||||
TypeDefKind::Record(record) => self.type_record(id, name, record, &ty.docs),
|
TypeDefKind::Record(record) => self.type_record(id, name, record, &ty.docs),
|
||||||
@@ -483,7 +494,6 @@ impl<'a> InterfaceGenerator<'a> {
|
|||||||
TypeDefKind::Unknown => unreachable!(),
|
TypeDefKind::Unknown => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fn type_record(&mut self, id: TypeId, _name: &str, record: &Record, docs: &Docs) {
|
fn type_record(&mut self, id: TypeId, _name: &str, record: &Record, docs: &Docs) {
|
||||||
let info = self.info(id);
|
let info = self.info(id);
|
||||||
|
|||||||
@@ -55,6 +55,9 @@ impl Types {
|
|||||||
self.type_info_func(resolve, f, import);
|
self.type_info_func(resolve, f, import);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
WorldItem::Type(id) => {
|
||||||
|
self.type_id_info(resolve, *id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1167,3 +1167,9 @@ criteria = "safe-to-deploy"
|
|||||||
version = "0.4.1"
|
version = "0.4.1"
|
||||||
notes = "The Bytecode Alliance is the author of this crate."
|
notes = "The Bytecode Alliance is the author of this crate."
|
||||||
|
|
||||||
|
[[audits.wit-parser]]
|
||||||
|
who = "Alex Crichton <alex@alexcrichton.com>"
|
||||||
|
criteria = "safe-to-deploy"
|
||||||
|
version = "0.5.0"
|
||||||
|
notes = "The Bytecode Alliance is the author of this crate."
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user