From fcd3242c3a5687f49d2c99f227621d0f9d3cf2b5 Mon Sep 17 00:00:00 2001 From: "Jiaxiao Zhou (Mossaka)" Date: Wed, 23 Aug 2023 01:16:48 -0700 Subject: [PATCH 01/40] add serialize to all the exported structs Signed-off-by: Jiaxiao Zhou (Mossaka) --- Cargo.lock | 14 ++- Cargo.toml | 26 +---- crates/wit-component/src/decoding.rs | 6 +- crates/wit-component/src/validation.rs | 2 +- crates/wit-parser/Cargo.toml | 6 +- crates/wit-parser/src/ast.rs | 2 +- crates/wit-parser/src/lib.rs | 83 ++++++++++------ crates/wit-parser/src/resolve.rs | 129 ++++++++++++++++++++++++- crates/wit-parser/src/version.rs | 58 +++++++++++ crates/wit-parser/tests/all.rs | 1 + src/bin/wasm-tools/component.rs | 19 ++++ src/lib.rs | 2 + 12 files changed, 282 insertions(+), 66 deletions(-) create mode 100644 crates/wit-parser/src/version.rs diff --git a/Cargo.lock b/Cargo.lock index 9047ce013c..ec05a070c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -807,6 +807,14 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" +[[package]] +name = "id-arena" +version = "2.2.1" +source = "git+https://github.com/Mossaka/id-arena-fork?rev=55c80c6deb4e2aea07002a21bddaaf985dbf7590#55c80c6deb4e2aea07002a21bddaaf985dbf7590" +dependencies = [ + "serde", +] + [[package]] name = "idna" version = "0.4.0" @@ -2375,7 +2383,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "541efa2046e544de53a9da1e2f6299e63079840360c9e106f1f8275a97771318" dependencies = [ "anyhow", - "id-arena", + "id-arena 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 2.0.0", "log", "pulldown-cmark", @@ -2390,13 +2398,15 @@ version = "0.11.0" dependencies = [ "anyhow", "env_logger", - "id-arena", + "id-arena 2.2.1 (git+https://github.com/Mossaka/id-arena-fork?rev=55c80c6deb4e2aea07002a21bddaaf985dbf7590)", "indexmap 2.0.0", "log", "pretty_assertions", "pulldown-cmark", "rayon", "semver", + "serde", + "serde_json", "unicode-xid", "url", ] diff --git a/Cargo.toml b/Cargo.toml index 90738fed38..c341658e5a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -134,23 +134,7 @@ harness = false [features] # By default, all subcommands are built -default = [ - 'shrink', - 'smith', - 'mutate', - 'validate', - 'print', - 'parse', - 'dump', - 'objdump', - 'strip', - 'compose', - 'demangle', - 'component', - 'metadata', - 'wit-smith', - 'addr2line', -] +default = ['shrink', 'smith', 'mutate', 'validate', 'print', 'parse', 'dump', 'objdump', 'strip', 'compose', 'demangle', 'component', 'metadata', 'wit-smith', 'addr2line'] # Each subcommand is gated behind a feature and lists the dependencies it needs validate = ['dep:wasmparser', 'rayon'] @@ -164,13 +148,7 @@ objdump = ['dep:wasmparser'] strip = ['wasm-encoder', 'dep:wasmparser', 'regex'] compose = ['wasm-compose', 'dep:wasmparser'] demangle = ['rustc-demangle', 'cpp_demangle', 'dep:wasmparser', 'wasm-encoder'] -component = [ - 'wit-component', - 'wit-parser', - 'wast', - 'wasm-encoder', - 'dep:wasmparser', -] +component = ['wit-component', 'wit-parser', 'wast', 'wasm-encoder', 'dep:wasmparser'] metadata = ['dep:wasmparser', 'wasm-metadata', 'serde_json'] wit-smith = ['dep:wit-smith', 'arbitrary'] addr2line = ['dep:addr2line', 'dep:gimli', 'dep:wasmparser'] diff --git a/crates/wit-component/src/decoding.rs b/crates/wit-component/src/decoding.rs index cee84d0bf1..32c6472d35 100644 --- a/crates/wit-component/src/decoding.rs +++ b/crates/wit-component/src/decoding.rs @@ -296,7 +296,7 @@ impl WitPackageDecoder<'_> { } if interface.as_str() == "wit" => PackageName { namespace: namespace.to_string(), name: package.to_string(), - version, + version: version.map(|v| v.into()), }, _ => bail!("package name is not a valid id: {name}"), }, @@ -562,15 +562,15 @@ impl WitPackageDecoder<'_> { KebabNameKind::Id { namespace, package, - version, interface, + version, } => (namespace, package, version, interface), _ => bail!("package name is not a valid id: {name_string}"), }; let package_name = PackageName { name: name.to_string(), namespace: namespace.to_string(), - version, + version: version.map(|v| v.into()), }; // Lazily create a `Package` as necessary, along with the interface. let package = self diff --git a/crates/wit-component/src/validation.rs b/crates/wit-component/src/validation.rs index c7bd5d331a..fae8264863 100644 --- a/crates/wit-component/src/validation.rs +++ b/crates/wit-component/src/validation.rs @@ -543,7 +543,7 @@ fn world_key(resolve: &Resolve, name: &str) -> WorldKey { PackageName { namespace: namespace.as_str().to_string(), name: package.as_str().to_string(), - version, + version: version.map(|v| v.into()), }, interface.as_str(), ), diff --git a/crates/wit-parser/Cargo.toml b/crates/wit-parser/Cargo.toml index f426267f28..adcb18eba5 100644 --- a/crates/wit-parser/Cargo.toml +++ b/crates/wit-parser/Cargo.toml @@ -13,14 +13,16 @@ Tooling for parsing `*.wit` files and working with their contents. """ [dependencies] -id-arena = "2" +id-arena = { git = "https://github.com/Mossaka/id-arena-fork", rev = "55c80c6deb4e2aea07002a21bddaaf985dbf7590" } anyhow = { workspace = true } -indexmap = { workspace = true } +indexmap = { workspace = true, features = ["serde"] } pulldown-cmark = { version = "0.9.3", default-features = false } unicode-xid = "0.2.2" log = { workspace = true } url = { workspace = true } semver = { workspace = true } +serde.workspace = true +serde_json = "1.0.105" [dev-dependencies] rayon = "1" diff --git a/crates/wit-parser/src/ast.rs b/crates/wit-parser/src/ast.rs index 465517718a..c506f7c784 100644 --- a/crates/wit-parser/src/ast.rs +++ b/crates/wit-parser/src/ast.rs @@ -170,7 +170,7 @@ impl<'a> PackageName<'a> { crate::PackageName { namespace: self.namespace.name.to_string(), name: self.name.name.to_string(), - version: self.version.as_ref().map(|(_, v)| v.clone()), + version: self.version.as_ref().map(|(_, v)| v.clone().into()), } } } diff --git a/crates/wit-parser/src/lib.rs b/crates/wit-parser/src/lib.rs index 57a1455e26..3c311a6c85 100644 --- a/crates/wit-parser/src/lib.rs +++ b/crates/wit-parser/src/lib.rs @@ -1,7 +1,7 @@ use anyhow::{Context, Result}; use id_arena::{Arena, Id}; use indexmap::IndexMap; -use semver::Version; +use serde::Serialize; use std::borrow::Cow; use std::fmt; use std::path::Path; @@ -16,6 +16,8 @@ mod resolve; pub use resolve::{Package, PackageId, Remap, Resolve}; mod live; pub use live::LiveTypes; +mod version; +pub use version::SerializableVersion; /// Checks if the given string is a legal identifier in wit. pub fn validate_id(s: &str) -> Result<()> { @@ -101,7 +103,7 @@ pub struct UnresolvedPackage { required_resource_types: Vec<(TypeId, Span)>, } -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Copy, Clone, Serialize)] pub enum AstItem { Interface(InterfaceId), World(WorldId), @@ -112,14 +114,21 @@ pub enum AstItem { /// /// This is directly encoded as an "ID" in the binary component representation /// with an interfaced tacked on as well. -#[derive(Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)] +#[derive(Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd, Serialize)] +#[serde(into = "String")] pub struct PackageName { /// A namespace such as `wasi` in `wasi:foo/bar` pub namespace: String, /// The kebab-name of this package, which is always specified. pub name: String, /// Optional major/minor version information. - pub version: Option, + pub version: Option, +} + +impl From for String { + fn from(name: PackageName) -> String { + name.to_string() + } } impl PackageName { @@ -231,7 +240,7 @@ impl UnresolvedPackage { } } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize)] pub struct World { /// The WIT identifier name of this world. pub name: String, @@ -249,13 +258,15 @@ pub struct World { pub package: Option, /// All the included worlds from this world. Empty if this is fully resolved + #[serde(skip)] pub includes: Vec, /// All the included worlds names. Empty if this is fully resolved + #[serde(skip)] pub include_names: Vec>, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize)] pub struct IncludeName { /// The name of the item pub name: String, @@ -266,7 +277,8 @@ pub struct IncludeName { /// The key to the import/export maps of a world. Either a kebab-name or a /// unique interface. -#[derive(Debug, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize)] +#[serde(into = "String")] pub enum WorldKey { /// A kebab-name. Name(String), @@ -274,6 +286,15 @@ pub enum WorldKey { Interface(InterfaceId), } +impl From for String { + fn from(key: WorldKey) -> String { + match key { + WorldKey::Name(name) => name, + WorldKey::Interface(id) => format!("interface-{}", id.index()), + } + } +} + impl WorldKey { /// Asserts that this is `WorldKey::Name` and returns the name. #[track_caller] @@ -285,7 +306,7 @@ impl WorldKey { } } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Serialize)] pub enum WorldItem { /// An interface is being imported or exported from a world, indicating that /// it's a namespace of functions. @@ -300,7 +321,7 @@ pub enum WorldItem { Type(TypeId), } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize)] pub struct Interface { /// Optionally listed name of this interface. /// @@ -323,7 +344,7 @@ pub struct Interface { pub package: Option, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Serialize)] pub struct TypeDef { pub docs: Docs, pub kind: TypeDefKind, @@ -331,7 +352,7 @@ pub struct TypeDef { pub owner: TypeOwner, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Serialize)] pub enum TypeDefKind { Record(Record), Resource, @@ -379,7 +400,7 @@ impl TypeDefKind { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize)] pub enum TypeOwner { /// This type was defined within a `world` block. World(WorldId), @@ -390,13 +411,13 @@ pub enum TypeOwner { None, } -#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone)] +#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, Serialize)] pub enum Handle { Own(TypeId), Borrow(TypeId), } -#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone)] +#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, Serialize)] pub enum Type { Bool, U8, @@ -414,7 +435,7 @@ pub enum Type { Id(TypeId), } -#[derive(PartialEq, Debug, Copy, Clone)] +#[derive(PartialEq, Debug, Copy, Clone, Serialize)] pub enum Int { U8, U16, @@ -422,30 +443,30 @@ pub enum Int { U64, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Serialize)] pub struct Record { pub fields: Vec, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Serialize)] pub struct Field { pub docs: Docs, pub name: String, pub ty: Type, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Serialize)] pub struct Flags { pub flags: Vec, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Serialize)] pub struct Flag { pub docs: Docs, pub name: String, } -#[derive(Debug)] +#[derive(Debug, Clone, PartialEq, Serialize)] pub enum FlagsRepr { U8, U16, @@ -473,17 +494,17 @@ impl FlagsRepr { } } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Serialize)] pub struct Tuple { pub types: Vec, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Serialize)] pub struct Variant { pub cases: Vec, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Serialize)] pub struct Case { pub docs: Docs, pub name: String, @@ -501,12 +522,12 @@ impl Variant { } } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Serialize)] pub struct Enum { pub cases: Vec, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Serialize)] pub struct EnumCase { pub docs: Docs, pub name: String, @@ -523,26 +544,26 @@ impl Enum { } } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Serialize)] pub struct Result_ { pub ok: Option, pub err: Option, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Serialize)] pub struct Stream { pub element: Option, pub end: Option, } -#[derive(Clone, Default, Debug, PartialEq, Eq)] +#[derive(Clone, Default, Debug, PartialEq, Eq, Serialize)] pub struct Docs { pub contents: Option, } pub type Params = Vec<(String, Type)>; -#[derive(Debug, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize)] pub enum Results { Named(Params), Anon(Type), @@ -607,7 +628,7 @@ impl Results { } } -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] pub struct Function { pub docs: Docs, pub name: String, @@ -616,7 +637,7 @@ pub struct Function { pub results: Results, } -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] pub enum FunctionKind { Freestanding, Method(TypeId), diff --git a/crates/wit-parser/src/resolve.rs b/crates/wit-parser/src/resolve.rs index 397b26aed7..d49268b3dc 100644 --- a/crates/wit-parser/src/resolve.rs +++ b/crates/wit-parser/src/resolve.rs @@ -8,6 +8,7 @@ use crate::{ use anyhow::{anyhow, bail, Context, Result}; use id_arena::{Arena, Id}; use indexmap::{IndexMap, IndexSet}; +use serde::Serialize; use std::collections::{BTreeMap, HashMap, HashSet}; use std::mem; use std::path::{Path, PathBuf}; @@ -25,7 +26,7 @@ use std::path::{Path, PathBuf}; /// /// Each item in a `Resolve` has a parent link to trace it back to the original /// package as necessary. -#[derive(Default, Clone)] +#[derive(Default, Clone, Serialize)] pub struct Resolve { pub worlds: Arena, pub interfaces: Arena, @@ -39,7 +40,7 @@ pub struct Resolve { /// A package is a collection of interfaces and worlds. Packages additionally /// have a unique identifier that affects generated components and uniquely /// identifiers this particular package. -#[derive(Clone)] +#[derive(Clone, Serialize)] pub struct Package { /// A unique name corresponding to this package. pub name: PackageName, @@ -1745,3 +1746,127 @@ impl<'a> MergeMap<'a> { Ok(()) } } + +#[cfg(test)] +mod tests { + use crate::Record; + use anyhow::Result; + + use super::*; + + #[test] + fn serialize_and_deserialize() -> Result<()> { + let resolve = Resolve::default(); + let s = serde_json::to_string(&resolve)?; + println!("{}", s); + Ok(()) + } + + #[test] + fn serialize_arena_world() -> Result<()> { + let mut worlds: Arena = Arena::new(); + let world1 = World { + name: "world1".to_string(), + docs: Default::default(), + imports: Default::default(), + exports: Default::default(), + includes: Default::default(), + include_names: Default::default(), + package: None, + }; + let world2 = World { + name: "world2".to_string(), + docs: Default::default(), + imports: Default::default(), + exports: Default::default(), + includes: Default::default(), + include_names: Default::default(), + package: None, + }; + worlds.alloc(world1); + worlds.alloc(world2); + + let s = serde_json::to_string(&worlds)?; + println!("{}", s); + Ok(()) + } + + #[test] + fn serialize_arena_interface() -> Result<()> { + let mut interfaces: Arena = Arena::new(); + let interface1 = Interface { + name: Some("interface1".to_string()), + docs: Default::default(), + types: Default::default(), + functions: Default::default(), + package: None, + }; + let interface2 = Interface { + name: Some("interface2".to_string()), + docs: Default::default(), + types: Default::default(), + functions: Default::default(), + package: None, + }; + interfaces.alloc(interface1); + interfaces.alloc(interface2); + + let s = serde_json::to_string(&interfaces)?; + println!("{}", s); + Ok(()) + } + + #[test] + fn serialize_arena_type() -> Result<()> { + let mut types: Arena = Arena::new(); + let type1 = TypeDef { + name: Some("type1".to_string()), + owner: TypeOwner::None, + kind: TypeDefKind::Type(Type::Bool), + docs: Default::default(), + }; + let type2 = TypeDef { + name: Some("type2".to_string()), + owner: TypeOwner::None, + kind: TypeDefKind::Record(Record { + fields: Default::default(), + }), + docs: Default::default(), + }; + types.alloc(type1); + types.alloc(type2); + + let s = serde_json::to_string(&types)?; + println!("{}", s); + Ok(()) + } + + #[test] + fn serialize_packages() { + let mut packages: Arena = Arena::new(); + let package1 = Package { + name: PackageName { + namespace: "foo".into(), + name: "package1".into(), + version: None, + }, + docs: Default::default(), + interfaces: Default::default(), + worlds: Default::default(), + }; + let package2 = Package { + name: PackageName { + namespace: "foo".into(), + name: "package2".into(), + version: None, + }, + docs: Default::default(), + interfaces: Default::default(), + worlds: Default::default(), + }; + packages.alloc(package1); + packages.alloc(package2); + let s = serde_json::to_string(&packages).unwrap(); + println!("{}", s); + } +} diff --git a/crates/wit-parser/src/version.rs b/crates/wit-parser/src/version.rs new file mode 100644 index 0000000000..9def339e39 --- /dev/null +++ b/crates/wit-parser/src/version.rs @@ -0,0 +1,58 @@ +use semver::Version; +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)] +pub struct SerializableVersion(Version); + +impl<'de> Deserialize<'de> for SerializableVersion { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s = String::deserialize(deserializer)?; + Version::parse(&s) + .map(SerializableVersion) + .map_err(serde::de::Error::custom) + } +} + +impl Serialize for SerializableVersion { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + // Assuming there's a method to convert Version to a string representation + let s = self.0.to_string(); + serializer.serialize_str(&s) + } +} + +impl From for Version { + fn from(v: SerializableVersion) -> Self { + v.0 + } +} + +impl From for SerializableVersion { + fn from(v: Version) -> Self { + SerializableVersion(v) + } +} + +impl AsRef for SerializableVersion { + fn as_ref(&self) -> &Version { + &self.0 + } +} + +impl AsMut for SerializableVersion { + fn as_mut(&mut self) -> &mut Version { + &mut self.0 + } +} + +impl std::fmt::Display for SerializableVersion { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.0.to_string().fmt(f) + } +} diff --git a/crates/wit-parser/tests/all.rs b/crates/wit-parser/tests/all.rs index c1c1132c66..815834e89b 100644 --- a/crates/wit-parser/tests/all.rs +++ b/crates/wit-parser/tests/all.rs @@ -124,6 +124,7 @@ impl Runner<'_> { } } else { result?; + serde_json::to_string(&resolve)?; return Ok(()); }; diff --git a/src/bin/wasm-tools/component.rs b/src/bin/wasm-tools/component.rs index 2757e5d450..67277ee2d5 100644 --- a/src/bin/wasm-tools/component.rs +++ b/src/bin/wasm-tools/component.rs @@ -416,6 +416,10 @@ pub struct WitOpts { /// options. #[clap(long)] skip_validation: bool, + + /// Emit the WIT document as JSON instead of text. + #[clap(short, long, conflicts_with = "wasm", conflicts_with = "out_dir", conflicts_with = "wat")] + json: bool, } impl WitOpts { @@ -478,6 +482,10 @@ impl WitOpts { // Now that the WIT document has been decoded, it's time to emit it. // This interprets all of the output options and performs such a task. + if self.json { + self.emit_json(&decoded)?; + return Ok(()); + } if self.wasm || self.wat { self.emit_wasm(&decoded)?; } else { @@ -565,6 +573,17 @@ impl WitOpts { } } + Ok(()) + } + + fn emit_json(&self, decoded: &DecodedWasm) -> Result<()> { + assert!(!self.wasm && !self.wat); + + let resolve = decoded.resolve(); + let output = serde_json::to_string_pretty(&resolve)?; + self.output.output(Output::Json(&output))?; + + Ok(()) } } diff --git a/src/lib.rs b/src/lib.rs index d0b74cab25..0a558d28f6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -94,6 +94,7 @@ pub struct OutputArg { pub enum Output<'a> { Wat(&'a str), Wasm { bytes: &'a [u8], wat: bool }, + Json(&'a str), } impl InputOutput { @@ -147,6 +148,7 @@ impl OutputArg { } Ok(()) } + Output::Json(s) => self.output_str(s), } } From b5b79bae4b901719245f666ce60e16e3e77695bc Mon Sep 17 00:00:00 2001 From: "Jiaxiao Zhou (Mossaka)" Date: Wed, 23 Aug 2023 01:36:14 -0700 Subject: [PATCH 02/40] rustfmt Signed-off-by: Jiaxiao Zhou (Mossaka) --- src/bin/wasm-tools/component.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/bin/wasm-tools/component.rs b/src/bin/wasm-tools/component.rs index 67277ee2d5..edbdd09779 100644 --- a/src/bin/wasm-tools/component.rs +++ b/src/bin/wasm-tools/component.rs @@ -418,7 +418,13 @@ pub struct WitOpts { skip_validation: bool, /// Emit the WIT document as JSON instead of text. - #[clap(short, long, conflicts_with = "wasm", conflicts_with = "out_dir", conflicts_with = "wat")] + #[clap( + short, + long, + conflicts_with = "wasm", + conflicts_with = "out_dir", + conflicts_with = "wat" + )] json: bool, } @@ -583,7 +589,6 @@ impl WitOpts { let output = serde_json::to_string_pretty(&resolve)?; self.output.output(Output::Json(&output))?; - Ok(()) } } From 8edc9f883ca41ed0799b2ac67fd7da9f37899aad Mon Sep 17 00:00:00 2001 From: "Jiaxiao Zhou (Mossaka)" Date: Wed, 30 Aug 2023 00:42:32 -0700 Subject: [PATCH 03/40] simplify the JSON output 1. serialize the Arena fields of Resolve as arrays, instead of an object with arena_id 2. serialize world items with kebab indexed 3. remove arena_id Signed-off-by: Jiaxiao Zhou (Mossaka) --- Cargo.lock | 4 +- crates/wit-parser/Cargo.toml | 2 +- crates/wit-parser/src/lib.rs | 13 +- crates/wit-parser/src/serde_.rs | 123 +++++++++++++++++++ crates/wit-parser/tests/ui/world-diamond.wit | 1 + 5 files changed, 134 insertions(+), 9 deletions(-) create mode 100644 crates/wit-parser/src/serde_.rs diff --git a/Cargo.lock b/Cargo.lock index ec05a070c3..5d044b316f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -810,7 +810,7 @@ checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" [[package]] name = "id-arena" version = "2.2.1" -source = "git+https://github.com/Mossaka/id-arena-fork?rev=55c80c6deb4e2aea07002a21bddaaf985dbf7590#55c80c6deb4e2aea07002a21bddaaf985dbf7590" +source = "git+https://github.com/Mossaka/id-arena-fork?rev=cae2a0a63d505adec402289eea90c52d3205007a#cae2a0a63d505adec402289eea90c52d3205007a" dependencies = [ "serde", ] @@ -2398,7 +2398,7 @@ version = "0.11.0" dependencies = [ "anyhow", "env_logger", - "id-arena 2.2.1 (git+https://github.com/Mossaka/id-arena-fork?rev=55c80c6deb4e2aea07002a21bddaaf985dbf7590)", + "id-arena 2.2.1 (git+https://github.com/Mossaka/id-arena-fork?rev=cae2a0a63d505adec402289eea90c52d3205007a)", "indexmap 2.0.0", "log", "pretty_assertions", diff --git a/crates/wit-parser/Cargo.toml b/crates/wit-parser/Cargo.toml index adcb18eba5..d05730900b 100644 --- a/crates/wit-parser/Cargo.toml +++ b/crates/wit-parser/Cargo.toml @@ -13,7 +13,7 @@ Tooling for parsing `*.wit` files and working with their contents. """ [dependencies] -id-arena = { git = "https://github.com/Mossaka/id-arena-fork", rev = "55c80c6deb4e2aea07002a21bddaaf985dbf7590" } +id-arena = { git = "https://github.com/Mossaka/id-arena-fork", rev = "cae2a0a63d505adec402289eea90c52d3205007a" } anyhow = { workspace = true } indexmap = { workspace = true, features = ["serde"] } pulldown-cmark = { version = "0.9.3", default-features = false } diff --git a/crates/wit-parser/src/lib.rs b/crates/wit-parser/src/lib.rs index 3c311a6c85..da64ec4343 100644 --- a/crates/wit-parser/src/lib.rs +++ b/crates/wit-parser/src/lib.rs @@ -18,6 +18,7 @@ mod live; pub use live::LiveTypes; mod version; pub use version::SerializableVersion; +mod serde_; /// Checks if the given string is a legal identifier in wit. pub fn validate_id(s: &str) -> Result<()> { @@ -306,7 +307,7 @@ impl WorldKey { } } -#[derive(Debug, Clone, PartialEq, Serialize)] +#[derive(Debug, Clone, PartialEq)] pub enum WorldItem { /// An interface is being imported or exported from a world, indicating that /// it's a namespace of functions. @@ -417,7 +418,7 @@ pub enum Handle { Borrow(TypeId), } -#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, Serialize)] +#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone)] pub enum Type { Bool, U8, @@ -556,14 +557,14 @@ pub struct Stream { pub end: Option, } -#[derive(Clone, Default, Debug, PartialEq, Eq, Serialize)] +#[derive(Clone, Default, Debug, PartialEq, Eq)] pub struct Docs { pub contents: Option, } pub type Params = Vec<(String, Type)>; -#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum Results { Named(Params), Anon(Type), @@ -628,7 +629,7 @@ impl Results { } } -#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct Function { pub docs: Docs, pub name: String, @@ -637,7 +638,7 @@ pub struct Function { pub results: Results, } -#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum FunctionKind { Freestanding, Method(TypeId), diff --git a/crates/wit-parser/src/serde_.rs b/crates/wit-parser/src/serde_.rs new file mode 100644 index 0000000000..b859f0fbad --- /dev/null +++ b/crates/wit-parser/src/serde_.rs @@ -0,0 +1,123 @@ +use serde::ser::{Serialize, SerializeStruct, Serializer}; + +use crate::{Docs, Function, FunctionKind, Results, Type, WorldItem}; + +impl Serialize for WorldItem { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + WorldItem::Interface(id) => { + let mut s = serializer.serialize_struct("WorldItem", 2)?; + s.serialize_field("Interface", &format!("interface-{}", id.index()))?; + s.end() + } + WorldItem::Function(func) => { + let mut s = serializer.serialize_struct("WorldItem", 1)?; + s.serialize_field("Function", func)?; + s.end() + } + WorldItem::Type(type_id) => { + let mut s = serializer.serialize_struct("WorldItem", 1)?; + s.serialize_field("Type", &format!("type-{}", type_id.index()))?; + s.end() + } + } + } +} + +impl Serialize for Function { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut s = serializer.serialize_struct("Function", 5)?; + s.serialize_field("docs", &self.docs)?; + s.serialize_field("name", &self.name)?; + s.serialize_field("kind", &self.kind)?; + s.serialize_field("params", &self.params)?; + s.serialize_field("results", &self.results)?; + s.end() + } +} + +impl Serialize for Docs { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut s = serializer.serialize_struct("Docs", 2)?; + s.serialize_field("contents", &self.contents)?; + s.end() + } +} + +impl Serialize for FunctionKind { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + FunctionKind::Freestanding => serializer.serialize_str("Freestanding"), + FunctionKind::Method(type_id) => { + let mut s = serializer.serialize_struct("Method", 1)?; + s.serialize_field("TypeId", type_id)?; + s.end() + } + FunctionKind::Static(type_id) => { + let mut s = serializer.serialize_struct("Static", 1)?; + s.serialize_field("TypeId", type_id)?; + s.end() + } + FunctionKind::Constructor(type_id) => { + let mut s = serializer.serialize_struct("Constructor", 1)?; + s.serialize_field("TypeId", type_id)?; + s.end() + } + } + } +} + +impl Serialize for Type { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Type::Bool => serializer.serialize_str("Bool"), + Type::U8 => serializer.serialize_str("U8"), + Type::U16 => serializer.serialize_str("U16"), + Type::U32 => serializer.serialize_str("U32"), + Type::U64 => serializer.serialize_str("U64"), + Type::S8 => serializer.serialize_str("S8"), + Type::S16 => serializer.serialize_str("S16"), + Type::S32 => serializer.serialize_str("S32"), + Type::S64 => serializer.serialize_str("S64"), + Type::Float32 => serializer.serialize_str("Float32"), + Type::Float64 => serializer.serialize_str("Float64"), + Type::Char => serializer.serialize_str("Char"), + Type::String => serializer.serialize_str("String"), + Type::Id(type_id) => { + let type_str = format!("type-{}", type_id.index()); + serializer.serialize_str(&type_str) + } + } + } +} + +impl Serialize for Results { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Results::Named(params) => { + serializer.serialize_newtype_variant("Results", 0, "Named", params) + } + Results::Anon(type_) => { + serializer.serialize_newtype_variant("Results", 1, "Anon", type_) + } + } + } +} diff --git a/crates/wit-parser/tests/ui/world-diamond.wit b/crates/wit-parser/tests/ui/world-diamond.wit index 6dd4ce8879..c858ed3689 100644 --- a/crates/wit-parser/tests/ui/world-diamond.wit +++ b/crates/wit-parser/tests/ui/world-diamond.wit @@ -19,4 +19,5 @@ interface i2 { world the-world { import i1 import i2 + import a: func() } From dbdde18c9096f5c4bbefb8bc5381e6187cea79f2 Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Thu, 31 Aug 2023 12:52:24 -0700 Subject: [PATCH 04/40] wit-parser: add implementation of id_arena::ArenaBehavior for serde support --- crates/wit-parser/src/id_arena_.rs | 97 ++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 crates/wit-parser/src/id_arena_.rs diff --git a/crates/wit-parser/src/id_arena_.rs b/crates/wit-parser/src/id_arena_.rs new file mode 100644 index 0000000000..f7624f542c --- /dev/null +++ b/crates/wit-parser/src/id_arena_.rs @@ -0,0 +1,97 @@ +use core::marker::PhantomData; +use id_arena; +use core::cmp::Ordering; +use core::fmt; +use core::hash::{Hash, Hasher}; + +/// An identifier for an object allocated within an arena. +pub struct Id { + idx: usize, + arena_id: u32, + _ty: PhantomData T>, +} + +impl fmt::Debug for Id { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Id").field("idx", &self.idx).finish() + } +} + +impl Copy for Id {} + +impl Clone for Id { + #[inline] + fn clone(&self) -> Id { + *self + } +} + +impl PartialEq for Id { + #[inline] + fn eq(&self, rhs: &Self) -> bool { + self.arena_id == rhs.arena_id && self.idx == rhs.idx + } +} + +impl Eq for Id {} + +impl Hash for Id { + #[inline] + fn hash(&self, h: &mut H) { + self.arena_id.hash(h); + self.idx.hash(h); + } +} + +impl PartialOrd for Id { + fn partial_cmp(&self, rhs: &Self) -> Option { + Some(self.cmp(rhs)) + } +} + +impl Ord for Id { + fn cmp(&self, rhs: &Self) -> Ordering { + self.arena_id + .cmp(&rhs.arena_id) + .then(self.idx.cmp(&rhs.idx)) + } +} + +impl Id { + /// Get the index within the arena that this id refers to. + #[inline] + pub fn index(&self) -> usize { + self.idx + } +} + +/// Our `ArenaBehavior` implementation. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct ArenaBehavior { + _phantom: PhantomData T>, +} + +impl id_arena::ArenaBehavior for ArenaBehavior { + type Id = Id; + + #[inline] + fn new_id(arena_id: u32, idx: usize) -> Self::Id { + Id { + idx, + arena_id, + _ty: PhantomData, + } + } + + #[inline] + fn index(id: Self::Id) -> usize { + id.idx + } + + #[inline] + fn arena_id(id: Self::Id) -> u32 { + id.arena_id + } +} + +pub type Arena> = id_arena::Arena; From 7a27087e8aa9a9baea684e8ff22539a30ed61b27 Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Thu, 31 Aug 2023 12:56:26 -0700 Subject: [PATCH 05/40] wit-parser: rename world arg to world_id --- crates/wit-parser/src/live.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wit-parser/src/live.rs b/crates/wit-parser/src/live.rs index 19ded9153f..47dac647bf 100644 --- a/crates/wit-parser/src/live.rs +++ b/crates/wit-parser/src/live.rs @@ -25,8 +25,8 @@ impl LiveTypes { } } - pub fn add_world(&mut self, resolve: &Resolve, world: WorldId) { - let world = &resolve.worlds[world]; + pub fn add_world(&mut self, resolve: &Resolve, world_id: WorldId) { + let world = &resolve.worlds[world_id]; for (_, item) in world.imports.iter().chain(world.exports.iter()) { self.add_world_item(resolve, item); } From a63119a4baaa1260599d654ead5d4db3568183ab Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Thu, 31 Aug 2023 13:00:20 -0700 Subject: [PATCH 06/40] wit-parser: use InterfaceId and WorldId types --- crates/wit-parser/src/resolve.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wit-parser/src/resolve.rs b/crates/wit-parser/src/resolve.rs index d49268b3dc..854e9c26ea 100644 --- a/crates/wit-parser/src/resolve.rs +++ b/crates/wit-parser/src/resolve.rs @@ -825,7 +825,7 @@ impl Remap { fn process_foreign_interfaces( &mut self, unresolved: &UnresolvedPackage, - interface_to_package: &HashMap, (&PackageName, &String, Span)>, + interface_to_package: &HashMap, resolve: &mut Resolve, ) -> Result<(), anyhow::Error> { for (unresolved_iface_id, unresolved_iface) in unresolved.interfaces.iter() { @@ -873,7 +873,7 @@ impl Remap { fn process_foreign_worlds( &mut self, unresolved: &UnresolvedPackage, - world_to_package: &HashMap, (&PackageName, &String, Span)>, + world_to_package: &HashMap, resolve: &mut Resolve, ) -> Result<(), anyhow::Error> { for (unresolved_world_id, _) in unresolved.worlds.iter() { From 4e3602dc133fe6ff15b86517a5306d4503a50cbf Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Thu, 31 Aug 2023 13:00:44 -0700 Subject: [PATCH 07/40] wit-parser: skip serialization of package name index --- crates/wit-parser/src/resolve.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/wit-parser/src/resolve.rs b/crates/wit-parser/src/resolve.rs index 854e9c26ea..29c3c34811 100644 --- a/crates/wit-parser/src/resolve.rs +++ b/crates/wit-parser/src/resolve.rs @@ -32,6 +32,7 @@ pub struct Resolve { pub interfaces: Arena, pub types: Arena, pub packages: Arena, + #[serde(skip)] pub package_names: IndexMap, } From 3bd24fb3ba8f3cba6c4ffc535f3a9fc1a304da87 Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Thu, 31 Aug 2023 13:02:32 -0700 Subject: [PATCH 08/40] wit-parser: additional Serialize implementations --- crates/wit-parser/src/lib.rs | 7 +-- crates/wit-parser/src/resolve.rs | 2 +- crates/wit-parser/src/serde_.rs | 80 ++++++++++++++++++++++---------- 3 files changed, 60 insertions(+), 29 deletions(-) diff --git a/crates/wit-parser/src/lib.rs b/crates/wit-parser/src/lib.rs index da64ec4343..cd3ff10f12 100644 --- a/crates/wit-parser/src/lib.rs +++ b/crates/wit-parser/src/lib.rs @@ -1,5 +1,4 @@ use anyhow::{Context, Result}; -use id_arena::{Arena, Id}; use indexmap::IndexMap; use serde::Serialize; use std::borrow::Cow; @@ -19,6 +18,8 @@ pub use live::LiveTypes; mod version; pub use version::SerializableVersion; mod serde_; +mod id_arena_; +use id_arena_::{Arena, Id}; /// Checks if the given string is a legal identifier in wit. pub fn validate_id(s: &str) -> Result<()> { @@ -401,7 +402,7 @@ impl TypeDefKind { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum TypeOwner { /// This type was defined within a `world` block. World(WorldId), @@ -412,7 +413,7 @@ pub enum TypeOwner { None, } -#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, Serialize)] +#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone)] pub enum Handle { Own(TypeId), Borrow(TypeId), diff --git a/crates/wit-parser/src/resolve.rs b/crates/wit-parser/src/resolve.rs index 29c3c34811..e07c306ace 100644 --- a/crates/wit-parser/src/resolve.rs +++ b/crates/wit-parser/src/resolve.rs @@ -5,8 +5,8 @@ use crate::{ PackageName, Results, Type, TypeDef, TypeDefKind, TypeId, TypeOwner, UnresolvedPackage, World, WorldId, WorldItem, WorldKey, }; +use crate::id_arena_::{Arena, Id}; use anyhow::{anyhow, bail, Context, Result}; -use id_arena::{Arena, Id}; use indexmap::{IndexMap, IndexSet}; use serde::Serialize; use std::collections::{BTreeMap, HashMap, HashSet}; diff --git a/crates/wit-parser/src/serde_.rs b/crates/wit-parser/src/serde_.rs index b859f0fbad..06c7311dae 100644 --- a/crates/wit-parser/src/serde_.rs +++ b/crates/wit-parser/src/serde_.rs @@ -1,6 +1,16 @@ use serde::ser::{Serialize, SerializeStruct, Serializer}; -use crate::{Docs, Function, FunctionKind, Results, Type, WorldItem}; +use crate::{Docs, Function, FunctionKind, Handle, Results, Type, TypeOwner, WorldItem}; +use crate::id_arena_::Id; + +impl Serialize for Id { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_u64(self.index() as u64) + } +} impl Serialize for WorldItem { fn serialize(&self, serializer: S) -> Result @@ -8,20 +18,14 @@ impl Serialize for WorldItem { S: Serializer, { match self { - WorldItem::Interface(id) => { - let mut s = serializer.serialize_struct("WorldItem", 2)?; - s.serialize_field("Interface", &format!("interface-{}", id.index()))?; - s.end() + WorldItem::Interface(interface_id) => { + serializer.serialize_newtype_variant("WorldItem", 0, "Interface", &(interface_id.index() as u64)) } WorldItem::Function(func) => { - let mut s = serializer.serialize_struct("WorldItem", 1)?; - s.serialize_field("Function", func)?; - s.end() + serializer.serialize_newtype_variant("WorldItem", 1, "Function", func) } WorldItem::Type(type_id) => { - let mut s = serializer.serialize_struct("WorldItem", 1)?; - s.serialize_field("Type", &format!("type-{}", type_id.index()))?; - s.end() + serializer.serialize_newtype_variant("WorldItem", 2, "Type", &(type_id.index() as u64)) } } } @@ -61,19 +65,13 @@ impl Serialize for FunctionKind { match self { FunctionKind::Freestanding => serializer.serialize_str("Freestanding"), FunctionKind::Method(type_id) => { - let mut s = serializer.serialize_struct("Method", 1)?; - s.serialize_field("TypeId", type_id)?; - s.end() + serializer.serialize_newtype_variant("FunctionKind", 0, "Method", &(type_id.index() as u64)) } FunctionKind::Static(type_id) => { - let mut s = serializer.serialize_struct("Static", 1)?; - s.serialize_field("TypeId", type_id)?; - s.end() + serializer.serialize_newtype_variant("FunctionKind", 1, "Static", &(type_id.index() as u64)) } FunctionKind::Constructor(type_id) => { - let mut s = serializer.serialize_struct("Constructor", 1)?; - s.serialize_field("TypeId", type_id)?; - s.end() + serializer.serialize_newtype_variant("FunctionKind", 2, "Constructor", &(type_id.index() as u64)) } } } @@ -98,9 +96,41 @@ impl Serialize for Type { Type::Float64 => serializer.serialize_str("Float64"), Type::Char => serializer.serialize_str("Char"), Type::String => serializer.serialize_str("String"), - Type::Id(type_id) => { - let type_str = format!("type-{}", type_id.index()); - serializer.serialize_str(&type_str) + Type::Id(type_id) => serializer.serialize_u64(type_id.index() as u64) + } + } +} + +impl Serialize for TypeOwner { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + TypeOwner::World(world_id) => { + serializer.serialize_newtype_variant("TypeOwner", 0, "World", &(world_id.index() as u64)) + } + TypeOwner::Interface(interface_id) => { + serializer.serialize_newtype_variant("TypeOwner", 1, "Interface", &(interface_id.index() as u64)) + } + TypeOwner::None => { + serializer.serialize_none() + } + } + } +} + +impl Serialize for Handle { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Handle::Own(type_id) => { + serializer.serialize_newtype_variant("Handle", 0, "Own", &(type_id.index() as u64)) + } + Handle::Borrow(type_id) => { + serializer.serialize_newtype_variant("Handle", 1, "Borrow", &(type_id.index() as u64)) } } } @@ -115,8 +145,8 @@ impl Serialize for Results { Results::Named(params) => { serializer.serialize_newtype_variant("Results", 0, "Named", params) } - Results::Anon(type_) => { - serializer.serialize_newtype_variant("Results", 1, "Anon", type_) + Results::Anon(typ) => { + serializer.serialize_newtype_variant("Results", 1, "Anon", typ) } } } From 48e4ad52ccf86ee3612e15d3c884eb832a64a3a4 Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Thu, 31 Aug 2023 13:48:37 -0700 Subject: [PATCH 09/40] wit-parser: use derived Serialize for more types --- crates/wit-parser/src/lib.rs | 4 +-- crates/wit-parser/src/serde_.rs | 53 +-------------------------------- 2 files changed, 3 insertions(+), 54 deletions(-) diff --git a/crates/wit-parser/src/lib.rs b/crates/wit-parser/src/lib.rs index cd3ff10f12..cd6f22f216 100644 --- a/crates/wit-parser/src/lib.rs +++ b/crates/wit-parser/src/lib.rs @@ -402,7 +402,7 @@ impl TypeDefKind { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize)] pub enum TypeOwner { /// This type was defined within a `world` block. World(WorldId), @@ -413,7 +413,7 @@ pub enum TypeOwner { None, } -#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone)] +#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, Serialize)] pub enum Handle { Own(TypeId), Borrow(TypeId), diff --git a/crates/wit-parser/src/serde_.rs b/crates/wit-parser/src/serde_.rs index 06c7311dae..9803447f63 100644 --- a/crates/wit-parser/src/serde_.rs +++ b/crates/wit-parser/src/serde_.rs @@ -1,6 +1,6 @@ use serde::ser::{Serialize, SerializeStruct, Serializer}; -use crate::{Docs, Function, FunctionKind, Handle, Results, Type, TypeOwner, WorldItem}; +use crate::{Docs, Function, FunctionKind, Param, Results, Type, WorldItem}; use crate::id_arena_::Id; impl Serialize for Id { @@ -100,54 +100,3 @@ impl Serialize for Type { } } } - -impl Serialize for TypeOwner { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - match self { - TypeOwner::World(world_id) => { - serializer.serialize_newtype_variant("TypeOwner", 0, "World", &(world_id.index() as u64)) - } - TypeOwner::Interface(interface_id) => { - serializer.serialize_newtype_variant("TypeOwner", 1, "Interface", &(interface_id.index() as u64)) - } - TypeOwner::None => { - serializer.serialize_none() - } - } - } -} - -impl Serialize for Handle { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - match self { - Handle::Own(type_id) => { - serializer.serialize_newtype_variant("Handle", 0, "Own", &(type_id.index() as u64)) - } - Handle::Borrow(type_id) => { - serializer.serialize_newtype_variant("Handle", 1, "Borrow", &(type_id.index() as u64)) - } - } - } -} - -impl Serialize for Results { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - match self { - Results::Named(params) => { - serializer.serialize_newtype_variant("Results", 0, "Named", params) - } - Results::Anon(typ) => { - serializer.serialize_newtype_variant("Results", 1, "Anon", typ) - } - } - } -} From 218d8f110cb6b23b1800283744a336d9de853025 Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Thu, 31 Aug 2023 15:41:32 -0700 Subject: [PATCH 10/40] wit-parser: change Params type from an alias to a single-value tuple with Deref/MutDeref This allows us to implement Serialize on the Params type. --- crates/wit-component/src/decoding.rs | 6 +- crates/wit-parser/src/ast/resolve.rs | 2 +- crates/wit-parser/src/lib.rs | 22 +++++++- crates/wit-parser/src/serde_.rs | 84 +++++++++++++++++++++++++++- 4 files changed, 105 insertions(+), 9 deletions(-) diff --git a/crates/wit-component/src/decoding.rs b/crates/wit-component/src/decoding.rs index 32c6472d35..7d8fe2b323 100644 --- a/crates/wit-component/src/decoding.rs +++ b/crates/wit-component/src/decoding.rs @@ -871,7 +871,7 @@ impl WitPackageDecoder<'_> { .context("failed to convert anonymous result type")?, ) } else { - Results::Named( + Results::Named(Params( ty.results .iter() .map(|(name, ty)| { @@ -882,7 +882,7 @@ impl WitPackageDecoder<'_> { }) .collect::>>() .context("failed to convert named result types")?, - ) + )) }; Ok(Function { docs: Default::default(), @@ -907,7 +907,7 @@ impl WitPackageDecoder<'_> { // discriminant calculated above indicates how to interpret this // name. name: name.to_string(), - params, + params: Params(params), results, }) } diff --git a/crates/wit-parser/src/ast/resolve.rs b/crates/wit-parser/src/ast/resolve.rs index e7ece4cf07..3faca7ca65 100644 --- a/crates/wit-parser/src/ast/resolve.rs +++ b/crates/wit-parser/src/ast/resolve.rs @@ -1295,7 +1295,7 @@ impl<'a> Resolver<'a> { } fn resolve_params(&mut self, params: &ParamList<'_>, kind: &FunctionKind) -> Result { - let mut ret = Vec::new(); + let mut ret = Params(Vec::new()); match *kind { // These kinds of methods don't have any adjustments to the // parameters, so do nothing here. diff --git a/crates/wit-parser/src/lib.rs b/crates/wit-parser/src/lib.rs index cd6f22f216..00092f5c32 100644 --- a/crates/wit-parser/src/lib.rs +++ b/crates/wit-parser/src/lib.rs @@ -3,6 +3,7 @@ use indexmap::IndexMap; use serde::Serialize; use std::borrow::Cow; use std::fmt; +use std::ops::{Deref, DerefMut}; use std::path::Path; pub mod abi; @@ -563,7 +564,24 @@ pub struct Docs { pub contents: Option, } -pub type Params = Vec<(String, Type)>; +// pub type Params = Vec<(String, Type)>; + +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct Params(pub Vec<(String, Type)>); + +impl Deref for Params { + type Target = Vec<(String, Type)>; + fn deref(&self) -> &Vec<(String, Type)> { + &self.0 + } +} + +impl DerefMut for Params { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } +} + #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum Results { @@ -599,7 +617,7 @@ impl<'a> ExactSizeIterator for ResultsTypeIter<'a> {} impl Results { // For the common case of an empty results list. pub fn empty() -> Results { - Results::Named(Vec::new()) + Results::Named(Params(Vec::new())) } pub fn len(&self) -> usize { diff --git a/crates/wit-parser/src/serde_.rs b/crates/wit-parser/src/serde_.rs index 9803447f63..9fbe4046f9 100644 --- a/crates/wit-parser/src/serde_.rs +++ b/crates/wit-parser/src/serde_.rs @@ -1,6 +1,7 @@ -use serde::ser::{Serialize, SerializeStruct, Serializer}; - -use crate::{Docs, Function, FunctionKind, Param, Results, Type, WorldItem}; +// use std::ops::Deref; +use serde::ser::{SerializeSeq, SerializeStruct, Serializer}; +use serde::Serialize; +use crate::{Docs, Function, FunctionKind, Params, Results, Type, WorldItem}; use crate::id_arena_::Id; impl Serialize for Id { @@ -100,3 +101,80 @@ impl Serialize for Type { } } } + +// impl Serialize for Params { +// fn serialize(&self, serializer: S) -> Result +// where +// S: Serializer, +// { +// let mut seq = serializer.serialize_seq(Some(self.len()))?; +// for element in self { +// seq.serialize_element(element)?; +// } +// seq.end() +// } +// } + +impl Serialize for Results { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Results::Named(params) => { + serializer.serialize_some(params) + } + Results::Anon(typ) => { + let mut seq = serializer.serialize_seq(Some(1))?; + let param = Param{name: None, ty: *typ}; + seq.serialize_element(¶m)?; + seq.end() + } + } + } +} + +// #[derive(Serialize)] +// #[serde(remote = "Params")] +// struct SerdeParams(Params); + +// impl Deref for SerdeParams { +// type Target = Params; + +// fn deref(&self) -> &Params { +// &self.0 +// } +// } + +impl Serialize for Params { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut seq = serializer.serialize_seq(Some(self.len()))?; + for (name, typ) in self.to_vec() { + let param = Param{name: Some(name), ty: typ}; + seq.serialize_element(¶m)?; + } + seq.end() + } +} + +struct Param { + pub name: Option, + pub ty: Type +} + +impl Serialize for Param { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut s = serializer.serialize_struct("Param", 2)?; + if let Some(name) = &self.name { + s.serialize_field("name", name)?; + } + s.serialize_field("type", &self.ty)?; + s.end() + } +} From fe3a420d1ff1f1fad8d58d25be92005d7de343e1 Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Thu, 31 Aug 2023 15:50:03 -0700 Subject: [PATCH 11/40] wit-parser: cleanup on aisle params --- crates/wit-parser/src/serde_.rs | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/crates/wit-parser/src/serde_.rs b/crates/wit-parser/src/serde_.rs index 9fbe4046f9..7bad6c1680 100644 --- a/crates/wit-parser/src/serde_.rs +++ b/crates/wit-parser/src/serde_.rs @@ -1,4 +1,3 @@ -// use std::ops::Deref; use serde::ser::{SerializeSeq, SerializeStruct, Serializer}; use serde::Serialize; use crate::{Docs, Function, FunctionKind, Params, Results, Type, WorldItem}; @@ -102,19 +101,6 @@ impl Serialize for Type { } } -// impl Serialize for Params { -// fn serialize(&self, serializer: S) -> Result -// where -// S: Serializer, -// { -// let mut seq = serializer.serialize_seq(Some(self.len()))?; -// for element in self { -// seq.serialize_element(element)?; -// } -// seq.end() -// } -// } - impl Serialize for Results { fn serialize(&self, serializer: S) -> Result where @@ -134,26 +120,14 @@ impl Serialize for Results { } } -// #[derive(Serialize)] -// #[serde(remote = "Params")] -// struct SerdeParams(Params); - -// impl Deref for SerdeParams { -// type Target = Params; - -// fn deref(&self) -> &Params { -// &self.0 -// } -// } - impl Serialize for Params { fn serialize(&self, serializer: S) -> Result where S: Serializer, { let mut seq = serializer.serialize_seq(Some(self.len()))?; - for (name, typ) in self.to_vec() { - let param = Param{name: Some(name), ty: typ}; + for (name, typ) in self.iter() { + let param = Param{name: Some(name.to_string()), ty: *typ}; seq.serialize_element(¶m)?; } seq.end() From 6bf12cb156d7635f65050d86c43f2ada30eaec50 Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Thu, 31 Aug 2023 16:42:12 -0700 Subject: [PATCH 12/40] wit-parser: lowercase serialization for enums Might change this? --- crates/wit-parser/src/lib.rs | 23 ++++++++++++++++++-- crates/wit-parser/src/serde_.rs | 38 ++++----------------------------- 2 files changed, 25 insertions(+), 36 deletions(-) diff --git a/crates/wit-parser/src/lib.rs b/crates/wit-parser/src/lib.rs index 00092f5c32..201a06f287 100644 --- a/crates/wit-parser/src/lib.rs +++ b/crates/wit-parser/src/lib.rs @@ -309,7 +309,8 @@ impl WorldKey { } } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Serialize)] +#[serde(rename_all = "lowercase")] pub enum WorldItem { /// An interface is being imported or exported from a world, indicating that /// it's a namespace of functions. @@ -356,6 +357,7 @@ pub struct TypeDef { } #[derive(Debug, Clone, PartialEq, Serialize)] +#[serde(rename_all = "lowercase")] pub enum TypeDefKind { Record(Record), Resource, @@ -404,6 +406,7 @@ impl TypeDefKind { } #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize)] +#[serde(rename_all = "lowercase")] pub enum TypeOwner { /// This type was defined within a `world` block. World(WorldId), @@ -415,6 +418,7 @@ pub enum TypeOwner { } #[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, Serialize)] +#[serde(rename_all = "lowercase")] pub enum Handle { Own(TypeId), Borrow(TypeId), @@ -438,7 +442,8 @@ pub enum Type { Id(TypeId), } -#[derive(PartialEq, Debug, Copy, Clone, Serialize)] +#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize)] +#[serde(into = "String")] pub enum Int { U8, U16, @@ -446,6 +451,17 @@ pub enum Int { U64, } +impl From for String { + fn from(i: Int) -> String { + (match i { + Int::U8 => "U8", + Int::U16 => "U16", + Int::U32 => "U32", + Int::U64 => "U64", + }).to_string() + } +} + #[derive(Debug, Clone, PartialEq, Serialize)] pub struct Record { pub fields: Vec, @@ -455,6 +471,7 @@ pub struct Record { pub struct Field { pub docs: Docs, pub name: String, + #[serde(rename = "type")] pub ty: Type, } @@ -469,6 +486,7 @@ pub struct Flag { pub name: String, } +// TODO(ydnar): impl Serialize #[derive(Debug, Clone, PartialEq, Serialize)] pub enum FlagsRepr { U8, @@ -511,6 +529,7 @@ pub struct Variant { pub struct Case { pub docs: Docs, pub name: String, + #[serde(rename = "type")] pub ty: Option, } diff --git a/crates/wit-parser/src/serde_.rs b/crates/wit-parser/src/serde_.rs index 7bad6c1680..b489ff017b 100644 --- a/crates/wit-parser/src/serde_.rs +++ b/crates/wit-parser/src/serde_.rs @@ -1,6 +1,6 @@ use serde::ser::{SerializeSeq, SerializeStruct, Serializer}; use serde::Serialize; -use crate::{Docs, Function, FunctionKind, Params, Results, Type, WorldItem}; +use crate::{Docs, Function, FunctionKind, Params, Results, Type}; use crate::id_arena_::Id; impl Serialize for Id { @@ -12,25 +12,6 @@ impl Serialize for Id { } } -impl Serialize for WorldItem { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - match self { - WorldItem::Interface(interface_id) => { - serializer.serialize_newtype_variant("WorldItem", 0, "Interface", &(interface_id.index() as u64)) - } - WorldItem::Function(func) => { - serializer.serialize_newtype_variant("WorldItem", 1, "Function", func) - } - WorldItem::Type(type_id) => { - serializer.serialize_newtype_variant("WorldItem", 2, "Type", &(type_id.index() as u64)) - } - } - } -} - impl Serialize for Function { fn serialize(&self, serializer: S) -> Result where @@ -134,21 +115,10 @@ impl Serialize for Params { } } +#[derive(Debug, Clone, PartialEq, Serialize)] struct Param { + #[serde(skip_serializing_if = "Option::is_none")] pub name: Option, + #[serde(rename = "type")] pub ty: Type } - -impl Serialize for Param { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut s = serializer.serialize_struct("Param", 2)?; - if let Some(name) = &self.name { - s.serialize_field("name", name)?; - } - s.serialize_field("type", &self.ty)?; - s.end() - } -} From ea455fbda57089e9fcfd183854a031d93a6b1b96 Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Thu, 31 Aug 2023 21:49:13 -0700 Subject: [PATCH 13/40] wit-parser: implement Serialize in a function This should allow wit-parser to serialize without the upstream patch to id_arena. --- crates/wit-parser/src/resolve.rs | 5 +++++ crates/wit-parser/src/serde_.rs | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/crates/wit-parser/src/resolve.rs b/crates/wit-parser/src/resolve.rs index e07c306ace..55de466a02 100644 --- a/crates/wit-parser/src/resolve.rs +++ b/crates/wit-parser/src/resolve.rs @@ -6,6 +6,7 @@ use crate::{ WorldId, WorldItem, WorldKey, }; use crate::id_arena_::{Arena, Id}; +use crate::serde_::serialize_arena; use anyhow::{anyhow, bail, Context, Result}; use indexmap::{IndexMap, IndexSet}; use serde::Serialize; @@ -28,9 +29,13 @@ use std::path::{Path, PathBuf}; /// package as necessary. #[derive(Default, Clone, Serialize)] pub struct Resolve { + #[serde(serialize_with = "serialize_arena")] pub worlds: Arena, + #[serde(serialize_with = "serialize_arena")] pub interfaces: Arena, + #[serde(serialize_with = "serialize_arena")] pub types: Arena, + #[serde(serialize_with = "serialize_arena")] pub packages: Arena, #[serde(skip)] pub package_names: IndexMap, diff --git a/crates/wit-parser/src/serde_.rs b/crates/wit-parser/src/serde_.rs index b489ff017b..3a720c3a71 100644 --- a/crates/wit-parser/src/serde_.rs +++ b/crates/wit-parser/src/serde_.rs @@ -1,7 +1,20 @@ use serde::ser::{SerializeSeq, SerializeStruct, Serializer}; use serde::Serialize; use crate::{Docs, Function, FunctionKind, Params, Results, Type}; -use crate::id_arena_::Id; +use crate::id_arena_::{Arena, Id}; + +pub fn serialize_arena(v: &Arena, serializer: S) -> Result +where + T: Serialize, + S: Serializer, +{ + let mut seq = serializer.serialize_seq(Some(v.len()))?; + for (_, item) in v.iter() { + seq.serialize_element(&item)?; + } + seq.end() +} + impl Serialize for Id { fn serialize(&self, serializer: S) -> Result From b5c68b4f7b99630ace7304d0e1bb3b9167898233 Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Thu, 31 Aug 2023 21:53:02 -0700 Subject: [PATCH 14/40] wit-parser: remove dependency on fork of id-arena crate --- Cargo.lock | 12 ++---------- crates/wit-parser/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5d044b316f..e7c6686a90 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -807,14 +807,6 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" -[[package]] -name = "id-arena" -version = "2.2.1" -source = "git+https://github.com/Mossaka/id-arena-fork?rev=cae2a0a63d505adec402289eea90c52d3205007a#cae2a0a63d505adec402289eea90c52d3205007a" -dependencies = [ - "serde", -] - [[package]] name = "idna" version = "0.4.0" @@ -2383,7 +2375,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "541efa2046e544de53a9da1e2f6299e63079840360c9e106f1f8275a97771318" dependencies = [ "anyhow", - "id-arena 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "id-arena", "indexmap 2.0.0", "log", "pulldown-cmark", @@ -2398,7 +2390,7 @@ version = "0.11.0" dependencies = [ "anyhow", "env_logger", - "id-arena 2.2.1 (git+https://github.com/Mossaka/id-arena-fork?rev=cae2a0a63d505adec402289eea90c52d3205007a)", + "id-arena", "indexmap 2.0.0", "log", "pretty_assertions", diff --git a/crates/wit-parser/Cargo.toml b/crates/wit-parser/Cargo.toml index d05730900b..5b3b5a95f9 100644 --- a/crates/wit-parser/Cargo.toml +++ b/crates/wit-parser/Cargo.toml @@ -13,7 +13,7 @@ Tooling for parsing `*.wit` files and working with their contents. """ [dependencies] -id-arena = { git = "https://github.com/Mossaka/id-arena-fork", rev = "cae2a0a63d505adec402289eea90c52d3205007a" } +id-arena = "2" anyhow = { workspace = true } indexmap = { workspace = true, features = ["serde"] } pulldown-cmark = { version = "0.9.3", default-features = false } From 38901e4dfa0deb070a9631b2c4485fac10e24a64 Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Sat, 2 Sep 2023 11:37:07 -0700 Subject: [PATCH 15/40] wit-parser: remove custom Serialize impl for Function --- crates/wit-parser/src/lib.rs | 2 +- crates/wit-parser/src/serde_.rs | 17 +---------------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/crates/wit-parser/src/lib.rs b/crates/wit-parser/src/lib.rs index 201a06f287..ff382c4013 100644 --- a/crates/wit-parser/src/lib.rs +++ b/crates/wit-parser/src/lib.rs @@ -667,7 +667,7 @@ impl Results { } } -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] pub struct Function { pub docs: Docs, pub name: String, diff --git a/crates/wit-parser/src/serde_.rs b/crates/wit-parser/src/serde_.rs index 3a720c3a71..770581f696 100644 --- a/crates/wit-parser/src/serde_.rs +++ b/crates/wit-parser/src/serde_.rs @@ -1,6 +1,6 @@ use serde::ser::{SerializeSeq, SerializeStruct, Serializer}; use serde::Serialize; -use crate::{Docs, Function, FunctionKind, Params, Results, Type}; +use crate::{Docs, FunctionKind, Params, Results, Type}; use crate::id_arena_::{Arena, Id}; pub fn serialize_arena(v: &Arena, serializer: S) -> Result @@ -25,21 +25,6 @@ impl Serialize for Id { } } -impl Serialize for Function { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut s = serializer.serialize_struct("Function", 5)?; - s.serialize_field("docs", &self.docs)?; - s.serialize_field("name", &self.name)?; - s.serialize_field("kind", &self.kind)?; - s.serialize_field("params", &self.params)?; - s.serialize_field("results", &self.results)?; - s.end() - } -} - impl Serialize for Docs { fn serialize(&self, serializer: S) -> Result where From 706d4895ee283774b0b77023b876f7f7d65829eb Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Sat, 2 Sep 2023 11:54:43 -0700 Subject: [PATCH 16/40] wit-parser: remove custom Serialize impl for Docs --- crates/wit-parser/src/lib.rs | 2 +- crates/wit-parser/src/serde_.rs | 16 ++-------------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/crates/wit-parser/src/lib.rs b/crates/wit-parser/src/lib.rs index ff382c4013..564bbf87aa 100644 --- a/crates/wit-parser/src/lib.rs +++ b/crates/wit-parser/src/lib.rs @@ -578,7 +578,7 @@ pub struct Stream { pub end: Option, } -#[derive(Clone, Default, Debug, PartialEq, Eq)] +#[derive(Clone, Default, Debug, PartialEq, Eq, Serialize)] pub struct Docs { pub contents: Option, } diff --git a/crates/wit-parser/src/serde_.rs b/crates/wit-parser/src/serde_.rs index 770581f696..975d1ce947 100644 --- a/crates/wit-parser/src/serde_.rs +++ b/crates/wit-parser/src/serde_.rs @@ -1,6 +1,6 @@ -use serde::ser::{SerializeSeq, SerializeStruct, Serializer}; +use serde::ser::{SerializeSeq, Serializer}; use serde::Serialize; -use crate::{Docs, FunctionKind, Params, Results, Type}; +use crate::{FunctionKind, Params, Results, Type}; use crate::id_arena_::{Arena, Id}; pub fn serialize_arena(v: &Arena, serializer: S) -> Result @@ -15,7 +15,6 @@ where seq.end() } - impl Serialize for Id { fn serialize(&self, serializer: S) -> Result where @@ -25,17 +24,6 @@ impl Serialize for Id { } } -impl Serialize for Docs { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut s = serializer.serialize_struct("Docs", 2)?; - s.serialize_field("contents", &self.contents)?; - s.end() - } -} - impl Serialize for FunctionKind { fn serialize(&self, serializer: S) -> Result where From 9d952996f8c8ee73df140e2ab97579c6e65fc1bb Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Sat, 2 Sep 2023 12:13:13 -0700 Subject: [PATCH 17/40] wit-parser: custom Serialize implementation for Handle and TypeOwner --- crates/wit-parser/src/lib.rs | 6 ++---- crates/wit-parser/src/serde_.rs | 35 ++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/crates/wit-parser/src/lib.rs b/crates/wit-parser/src/lib.rs index 564bbf87aa..f2f4f2de14 100644 --- a/crates/wit-parser/src/lib.rs +++ b/crates/wit-parser/src/lib.rs @@ -405,8 +405,7 @@ impl TypeDefKind { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize)] -#[serde(rename_all = "lowercase")] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum TypeOwner { /// This type was defined within a `world` block. World(WorldId), @@ -417,8 +416,7 @@ pub enum TypeOwner { None, } -#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, Serialize)] -#[serde(rename_all = "lowercase")] +#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone)] pub enum Handle { Own(TypeId), Borrow(TypeId), diff --git a/crates/wit-parser/src/serde_.rs b/crates/wit-parser/src/serde_.rs index 975d1ce947..86f548527d 100644 --- a/crates/wit-parser/src/serde_.rs +++ b/crates/wit-parser/src/serde_.rs @@ -1,6 +1,6 @@ use serde::ser::{SerializeSeq, Serializer}; use serde::Serialize; -use crate::{FunctionKind, Params, Results, Type}; +use crate::{FunctionKind, Handle, Params, Results, Type, TypeOwner}; use crate::id_arena_::{Arena, Id}; pub fn serialize_arena(v: &Arena, serializer: S) -> Result @@ -68,6 +68,39 @@ impl Serialize for Type { } } +impl Serialize for TypeOwner { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + TypeOwner::World(world_id) => { + serializer.serialize_newtype_variant("TypeOwner", 0, "world", &(world_id.index() as u64)) + } + TypeOwner::Interface(interface_id) => { + serializer.serialize_newtype_variant("TypeOwner", 1, "interface", &(interface_id.index() as u64)) + } + TypeOwner::None => serializer.serialize_none(), + } + } +} + +impl Serialize for Handle { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Handle::Own(type_id) => { + serializer.serialize_newtype_variant("Handle", 0, "own", &(type_id.index() as u64)) + } + Handle::Borrow(type_id) => { + serializer.serialize_newtype_variant("Handle", 1, "borrow", &(type_id.index() as u64)) + } + } + } +} + impl Serialize for Results { fn serialize(&self, serializer: S) -> Result where From 79188fb7e583ccb6973fcef105e8b2583d73423d Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Sat, 2 Sep 2023 12:17:18 -0700 Subject: [PATCH 18/40] wit-parser: custom Serialize impl for WorldItem --- crates/wit-parser/src/lib.rs | 3 +-- crates/wit-parser/src/serde_.rs | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/crates/wit-parser/src/lib.rs b/crates/wit-parser/src/lib.rs index f2f4f2de14..889196fefc 100644 --- a/crates/wit-parser/src/lib.rs +++ b/crates/wit-parser/src/lib.rs @@ -309,8 +309,7 @@ impl WorldKey { } } -#[derive(Debug, Clone, PartialEq, Serialize)] -#[serde(rename_all = "lowercase")] +#[derive(Debug, Clone, PartialEq)] pub enum WorldItem { /// An interface is being imported or exported from a world, indicating that /// it's a namespace of functions. diff --git a/crates/wit-parser/src/serde_.rs b/crates/wit-parser/src/serde_.rs index 86f548527d..84c83b60a5 100644 --- a/crates/wit-parser/src/serde_.rs +++ b/crates/wit-parser/src/serde_.rs @@ -1,6 +1,6 @@ use serde::ser::{SerializeSeq, Serializer}; use serde::Serialize; -use crate::{FunctionKind, Handle, Params, Results, Type, TypeOwner}; +use crate::{FunctionKind, Handle, Params, Results, Type, TypeOwner, WorldItem}; use crate::id_arena_::{Arena, Id}; pub fn serialize_arena(v: &Arena, serializer: S) -> Result @@ -24,6 +24,25 @@ impl Serialize for Id { } } +impl Serialize for WorldItem { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + WorldItem::Interface(interface_id) => { + serializer.serialize_newtype_variant("WorldItem", 0, "interface", &(interface_id.index() as u64)) + } + WorldItem::Function(func) => { + serializer.serialize_newtype_variant("WorldItem", 2, "function", func) + } + WorldItem::Type(type_id) => { + serializer.serialize_newtype_variant("WorldItem", 2, "type", &(type_id.index() as u64)) + } + } + } +} + impl Serialize for FunctionKind { fn serialize(&self, serializer: S) -> Result where From 2fdeb0ce474cc4f6d9dc85398de1cfb13804a4fe Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Sat, 2 Sep 2023 12:29:52 -0700 Subject: [PATCH 19/40] wit-parser: Serialize enums with less code --- crates/wit-parser/src/lib.rs | 16 +++++++-- crates/wit-parser/src/serde_.rs | 61 +++++---------------------------- 2 files changed, 21 insertions(+), 56 deletions(-) diff --git a/crates/wit-parser/src/lib.rs b/crates/wit-parser/src/lib.rs index 889196fefc..a08086ae75 100644 --- a/crates/wit-parser/src/lib.rs +++ b/crates/wit-parser/src/lib.rs @@ -19,6 +19,7 @@ pub use live::LiveTypes; mod version; pub use version::SerializableVersion; mod serde_; +use serde_::{serialize_id}; mod id_arena_; use id_arena_::{Arena, Id}; @@ -309,10 +310,12 @@ impl WorldKey { } } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Serialize)] +#[serde(rename_all = "lowercase")] pub enum WorldItem { /// An interface is being imported or exported from a world, indicating that /// it's a namespace of functions. + #[serde(serialize_with = "serialize_id")] Interface(InterfaceId), /// A function is being directly imported or exported from this world. @@ -321,6 +324,7 @@ pub enum WorldItem { /// A type is being exported from this world. /// /// Note that types are never imported into worlds at this time. + #[serde(serialize_with = "serialize_id")] Type(TypeId), } @@ -404,20 +408,26 @@ impl TypeDefKind { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize)] +#[serde(rename_all = "lowercase")] pub enum TypeOwner { /// This type was defined within a `world` block. + #[serde(serialize_with = "serialize_id")] World(WorldId), /// This type was defined within an `interface` block. + #[serde(serialize_with = "serialize_id")] Interface(InterfaceId), /// This type wasn't inherently defined anywhere, such as a `list`, which /// doesn't need an owner. None, } -#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone)] +#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, Serialize)] +#[serde(rename_all = "lowercase")] pub enum Handle { + #[serde(serialize_with = "serialize_id")] Own(TypeId), + #[serde(serialize_with = "serialize_id")] Borrow(TypeId), } diff --git a/crates/wit-parser/src/serde_.rs b/crates/wit-parser/src/serde_.rs index 84c83b60a5..c8eeb2ed9a 100644 --- a/crates/wit-parser/src/serde_.rs +++ b/crates/wit-parser/src/serde_.rs @@ -1,6 +1,6 @@ use serde::ser::{SerializeSeq, Serializer}; use serde::Serialize; -use crate::{FunctionKind, Handle, Params, Results, Type, TypeOwner, WorldItem}; +use crate::{FunctionKind, Params, Results, Type}; use crate::id_arena_::{Arena, Id}; pub fn serialize_arena(v: &Arena, serializer: S) -> Result @@ -15,31 +15,19 @@ where seq.end() } -impl Serialize for Id { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - serializer.serialize_u64(self.index() as u64) - } +pub fn serialize_id(id: &Id, serializer: S) -> Result +where + S: Serializer, +{ + serializer.serialize_u64(id.index() as u64) } -impl Serialize for WorldItem { +impl Serialize for Id { fn serialize(&self, serializer: S) -> Result where S: Serializer, { - match self { - WorldItem::Interface(interface_id) => { - serializer.serialize_newtype_variant("WorldItem", 0, "interface", &(interface_id.index() as u64)) - } - WorldItem::Function(func) => { - serializer.serialize_newtype_variant("WorldItem", 2, "function", func) - } - WorldItem::Type(type_id) => { - serializer.serialize_newtype_variant("WorldItem", 2, "type", &(type_id.index() as u64)) - } - } + serializer.serialize_u64(self.index() as u64) } } @@ -87,39 +75,6 @@ impl Serialize for Type { } } -impl Serialize for TypeOwner { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - match self { - TypeOwner::World(world_id) => { - serializer.serialize_newtype_variant("TypeOwner", 0, "world", &(world_id.index() as u64)) - } - TypeOwner::Interface(interface_id) => { - serializer.serialize_newtype_variant("TypeOwner", 1, "interface", &(interface_id.index() as u64)) - } - TypeOwner::None => serializer.serialize_none(), - } - } -} - -impl Serialize for Handle { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - match self { - Handle::Own(type_id) => { - serializer.serialize_newtype_variant("Handle", 0, "own", &(type_id.index() as u64)) - } - Handle::Borrow(type_id) => { - serializer.serialize_newtype_variant("Handle", 1, "borrow", &(type_id.index() as u64)) - } - } - } -} - impl Serialize for Results { fn serialize(&self, serializer: S) -> Result where From abd730f1de638da9031d2e79d573c4358cd03afa Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Sat, 2 Sep 2023 18:27:21 -0700 Subject: [PATCH 20/40] wit-parser: implement lowercase derived impl Serialize for FunctionKind --- crates/wit-parser/src/lib.rs | 6 +++++- crates/wit-parser/src/serde_.rs | 22 +--------------------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/crates/wit-parser/src/lib.rs b/crates/wit-parser/src/lib.rs index a08086ae75..345792e914 100644 --- a/crates/wit-parser/src/lib.rs +++ b/crates/wit-parser/src/lib.rs @@ -683,11 +683,15 @@ pub struct Function { pub results: Results, } -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +#[serde(rename_all = "lowercase")] pub enum FunctionKind { Freestanding, + #[serde(serialize_with = "serialize_id")] Method(TypeId), + #[serde(serialize_with = "serialize_id")] Static(TypeId), + #[serde(serialize_with = "serialize_id")] Constructor(TypeId), } diff --git a/crates/wit-parser/src/serde_.rs b/crates/wit-parser/src/serde_.rs index c8eeb2ed9a..2f6a673bb4 100644 --- a/crates/wit-parser/src/serde_.rs +++ b/crates/wit-parser/src/serde_.rs @@ -1,6 +1,6 @@ use serde::ser::{SerializeSeq, Serializer}; use serde::Serialize; -use crate::{FunctionKind, Params, Results, Type}; +use crate::{Params, Results, Type}; use crate::id_arena_::{Arena, Id}; pub fn serialize_arena(v: &Arena, serializer: S) -> Result @@ -31,26 +31,6 @@ impl Serialize for Id { } } -impl Serialize for FunctionKind { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - match self { - FunctionKind::Freestanding => serializer.serialize_str("Freestanding"), - FunctionKind::Method(type_id) => { - serializer.serialize_newtype_variant("FunctionKind", 0, "Method", &(type_id.index() as u64)) - } - FunctionKind::Static(type_id) => { - serializer.serialize_newtype_variant("FunctionKind", 1, "Static", &(type_id.index() as u64)) - } - FunctionKind::Constructor(type_id) => { - serializer.serialize_newtype_variant("FunctionKind", 2, "Constructor", &(type_id.index() as u64)) - } - } - } -} - impl Serialize for Type { fn serialize(&self, serializer: S) -> Result where From 1771e10a26e2c5a96af21f211fd2d2f2563e47e4 Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Sat, 2 Sep 2023 18:29:18 -0700 Subject: [PATCH 21/40] wit-parser: serialize WIT types in JSON in their lowercase form --- crates/wit-parser/src/serde_.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/crates/wit-parser/src/serde_.rs b/crates/wit-parser/src/serde_.rs index 2f6a673bb4..e9b90ba96f 100644 --- a/crates/wit-parser/src/serde_.rs +++ b/crates/wit-parser/src/serde_.rs @@ -37,19 +37,19 @@ impl Serialize for Type { S: Serializer, { match self { - Type::Bool => serializer.serialize_str("Bool"), - Type::U8 => serializer.serialize_str("U8"), - Type::U16 => serializer.serialize_str("U16"), - Type::U32 => serializer.serialize_str("U32"), - Type::U64 => serializer.serialize_str("U64"), - Type::S8 => serializer.serialize_str("S8"), - Type::S16 => serializer.serialize_str("S16"), - Type::S32 => serializer.serialize_str("S32"), - Type::S64 => serializer.serialize_str("S64"), - Type::Float32 => serializer.serialize_str("Float32"), - Type::Float64 => serializer.serialize_str("Float64"), - Type::Char => serializer.serialize_str("Char"), - Type::String => serializer.serialize_str("String"), + Type::Bool => serializer.serialize_str("bool"), + Type::U8 => serializer.serialize_str("u8"), + Type::U16 => serializer.serialize_str("u16"), + Type::U32 => serializer.serialize_str("u32"), + Type::U64 => serializer.serialize_str("u64"), + Type::S8 => serializer.serialize_str("s8"), + Type::S16 => serializer.serialize_str("s16"), + Type::S32 => serializer.serialize_str("s32"), + Type::S64 => serializer.serialize_str("s64"), + Type::Float32 => serializer.serialize_str("float32"), + Type::Float64 => serializer.serialize_str("float64"), + Type::Char => serializer.serialize_str("char"), + Type::String => serializer.serialize_str("string"), Type::Id(type_id) => serializer.serialize_u64(type_id.index() as u64) } } From ccb7e5c360c28ba38458813841096bd8f38907ed Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Sat, 2 Sep 2023 18:57:07 -0700 Subject: [PATCH 22/40] wit-component, wit-parser: remove custom Params type Handle serialization using existing type alias to not break existing public API. --- crates/wit-component/src/decoding.rs | 6 ++-- crates/wit-parser/src/ast/resolve.rs | 2 +- crates/wit-parser/src/lib.rs | 25 +++---------- crates/wit-parser/src/serde_.rs | 53 ++++++++++++++++------------ 4 files changed, 39 insertions(+), 47 deletions(-) diff --git a/crates/wit-component/src/decoding.rs b/crates/wit-component/src/decoding.rs index 7d8fe2b323..ac7ab1b012 100644 --- a/crates/wit-component/src/decoding.rs +++ b/crates/wit-component/src/decoding.rs @@ -871,7 +871,7 @@ impl WitPackageDecoder<'_> { .context("failed to convert anonymous result type")?, ) } else { - Results::Named(Params( + Results::Named( ty.results .iter() .map(|(name, ty)| { @@ -882,7 +882,7 @@ impl WitPackageDecoder<'_> { }) .collect::>>() .context("failed to convert named result types")?, - )) + ) }; Ok(Function { docs: Default::default(), @@ -907,7 +907,7 @@ impl WitPackageDecoder<'_> { // discriminant calculated above indicates how to interpret this // name. name: name.to_string(), - params: Params(params), + params: params, results, }) } diff --git a/crates/wit-parser/src/ast/resolve.rs b/crates/wit-parser/src/ast/resolve.rs index 3faca7ca65..e7ece4cf07 100644 --- a/crates/wit-parser/src/ast/resolve.rs +++ b/crates/wit-parser/src/ast/resolve.rs @@ -1295,7 +1295,7 @@ impl<'a> Resolver<'a> { } fn resolve_params(&mut self, params: &ParamList<'_>, kind: &FunctionKind) -> Result { - let mut ret = Params(Vec::new()); + let mut ret = Vec::new(); match *kind { // These kinds of methods don't have any adjustments to the // parameters, so do nothing here. diff --git a/crates/wit-parser/src/lib.rs b/crates/wit-parser/src/lib.rs index 345792e914..c0bfd2c442 100644 --- a/crates/wit-parser/src/lib.rs +++ b/crates/wit-parser/src/lib.rs @@ -3,7 +3,6 @@ use indexmap::IndexMap; use serde::Serialize; use std::borrow::Cow; use std::fmt; -use std::ops::{Deref, DerefMut}; use std::path::Path; pub mod abi; @@ -19,7 +18,7 @@ pub use live::LiveTypes; mod version; pub use version::SerializableVersion; mod serde_; -use serde_::{serialize_id}; +use serde_::{serialize_id, serialize_params}; mod id_arena_; use id_arena_::{Arena, Id}; @@ -590,24 +589,7 @@ pub struct Docs { pub contents: Option, } -// pub type Params = Vec<(String, Type)>; - -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct Params(pub Vec<(String, Type)>); - -impl Deref for Params { - type Target = Vec<(String, Type)>; - fn deref(&self) -> &Vec<(String, Type)> { - &self.0 - } -} - -impl DerefMut for Params { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.0 - } -} - +pub type Params = Vec<(String, Type)>; #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum Results { @@ -643,7 +625,7 @@ impl<'a> ExactSizeIterator for ResultsTypeIter<'a> {} impl Results { // For the common case of an empty results list. pub fn empty() -> Results { - Results::Named(Params(Vec::new())) + Results::Named(Vec::new()) } pub fn len(&self) -> usize { @@ -679,6 +661,7 @@ pub struct Function { pub docs: Docs, pub name: String, pub kind: FunctionKind, + #[serde(serialize_with="serialize_params")] pub params: Params, pub results: Results, } diff --git a/crates/wit-parser/src/serde_.rs b/crates/wit-parser/src/serde_.rs index e9b90ba96f..c0c6320441 100644 --- a/crates/wit-parser/src/serde_.rs +++ b/crates/wit-parser/src/serde_.rs @@ -3,13 +3,13 @@ use serde::Serialize; use crate::{Params, Results, Type}; use crate::id_arena_::{Arena, Id}; -pub fn serialize_arena(v: &Arena, serializer: S) -> Result +pub fn serialize_arena(arena: &Arena, serializer: S) -> Result where T: Serialize, S: Serializer, { - let mut seq = serializer.serialize_seq(Some(v.len()))?; - for (_, item) in v.iter() { + let mut seq = serializer.serialize_seq(Some(arena.len()))?; + for (_, item) in arena.iter() { seq.serialize_element(&item)?; } seq.end() @@ -62,36 +62,45 @@ impl Serialize for Results { { match self { Results::Named(params) => { - serializer.serialize_some(params) + serialize_params(params, serializer) } Results::Anon(typ) => { - let mut seq = serializer.serialize_seq(Some(1))?; - let param = Param{name: None, ty: *typ}; - seq.serialize_element(¶m)?; - seq.end() + let params: Params = vec![(String::default(), *typ)]; + serialize_params(¶ms, serializer) } } } } -impl Serialize for Params { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut seq = serializer.serialize_seq(Some(self.len()))?; - for (name, typ) in self.iter() { - let param = Param{name: Some(name.to_string()), ty: *typ}; - seq.serialize_element(¶m)?; - } - seq.end() +pub fn serialize_params(params: &Params, serializer: S) -> Result +where + S: Serializer, +{ + let mut seq = serializer.serialize_seq(Some(params.len()))?; + for (name, typ) in params.iter() { + let param = Param{name: name.to_string(), typ: *typ}; + seq.serialize_element(¶m)?; } + seq.end() } #[derive(Debug, Clone, PartialEq, Serialize)] struct Param { - #[serde(skip_serializing_if = "Option::is_none")] - pub name: Option, + #[serde(skip_serializing_if = "String::is_empty")] + pub name: String, #[serde(rename = "type")] - pub ty: Type + pub typ: Type } + +// pub fn serialize_param(param: &(String, Type), serializer: S) -> Result +// where +// S: Serializer, +// { +// let len = if param.0.is_empty() { 1 } else { 2 }; +// let mut s = serializer.serialize_struct("Param", len)?; +// if !param.0.is_empty() { +// s.serialize_field("name", ¶m.0) +// } +// s.serialize_field("type", ¶m.1); +// s.end() +// } From 52015c7504ec5881f673c3f20dabc4b9b4285342 Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Sat, 2 Sep 2023 19:03:57 -0700 Subject: [PATCH 23/40] wit-parser: remove commented-out serialize fn --- crates/wit-parser/src/serde_.rs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/crates/wit-parser/src/serde_.rs b/crates/wit-parser/src/serde_.rs index c0c6320441..cdd490ce43 100644 --- a/crates/wit-parser/src/serde_.rs +++ b/crates/wit-parser/src/serde_.rs @@ -91,16 +91,3 @@ struct Param { #[serde(rename = "type")] pub typ: Type } - -// pub fn serialize_param(param: &(String, Type), serializer: S) -> Result -// where -// S: Serializer, -// { -// let len = if param.0.is_empty() { 1 } else { 2 }; -// let mut s = serializer.serialize_struct("Param", len)?; -// if !param.0.is_empty() { -// s.serialize_field("name", ¶m.0) -// } -// s.serialize_field("type", ¶m.1); -// s.end() -// } From 61e48b11ef2700bc29fb63c80eacf9ae41c014ae Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Sat, 2 Sep 2023 19:04:19 -0700 Subject: [PATCH 24/40] wit-parser: remove custom Serialize impl for Results --- crates/wit-parser/src/lib.rs | 7 +++++-- crates/wit-parser/src/serde_.rs | 23 +++++++---------------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/crates/wit-parser/src/lib.rs b/crates/wit-parser/src/lib.rs index c0bfd2c442..b7ab92c141 100644 --- a/crates/wit-parser/src/lib.rs +++ b/crates/wit-parser/src/lib.rs @@ -18,7 +18,7 @@ pub use live::LiveTypes; mod version; pub use version::SerializableVersion; mod serde_; -use serde_::{serialize_id, serialize_params}; +use serde_::{serialize_anon_result, serialize_id, serialize_params}; mod id_arena_; use id_arena_::{Arena, Id}; @@ -591,9 +591,12 @@ pub struct Docs { pub type Params = Vec<(String, Type)>; -#[derive(Debug, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize)] +#[serde(untagged)] pub enum Results { + #[serde(serialize_with="serialize_params")] Named(Params), + #[serde(serialize_with="serialize_anon_result")] Anon(Type), } diff --git a/crates/wit-parser/src/serde_.rs b/crates/wit-parser/src/serde_.rs index cdd490ce43..d4591bab5b 100644 --- a/crates/wit-parser/src/serde_.rs +++ b/crates/wit-parser/src/serde_.rs @@ -1,6 +1,6 @@ use serde::ser::{SerializeSeq, Serializer}; use serde::Serialize; -use crate::{Params, Results, Type}; +use crate::{Params, Type}; use crate::id_arena_::{Arena, Id}; pub fn serialize_arena(arena: &Arena, serializer: S) -> Result @@ -55,21 +55,12 @@ impl Serialize for Type { } } -impl Serialize for Results { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - match self { - Results::Named(params) => { - serialize_params(params, serializer) - } - Results::Anon(typ) => { - let params: Params = vec![(String::default(), *typ)]; - serialize_params(¶ms, serializer) - } - } - } +pub fn serialize_anon_result(typ: &Type, serializer: S) -> Result +where + S: Serializer, +{ + let params: Params = vec![(String::default(), *typ)]; + serialize_params(¶ms, serializer) } pub fn serialize_params(params: &Params, serializer: S) -> Result From db4b0912019b07c21c5845a913ecc1662863fe82 Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Sat, 2 Sep 2023 19:28:46 -0700 Subject: [PATCH 25/40] wit-parser: remove custom ArenaBehavior in favor of serialize_\* functions --- crates/wit-parser/src/id_arena_.rs | 97 ------------------------------ crates/wit-parser/src/lib.rs | 11 +++- crates/wit-parser/src/resolve.rs | 6 +- crates/wit-parser/src/serde_.rs | 30 ++++++--- 4 files changed, 34 insertions(+), 110 deletions(-) delete mode 100644 crates/wit-parser/src/id_arena_.rs diff --git a/crates/wit-parser/src/id_arena_.rs b/crates/wit-parser/src/id_arena_.rs deleted file mode 100644 index f7624f542c..0000000000 --- a/crates/wit-parser/src/id_arena_.rs +++ /dev/null @@ -1,97 +0,0 @@ -use core::marker::PhantomData; -use id_arena; -use core::cmp::Ordering; -use core::fmt; -use core::hash::{Hash, Hasher}; - -/// An identifier for an object allocated within an arena. -pub struct Id { - idx: usize, - arena_id: u32, - _ty: PhantomData T>, -} - -impl fmt::Debug for Id { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("Id").field("idx", &self.idx).finish() - } -} - -impl Copy for Id {} - -impl Clone for Id { - #[inline] - fn clone(&self) -> Id { - *self - } -} - -impl PartialEq for Id { - #[inline] - fn eq(&self, rhs: &Self) -> bool { - self.arena_id == rhs.arena_id && self.idx == rhs.idx - } -} - -impl Eq for Id {} - -impl Hash for Id { - #[inline] - fn hash(&self, h: &mut H) { - self.arena_id.hash(h); - self.idx.hash(h); - } -} - -impl PartialOrd for Id { - fn partial_cmp(&self, rhs: &Self) -> Option { - Some(self.cmp(rhs)) - } -} - -impl Ord for Id { - fn cmp(&self, rhs: &Self) -> Ordering { - self.arena_id - .cmp(&rhs.arena_id) - .then(self.idx.cmp(&rhs.idx)) - } -} - -impl Id { - /// Get the index within the arena that this id refers to. - #[inline] - pub fn index(&self) -> usize { - self.idx - } -} - -/// Our `ArenaBehavior` implementation. -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct ArenaBehavior { - _phantom: PhantomData T>, -} - -impl id_arena::ArenaBehavior for ArenaBehavior { - type Id = Id; - - #[inline] - fn new_id(arena_id: u32, idx: usize) -> Self::Id { - Id { - idx, - arena_id, - _ty: PhantomData, - } - } - - #[inline] - fn index(id: Self::Id) -> usize { - id.idx - } - - #[inline] - fn arena_id(id: Self::Id) -> u32 { - id.arena_id - } -} - -pub type Arena> = id_arena::Arena; diff --git a/crates/wit-parser/src/lib.rs b/crates/wit-parser/src/lib.rs index b7ab92c141..ccd365cecd 100644 --- a/crates/wit-parser/src/lib.rs +++ b/crates/wit-parser/src/lib.rs @@ -1,4 +1,5 @@ use anyhow::{Context, Result}; +use id_arena::{Arena, Id}; use indexmap::IndexMap; use serde::Serialize; use std::borrow::Cow; @@ -18,9 +19,7 @@ pub use live::LiveTypes; mod version; pub use version::SerializableVersion; mod serde_; -use serde_::{serialize_anon_result, serialize_id, serialize_params}; -mod id_arena_; -use id_arena_::{Arena, Id}; +use serde_::{serialize_anon_result, serialize_id, serialize_optional_id, serialize_id_map, serialize_params}; /// Checks if the given string is a legal identifier in wit. pub fn validate_id(s: &str) -> Result<()> { @@ -107,8 +106,11 @@ pub struct UnresolvedPackage { } #[derive(Debug, Copy, Clone, Serialize)] +#[serde(rename_all = "lowercase")] pub enum AstItem { + #[serde(serialize_with = "serialize_id")] Interface(InterfaceId), + #[serde(serialize_with = "serialize_id")] World(WorldId), } @@ -258,6 +260,7 @@ pub struct World { pub exports: IndexMap, /// The package that owns this world. + #[serde(serialize_with="serialize_optional_id")] pub package: Option, /// All the included worlds from this world. Empty if this is fully resolved @@ -341,12 +344,14 @@ pub struct Interface { /// /// Export names are listed within the types themselves. Note that the /// export name here matches the name listed in the `TypeDef`. + #[serde(serialize_with = "serialize_id_map")] pub types: IndexMap, /// Exported functions from this interface. pub functions: IndexMap, /// The package that owns this interface. + #[serde(serialize_with = "serialize_optional_id")] pub package: Option, } diff --git a/crates/wit-parser/src/resolve.rs b/crates/wit-parser/src/resolve.rs index 55de466a02..5a32fc2531 100644 --- a/crates/wit-parser/src/resolve.rs +++ b/crates/wit-parser/src/resolve.rs @@ -5,9 +5,9 @@ use crate::{ PackageName, Results, Type, TypeDef, TypeDefKind, TypeId, TypeOwner, UnresolvedPackage, World, WorldId, WorldItem, WorldKey, }; -use crate::id_arena_::{Arena, Id}; -use crate::serde_::serialize_arena; +use crate::serde_::{serialize_arena, serialize_id_map}; use anyhow::{anyhow, bail, Context, Result}; +use id_arena::{Arena, Id}; use indexmap::{IndexMap, IndexSet}; use serde::Serialize; use std::collections::{BTreeMap, HashMap, HashSet}; @@ -56,9 +56,11 @@ pub struct Package { /// All interfaces contained in this packaged, keyed by the interface's /// name. + #[serde(serialize_with="serialize_id_map")] pub interfaces: IndexMap, /// All worlds contained in this package, keyed by the world's name. + #[serde(serialize_with="serialize_id_map")] pub worlds: IndexMap, } diff --git a/crates/wit-parser/src/serde_.rs b/crates/wit-parser/src/serde_.rs index d4591bab5b..72e4651f46 100644 --- a/crates/wit-parser/src/serde_.rs +++ b/crates/wit-parser/src/serde_.rs @@ -1,7 +1,8 @@ -use serde::ser::{SerializeSeq, Serializer}; +use id_arena::{Arena, Id}; +use indexmap::IndexMap; +use serde::ser::{Serializer, SerializeMap, SerializeSeq}; use serde::Serialize; use crate::{Params, Type}; -use crate::id_arena_::{Arena, Id}; pub fn serialize_arena(arena: &Arena, serializer: S) -> Result where @@ -22,13 +23,26 @@ where serializer.serialize_u64(id.index() as u64) } -impl Serialize for Id { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - serializer.serialize_u64(self.index() as u64) +pub fn serialize_optional_id(id: &Option>, serializer: S) -> Result +where + S: Serializer, +{ + match id { + Some(id) => serialize_id(&id, serializer), + None => serializer.serialize_none() + } +} + +pub fn serialize_id_map(map: &IndexMap>, serializer: S) -> Result +where + K: Serialize, + S: Serializer, +{ + let mut s = serializer.serialize_map(Some(map.len()))?; + for (key, id) in map.iter() { + s.serialize_entry(key, &(id.index() as u64))?; } + s.end() } impl Serialize for Type { From 3eff7f07e96592601e6302ec118830be35000d3f Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Sat, 2 Sep 2023 19:30:54 -0700 Subject: [PATCH 26/40] wit-component: revert unnecessary line change --- crates/wit-component/src/decoding.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/wit-component/src/decoding.rs b/crates/wit-component/src/decoding.rs index ac7ab1b012..32c6472d35 100644 --- a/crates/wit-component/src/decoding.rs +++ b/crates/wit-component/src/decoding.rs @@ -907,7 +907,7 @@ impl WitPackageDecoder<'_> { // discriminant calculated above indicates how to interpret this // name. name: name.to_string(), - params: params, + params, results, }) } From d49b5fb31e26e540129d76e7cbef1253a7feae86 Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Sat, 2 Sep 2023 19:33:47 -0700 Subject: [PATCH 27/40] wit-parser: revert unrelated change --- crates/wit-parser/src/live.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wit-parser/src/live.rs b/crates/wit-parser/src/live.rs index 47dac647bf..19ded9153f 100644 --- a/crates/wit-parser/src/live.rs +++ b/crates/wit-parser/src/live.rs @@ -25,8 +25,8 @@ impl LiveTypes { } } - pub fn add_world(&mut self, resolve: &Resolve, world_id: WorldId) { - let world = &resolve.worlds[world_id]; + pub fn add_world(&mut self, resolve: &Resolve, world: WorldId) { + let world = &resolve.worlds[world]; for (_, item) in world.imports.iter().chain(world.exports.iter()) { self.add_world_item(resolve, item); } From 5d9f3680c0c015274010bb9df10562dfab41396f Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Sat, 2 Sep 2023 19:36:25 -0700 Subject: [PATCH 28/40] wit-parser: remove Serialize impl from Int --- crates/wit-parser/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/wit-parser/src/lib.rs b/crates/wit-parser/src/lib.rs index ccd365cecd..9a5dbd1198 100644 --- a/crates/wit-parser/src/lib.rs +++ b/crates/wit-parser/src/lib.rs @@ -453,8 +453,7 @@ pub enum Type { Id(TypeId), } -#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize)] -#[serde(into = "String")] +#[derive(Debug, Copy, Clone, Eq, PartialEq)] pub enum Int { U8, U16, From 14230bf7455fcd3724d9c1211808945809c82dfe Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Sat, 2 Sep 2023 19:39:29 -0700 Subject: [PATCH 29/40] wit-parser: remove From for String --- crates/wit-parser/src/lib.rs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/crates/wit-parser/src/lib.rs b/crates/wit-parser/src/lib.rs index 9a5dbd1198..4eca18f45e 100644 --- a/crates/wit-parser/src/lib.rs +++ b/crates/wit-parser/src/lib.rs @@ -461,17 +461,6 @@ pub enum Int { U64, } -impl From for String { - fn from(i: Int) -> String { - (match i { - Int::U8 => "U8", - Int::U16 => "U16", - Int::U32 => "U32", - Int::U64 => "U64", - }).to_string() - } -} - #[derive(Debug, Clone, PartialEq, Serialize)] pub struct Record { pub fields: Vec, From dbf7bfd13673d2791fe93ac48b9798a191b3b768 Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Sat, 2 Sep 2023 19:41:56 -0700 Subject: [PATCH 30/40] wit-parser: remove Serialize impl from FlagsRepr Not needed? --- crates/wit-parser/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/wit-parser/src/lib.rs b/crates/wit-parser/src/lib.rs index 4eca18f45e..b3a1d1c075 100644 --- a/crates/wit-parser/src/lib.rs +++ b/crates/wit-parser/src/lib.rs @@ -485,8 +485,7 @@ pub struct Flag { pub name: String, } -// TODO(ydnar): impl Serialize -#[derive(Debug, Clone, PartialEq, Serialize)] +#[derive(Debug, Clone, PartialEq)] pub enum FlagsRepr { U8, U16, From 94678690494862a6e638f81949363d824ffcd60a Mon Sep 17 00:00:00 2001 From: "Jiaxiao Zhou (Mossaka)" Date: Sat, 2 Sep 2023 20:26:12 -0700 Subject: [PATCH 31/40] fixed the tests and run rustfmt Signed-off-by: Jiaxiao Zhou (Mossaka) --- crates/wit-parser/src/lib.rs | 12 ++-- crates/wit-parser/src/resolve.rs | 114 +++++++++++++++++++++++-------- crates/wit-parser/src/serde_.rs | 15 ++-- 3 files changed, 101 insertions(+), 40 deletions(-) diff --git a/crates/wit-parser/src/lib.rs b/crates/wit-parser/src/lib.rs index b3a1d1c075..df0bbe2cb9 100644 --- a/crates/wit-parser/src/lib.rs +++ b/crates/wit-parser/src/lib.rs @@ -19,7 +19,9 @@ pub use live::LiveTypes; mod version; pub use version::SerializableVersion; mod serde_; -use serde_::{serialize_anon_result, serialize_id, serialize_optional_id, serialize_id_map, serialize_params}; +use serde_::{ + serialize_anon_result, serialize_id, serialize_id_map, serialize_optional_id, serialize_params, +}; /// Checks if the given string is a legal identifier in wit. pub fn validate_id(s: &str) -> Result<()> { @@ -260,7 +262,7 @@ pub struct World { pub exports: IndexMap, /// The package that owns this world. - #[serde(serialize_with="serialize_optional_id")] + #[serde(serialize_with = "serialize_optional_id")] pub package: Option, /// All the included worlds from this world. Empty if this is fully resolved @@ -586,9 +588,9 @@ pub type Params = Vec<(String, Type)>; #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize)] #[serde(untagged)] pub enum Results { - #[serde(serialize_with="serialize_params")] + #[serde(serialize_with = "serialize_params")] Named(Params), - #[serde(serialize_with="serialize_anon_result")] + #[serde(serialize_with = "serialize_anon_result")] Anon(Type), } @@ -656,7 +658,7 @@ pub struct Function { pub docs: Docs, pub name: String, pub kind: FunctionKind, - #[serde(serialize_with="serialize_params")] + #[serde(serialize_with = "serialize_params")] pub params: Params, pub results: Results, } diff --git a/crates/wit-parser/src/resolve.rs b/crates/wit-parser/src/resolve.rs index 5a32fc2531..afe722aad9 100644 --- a/crates/wit-parser/src/resolve.rs +++ b/crates/wit-parser/src/resolve.rs @@ -1,11 +1,11 @@ use crate::ast::lex::Span; use crate::ast::{parse_use_path, AstUsePath}; +use crate::serde_::{serialize_arena, serialize_id_map}; use crate::{ AstItem, Docs, Error, Function, FunctionKind, Handle, IncludeName, Interface, InterfaceId, PackageName, Results, Type, TypeDef, TypeDefKind, TypeId, TypeOwner, UnresolvedPackage, World, WorldId, WorldItem, WorldKey, }; -use crate::serde_::{serialize_arena, serialize_id_map}; use anyhow::{anyhow, bail, Context, Result}; use id_arena::{Arena, Id}; use indexmap::{IndexMap, IndexSet}; @@ -56,11 +56,11 @@ pub struct Package { /// All interfaces contained in this packaged, keyed by the interface's /// name. - #[serde(serialize_with="serialize_id_map")] + #[serde(serialize_with = "serialize_id_map")] pub interfaces: IndexMap, /// All worlds contained in this package, keyed by the world's name. - #[serde(serialize_with="serialize_id_map")] + #[serde(serialize_with = "serialize_id_map")] pub worlds: IndexMap, } @@ -1762,16 +1762,83 @@ mod tests { use super::*; + const EMPTY_RESOLVE: &str = + r#"{ "worlds": [], "interfaces": [], "types": [], "packages": [] }"#; + + const JSON_RESOLVE: &str = r#"{ + "worlds": [ + { + "name": "world1", + "docs": { "contents": null }, + "imports": {}, + "exports": {}, + "package": null + }, + { + "name": "world2", + "docs": { "contents": null }, + "imports": {}, + "exports": {}, + "package": null + } + ], + "interfaces": [ + { + "name": "interface1", + "docs": { "contents": null }, + "types": {}, + "functions": {}, + "package": null + }, + { + "name": "interface2", + "docs": { "contents": null }, + "types": {}, + "functions": {}, + "package": null + } + ], + "types": [ + { + "docs": { "contents": null }, + "kind": { "type": "bool" }, + "name": "type1", + "owner": "none" + }, + { + "docs": { "contents": null }, + "kind": { "record": { "fields": [] } }, + "name": "type2", + "owner": "none" + } + ], + "packages": [ + { + "name": "foo:package1", + "docs": { "contents": null }, + "interfaces": {}, + "worlds": {} + }, + { + "name": "foo:package2", + "docs": { "contents": null }, + "interfaces": {}, + "worlds": {} + } + ] + }"#; + #[test] - fn serialize_and_deserialize() -> Result<()> { + fn serialize_empty_resolve() -> Result<()> { let resolve = Resolve::default(); let s = serde_json::to_string(&resolve)?; - println!("{}", s); + let empty_resolve = EMPTY_RESOLVE.replace(" ", "").replace("\n", ""); + assert_eq!(s, empty_resolve); Ok(()) } #[test] - fn serialize_arena_world() -> Result<()> { + fn serialize_resolve() -> Result<()> { let mut worlds: Arena = Arena::new(); let world1 = World { name: "world1".to_string(), @@ -1794,13 +1861,6 @@ mod tests { worlds.alloc(world1); worlds.alloc(world2); - let s = serde_json::to_string(&worlds)?; - println!("{}", s); - Ok(()) - } - - #[test] - fn serialize_arena_interface() -> Result<()> { let mut interfaces: Arena = Arena::new(); let interface1 = Interface { name: Some("interface1".to_string()), @@ -1819,13 +1879,6 @@ mod tests { interfaces.alloc(interface1); interfaces.alloc(interface2); - let s = serde_json::to_string(&interfaces)?; - println!("{}", s); - Ok(()) - } - - #[test] - fn serialize_arena_type() -> Result<()> { let mut types: Arena = Arena::new(); let type1 = TypeDef { name: Some("type1".to_string()), @@ -1844,13 +1897,6 @@ mod tests { types.alloc(type1); types.alloc(type2); - let s = serde_json::to_string(&types)?; - println!("{}", s); - Ok(()) - } - - #[test] - fn serialize_packages() { let mut packages: Arena = Arena::new(); let package1 = Package { name: PackageName { @@ -1874,7 +1920,17 @@ mod tests { }; packages.alloc(package1); packages.alloc(package2); - let s = serde_json::to_string(&packages).unwrap(); - println!("{}", s); + + let resolve = Resolve { + packages, + interfaces, + types, + worlds, + package_names: Default::default(), + }; + let s = serde_json::to_string(&resolve).unwrap(); + let json_resolve = JSON_RESOLVE.replace(" ", "").replace("\n", ""); + assert_eq!(s, json_resolve); + Ok(()) } } diff --git a/crates/wit-parser/src/serde_.rs b/crates/wit-parser/src/serde_.rs index 72e4651f46..64497b3c96 100644 --- a/crates/wit-parser/src/serde_.rs +++ b/crates/wit-parser/src/serde_.rs @@ -1,8 +1,8 @@ +use crate::{Params, Type}; use id_arena::{Arena, Id}; use indexmap::IndexMap; -use serde::ser::{Serializer, SerializeMap, SerializeSeq}; +use serde::ser::{SerializeMap, SerializeSeq, Serializer}; use serde::Serialize; -use crate::{Params, Type}; pub fn serialize_arena(arena: &Arena, serializer: S) -> Result where @@ -29,7 +29,7 @@ where { match id { Some(id) => serialize_id(&id, serializer), - None => serializer.serialize_none() + None => serializer.serialize_none(), } } @@ -64,7 +64,7 @@ impl Serialize for Type { Type::Float64 => serializer.serialize_str("float64"), Type::Char => serializer.serialize_str("char"), Type::String => serializer.serialize_str("string"), - Type::Id(type_id) => serializer.serialize_u64(type_id.index() as u64) + Type::Id(type_id) => serializer.serialize_u64(type_id.index() as u64), } } } @@ -83,7 +83,10 @@ where { let mut seq = serializer.serialize_seq(Some(params.len()))?; for (name, typ) in params.iter() { - let param = Param{name: name.to_string(), typ: *typ}; + let param = Param { + name: name.to_string(), + typ: *typ, + }; seq.serialize_element(¶m)?; } seq.end() @@ -94,5 +97,5 @@ struct Param { #[serde(skip_serializing_if = "String::is_empty")] pub name: String, #[serde(rename = "type")] - pub typ: Type + pub typ: Type, } From 34baa97532f98d8e511a175ce022c20f2fb249ac Mon Sep 17 00:00:00 2001 From: "Jiaxiao Zhou (Mossaka)" Date: Sat, 2 Sep 2023 20:30:59 -0700 Subject: [PATCH 32/40] add serde_json to component feature Signed-off-by: Jiaxiao Zhou (Mossaka) --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index c341658e5a..9c214c169b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -148,7 +148,7 @@ objdump = ['dep:wasmparser'] strip = ['wasm-encoder', 'dep:wasmparser', 'regex'] compose = ['wasm-compose', 'dep:wasmparser'] demangle = ['rustc-demangle', 'cpp_demangle', 'dep:wasmparser', 'wasm-encoder'] -component = ['wit-component', 'wit-parser', 'wast', 'wasm-encoder', 'dep:wasmparser'] +component = ['wit-component', 'wit-parser', 'wast', 'wasm-encoder', 'dep:wasmparser', 'serde_json'] metadata = ['dep:wasmparser', 'wasm-metadata', 'serde_json'] wit-smith = ['dep:wit-smith', 'arbitrary'] addr2line = ['dep:addr2line', 'dep:gimli', 'dep:wasmparser'] From db477003cd5b5ead4867cf4a294157427db93fe7 Mon Sep 17 00:00:00 2001 From: "Jiaxiao Zhou (Mossaka)" Date: Wed, 13 Sep 2023 21:03:41 -0700 Subject: [PATCH 33/40] modified the tests to generate json for each valid WIT package. This uses the "BLESS=1" env var to tell `cargo test` to force to write to files. Signed-off-by: Jiaxiao Zhou (Mossaka) --- crates/wit-parser/tests/all.rs | 24 +- crates/wit-parser/tests/ui/comments.wit.json | 58 + .../tests/ui/complex-include.wit.json | 213 +++ .../tests/ui/cross-package-resource.wit.json | 88 + crates/wit-parser/tests/ui/diamond1.wit.json | 73 + .../tests/ui/disambiguate-diamond.wit.json | 137 ++ .../wit-parser/tests/ui/embedded.wit.md.json | 55 + crates/wit-parser/tests/ui/empty.wit.json | 15 + .../tests/ui/foreign-deps-union.wit.json | 497 ++++++ .../wit-parser/tests/ui/foreign-deps.wit.json | 455 +++++ crates/wit-parser/tests/ui/functions.wit.json | 211 +++ .../tests/ui/ignore-files-deps.wit.json | 51 + .../wit-parser/tests/ui/include-reps.wit.json | 75 + .../tests/ui/kebab-name-include-with.wit.json | 94 ++ .../wit-parser/tests/ui/many-names.wit.json | 52 + .../wit-parser/tests/ui/multi-file.wit.json | 388 +++++ .../ui/name-both-resource-and-type.wit.json | 116 ++ .../tests/ui/package-syntax1.wit.json | 15 + .../tests/ui/package-syntax3.wit.json | 15 + .../tests/ui/package-syntax4.wit.json | 15 + .../tests/ui/resources-empty.wit.json | 93 ++ ...resources-multiple-returns-borrow.wit.json | 92 ++ .../resources-multiple-returns-own.wit.json | 104 ++ .../tests/ui/resources-multiple.wit.json | 341 ++++ .../tests/ui/resources-return-borrow.wit.json | 87 + .../tests/ui/resources-return-own.wit.json | 99 ++ crates/wit-parser/tests/ui/resources.wit.json | 433 +++++ .../wit-parser/tests/ui/resources1.wit.json | 123 ++ .../wit-parser/tests/ui/shared-types.wit.json | 107 ++ .../tests/ui/stress-export-elaborate.wit.json | 1472 +++++++++++++++++ .../tests/ui/type-then-eof.wit.json | 41 + crates/wit-parser/tests/ui/types.wit.json | 1006 +++++++++++ .../wit-parser/tests/ui/union-fuzz-1.wit.json | 47 + crates/wit-parser/tests/ui/use-chain.wit.json | 68 + crates/wit-parser/tests/ui/use.wit.json | 226 +++ crates/wit-parser/tests/ui/versions.wit.json | 121 ++ crates/wit-parser/tests/ui/wasi.wit.json | 548 ++++++ .../tests/ui/world-diamond.wit.json | 151 ++ .../tests/ui/world-iface-no-collide.wit.json | 84 + .../tests/ui/world-implicit-import1.wit.json | 96 ++ .../tests/ui/world-implicit-import2.wit.json | 88 + .../tests/ui/world-implicit-import3.wit.json | 89 + .../tests/ui/world-same-fields4.wit.json | 97 ++ .../tests/ui/world-top-level-funcs.wit.json | 113 ++ .../ui/world-top-level-resources.wit.json | 303 ++++ .../tests/ui/worlds-union-dedup.wit.json | 130 ++ .../tests/ui/worlds-with-types.wit.json | 253 +++ 47 files changed, 9051 insertions(+), 8 deletions(-) create mode 100644 crates/wit-parser/tests/ui/comments.wit.json create mode 100644 crates/wit-parser/tests/ui/complex-include.wit.json create mode 100644 crates/wit-parser/tests/ui/cross-package-resource.wit.json create mode 100644 crates/wit-parser/tests/ui/diamond1.wit.json create mode 100644 crates/wit-parser/tests/ui/disambiguate-diamond.wit.json create mode 100644 crates/wit-parser/tests/ui/embedded.wit.md.json create mode 100644 crates/wit-parser/tests/ui/empty.wit.json create mode 100644 crates/wit-parser/tests/ui/foreign-deps-union.wit.json create mode 100644 crates/wit-parser/tests/ui/foreign-deps.wit.json create mode 100644 crates/wit-parser/tests/ui/functions.wit.json create mode 100644 crates/wit-parser/tests/ui/ignore-files-deps.wit.json create mode 100644 crates/wit-parser/tests/ui/include-reps.wit.json create mode 100644 crates/wit-parser/tests/ui/kebab-name-include-with.wit.json create mode 100644 crates/wit-parser/tests/ui/many-names.wit.json create mode 100644 crates/wit-parser/tests/ui/multi-file.wit.json create mode 100644 crates/wit-parser/tests/ui/name-both-resource-and-type.wit.json create mode 100644 crates/wit-parser/tests/ui/package-syntax1.wit.json create mode 100644 crates/wit-parser/tests/ui/package-syntax3.wit.json create mode 100644 crates/wit-parser/tests/ui/package-syntax4.wit.json create mode 100644 crates/wit-parser/tests/ui/resources-empty.wit.json create mode 100644 crates/wit-parser/tests/ui/resources-multiple-returns-borrow.wit.json create mode 100644 crates/wit-parser/tests/ui/resources-multiple-returns-own.wit.json create mode 100644 crates/wit-parser/tests/ui/resources-multiple.wit.json create mode 100644 crates/wit-parser/tests/ui/resources-return-borrow.wit.json create mode 100644 crates/wit-parser/tests/ui/resources-return-own.wit.json create mode 100644 crates/wit-parser/tests/ui/resources.wit.json create mode 100644 crates/wit-parser/tests/ui/resources1.wit.json create mode 100644 crates/wit-parser/tests/ui/shared-types.wit.json create mode 100644 crates/wit-parser/tests/ui/stress-export-elaborate.wit.json create mode 100644 crates/wit-parser/tests/ui/type-then-eof.wit.json create mode 100644 crates/wit-parser/tests/ui/types.wit.json create mode 100644 crates/wit-parser/tests/ui/union-fuzz-1.wit.json create mode 100644 crates/wit-parser/tests/ui/use-chain.wit.json create mode 100644 crates/wit-parser/tests/ui/use.wit.json create mode 100644 crates/wit-parser/tests/ui/versions.wit.json create mode 100644 crates/wit-parser/tests/ui/wasi.wit.json create mode 100644 crates/wit-parser/tests/ui/world-diamond.wit.json create mode 100644 crates/wit-parser/tests/ui/world-iface-no-collide.wit.json create mode 100644 crates/wit-parser/tests/ui/world-implicit-import1.wit.json create mode 100644 crates/wit-parser/tests/ui/world-implicit-import2.wit.json create mode 100644 crates/wit-parser/tests/ui/world-implicit-import3.wit.json create mode 100644 crates/wit-parser/tests/ui/world-same-fields4.wit.json create mode 100644 crates/wit-parser/tests/ui/world-top-level-funcs.wit.json create mode 100644 crates/wit-parser/tests/ui/world-top-level-resources.wit.json create mode 100644 crates/wit-parser/tests/ui/worlds-union-dedup.wit.json create mode 100644 crates/wit-parser/tests/ui/worlds-with-types.wit.json diff --git a/crates/wit-parser/tests/all.rs b/crates/wit-parser/tests/all.rs index 815834e89b..a9395da8ec 100644 --- a/crates/wit-parser/tests/all.rs +++ b/crates/wit-parser/tests/all.rs @@ -124,21 +124,29 @@ impl Runner<'_> { } } else { result?; - serde_json::to_string(&resolve)?; + // format json string to human readable + let json_result = serde_json::to_string_pretty(&resolve)?; + // "foo.wit" => "foo.wit.json" + self.read_or_write_to_file(test, &json_result, "json")?; return Ok(()); }; // "foo.wit" => "foo.wit.result" // "foo.wit.md" => "foo.wit.md.result" + self.read_or_write_to_file(test, &result, "result")?; + return Ok(()); + } + + fn read_or_write_to_file(&mut self, test: &Path, result: &str, extension: &str) -> Result<(), anyhow::Error> { let result_file = if test.extension() == Some(OsStr::new("md")) && test .file_stem() .and_then(|path| Path::new(path).extension()) == Some(OsStr::new("wit")) { - test.with_extension("md.result") + test.with_extension(format!("md.{extension}")) } else { - test.with_extension("wit.result") + test.with_extension(format!("wit.{extension}")) }; if env::var_os("BLESS").is_some() { fs::write(&result_file, result)?; @@ -156,14 +164,14 @@ impl Runner<'_> { } } self.bump_ntests(); - return Ok(()); - - fn normalize(s: &str) -> String { - s.replace('\\', "/").replace("\r\n", "\n") - } + Ok(()) } fn bump_ntests(&self) { self.ntests.fetch_add(1, SeqCst); } } + +fn normalize(s: &str) -> String { + s.replace('\\', "/").replace("\r\n", "\n") +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/comments.wit.json b/crates/wit-parser/tests/ui/comments.wit.json new file mode 100644 index 0000000000..e41ad846f4 --- /dev/null +++ b/crates/wit-parser/tests/ui/comments.wit.json @@ -0,0 +1,58 @@ +{ + "worlds": [], + "interfaces": [ + { + "name": "foo", + "docs": { + "contents": null + }, + "types": { + "x": 0, + "bar": 1 + }, + "functions": {}, + "package": 0 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "x", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "stream": { + "element": 0, + "end": null + } + }, + "name": "bar", + "owner": { + "interface": 0 + } + } + ], + "packages": [ + { + "name": "foo:comments", + "docs": { + "contents": null + }, + "interfaces": { + "foo": 0 + }, + "worlds": {} + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/complex-include.wit.json b/crates/wit-parser/tests/ui/complex-include.wit.json new file mode 100644 index 0000000000..54e6d5d71d --- /dev/null +++ b/crates/wit-parser/tests/ui/complex-include.wit.json @@ -0,0 +1,213 @@ +{ + "worlds": [ + { + "name": "bar-a", + "docs": { + "contents": null + }, + "imports": { + "interface-0": { + "interface": 0 + }, + "interface-1": { + "interface": 1 + } + }, + "exports": {}, + "package": 0 + }, + { + "name": "baz-a", + "docs": { + "contents": null + }, + "imports": { + "interface-2": { + "interface": 2 + }, + "interface-3": { + "interface": 3 + } + }, + "exports": {}, + "package": 1 + }, + { + "name": "a", + "docs": { + "contents": null + }, + "imports": { + "interface-4": { + "interface": 4 + }, + "interface-5": { + "interface": 5 + } + }, + "exports": {}, + "package": 2 + }, + { + "name": "b", + "docs": { + "contents": null + }, + "imports": { + "interface-0": { + "interface": 0 + }, + "interface-1": { + "interface": 1 + } + }, + "exports": {}, + "package": 2 + }, + { + "name": "c", + "docs": { + "contents": null + }, + "imports": { + "interface-0": { + "interface": 0 + }, + "interface-1": { + "interface": 1 + } + }, + "exports": {}, + "package": 2 + }, + { + "name": "union-world", + "docs": { + "contents": null + }, + "imports": { + "interface-4": { + "interface": 4 + }, + "interface-5": { + "interface": 5 + }, + "interface-0": { + "interface": 0 + }, + "interface-1": { + "interface": 1 + }, + "interface-2": { + "interface": 2 + }, + "interface-3": { + "interface": 3 + } + }, + "exports": {}, + "package": 2 + } + ], + "interfaces": [ + { + "name": "a", + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 0 + }, + { + "name": "b", + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 0 + }, + { + "name": "a", + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 1 + }, + { + "name": "b", + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 1 + }, + { + "name": "ai", + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 2 + }, + { + "name": "bi", + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 2 + } + ], + "types": [], + "packages": [ + { + "name": "foo:bar", + "docs": { + "contents": null + }, + "interfaces": { + "a": 0, + "b": 1 + }, + "worlds": { + "bar-a": 0 + } + }, + { + "name": "foo:baz", + "docs": { + "contents": null + }, + "interfaces": { + "a": 2, + "b": 3 + }, + "worlds": { + "baz-a": 1 + } + }, + { + "name": "foo:root", + "docs": { + "contents": null + }, + "interfaces": { + "ai": 4, + "bi": 5 + }, + "worlds": { + "a": 2, + "b": 3, + "c": 4, + "union-world": 5 + } + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/cross-package-resource.wit.json b/crates/wit-parser/tests/ui/cross-package-resource.wit.json new file mode 100644 index 0000000000..ee8f63584e --- /dev/null +++ b/crates/wit-parser/tests/ui/cross-package-resource.wit.json @@ -0,0 +1,88 @@ +{ + "worlds": [], + "interfaces": [ + { + "name": "foo", + "docs": { + "contents": null + }, + "types": { + "r": 0 + }, + "functions": {}, + "package": 0 + }, + { + "name": "foo", + "docs": { + "contents": null + }, + "types": { + "r": 1, + "t": 2 + }, + "functions": {}, + "package": 1 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": "resource", + "name": "r", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 0 + }, + "name": "r", + "owner": { + "interface": 1 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "own": 1 + } + }, + "name": "t", + "owner": { + "interface": 1 + } + } + ], + "packages": [ + { + "name": "some:dep", + "docs": { + "contents": null + }, + "interfaces": { + "foo": 0 + }, + "worlds": {} + }, + { + "name": "foo:bar", + "docs": { + "contents": null + }, + "interfaces": { + "foo": 1 + }, + "worlds": {} + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/diamond1.wit.json b/crates/wit-parser/tests/ui/diamond1.wit.json new file mode 100644 index 0000000000..64d18c76f8 --- /dev/null +++ b/crates/wit-parser/tests/ui/diamond1.wit.json @@ -0,0 +1,73 @@ +{ + "worlds": [ + { + "name": "foo", + "docs": { + "contents": null + }, + "imports": { + "interface-0": { + "interface": 0 + }, + "interface-1": { + "interface": 1 + } + }, + "exports": {}, + "package": 2 + } + ], + "interfaces": [ + { + "name": "types", + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 0 + }, + { + "name": "types", + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 1 + } + ], + "types": [], + "packages": [ + { + "name": "foo:dep1", + "docs": { + "contents": null + }, + "interfaces": { + "types": 0 + }, + "worlds": {} + }, + { + "name": "foo:dep2", + "docs": { + "contents": null + }, + "interfaces": { + "types": 1 + }, + "worlds": {} + }, + { + "name": "foo:foo", + "docs": { + "contents": null + }, + "interfaces": {}, + "worlds": { + "foo": 0 + } + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/disambiguate-diamond.wit.json b/crates/wit-parser/tests/ui/disambiguate-diamond.wit.json new file mode 100644 index 0000000000..237081a0d6 --- /dev/null +++ b/crates/wit-parser/tests/ui/disambiguate-diamond.wit.json @@ -0,0 +1,137 @@ +{ + "worlds": [ + { + "name": "foo", + "docs": { + "contents": null + }, + "imports": { + "interface-0": { + "interface": 0 + }, + "foo": { + "interface": 2 + }, + "interface-1": { + "interface": 1 + }, + "bar": { + "interface": 3 + } + }, + "exports": {}, + "package": 0 + } + ], + "interfaces": [ + { + "name": "shared1", + "docs": { + "contents": null + }, + "types": { + "the-type": 0 + }, + "functions": {}, + "package": 0 + }, + { + "name": "shared2", + "docs": { + "contents": null + }, + "types": { + "the-type": 1 + }, + "functions": {}, + "package": 0 + }, + { + "name": null, + "docs": { + "contents": null + }, + "types": { + "the-type": 2 + }, + "functions": {}, + "package": 0 + }, + { + "name": null, + "docs": { + "contents": null + }, + "types": { + "the-type": 3 + }, + "functions": {}, + "package": 0 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "the-type", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "the-type", + "owner": { + "interface": 1 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 0 + }, + "name": "the-type", + "owner": { + "interface": 2 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 1 + }, + "name": "the-type", + "owner": { + "interface": 3 + } + } + ], + "packages": [ + { + "name": "foo:diamond", + "docs": { + "contents": null + }, + "interfaces": { + "shared1": 0, + "shared2": 1 + }, + "worlds": { + "foo": 0 + } + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/embedded.wit.md.json b/crates/wit-parser/tests/ui/embedded.wit.md.json new file mode 100644 index 0000000000..76896ee1dd --- /dev/null +++ b/crates/wit-parser/tests/ui/embedded.wit.md.json @@ -0,0 +1,55 @@ +{ + "worlds": [], + "interfaces": [ + { + "name": "foo", + "docs": { + "contents": null + }, + "types": {}, + "functions": { + "x": { + "docs": { + "contents": null + }, + "name": "x", + "kind": "freestanding", + "params": [], + "results": [] + }, + "y": { + "docs": { + "contents": null + }, + "name": "y", + "kind": "freestanding", + "params": [], + "results": [] + }, + "z": { + "docs": { + "contents": null + }, + "name": "z", + "kind": "freestanding", + "params": [], + "results": [] + } + }, + "package": 0 + } + ], + "types": [], + "packages": [ + { + "name": "foo:foo", + "docs": { + "contents": null + }, + "interfaces": { + "foo": 0 + }, + "worlds": {} + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/empty.wit.json b/crates/wit-parser/tests/ui/empty.wit.json new file mode 100644 index 0000000000..703caa711d --- /dev/null +++ b/crates/wit-parser/tests/ui/empty.wit.json @@ -0,0 +1,15 @@ +{ + "worlds": [], + "interfaces": [], + "types": [], + "packages": [ + { + "name": "foo:empty", + "docs": { + "contents": null + }, + "interfaces": {}, + "worlds": {} + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/foreign-deps-union.wit.json b/crates/wit-parser/tests/ui/foreign-deps-union.wit.json new file mode 100644 index 0000000000..7525e05b45 --- /dev/null +++ b/crates/wit-parser/tests/ui/foreign-deps-union.wit.json @@ -0,0 +1,497 @@ +{ + "worlds": [ + { + "name": "wasi", + "docs": { + "contents": null + }, + "imports": { + "interface-8": { + "interface": 8 + }, + "interface-7": { + "interface": 7 + } + }, + "exports": {}, + "package": 5 + }, + { + "name": "my-world", + "docs": { + "contents": null + }, + "imports": { + "interface-8": { + "interface": 8 + }, + "interface-7": { + "interface": 7 + } + }, + "exports": { + "interface-1": { + "interface": 1 + } + }, + "package": 6 + }, + { + "name": "my-world2", + "docs": { + "contents": null + }, + "imports": { + "interface-8": { + "interface": 8 + }, + "interface-7": { + "interface": 7 + } + }, + "exports": { + "interface-9": { + "interface": 9 + }, + "interface-1": { + "interface": 1 + } + }, + "package": 6 + }, + { + "name": "bars-world", + "docs": { + "contents": null + }, + "imports": { + "interface-4": { + "interface": 4 + }, + "interface-0": { + "interface": 0 + } + }, + "exports": {}, + "package": 6 + }, + { + "name": "unionw-world", + "docs": { + "contents": null + }, + "imports": { + "interface-8": { + "interface": 8 + }, + "interface-7": { + "interface": 7 + } + }, + "exports": { + "interface-1": { + "interface": 1 + }, + "interface-9": { + "interface": 9 + } + }, + "package": 6 + } + ], + "interfaces": [ + { + "name": "other-interface", + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 0 + }, + { + "name": "saas", + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 1 + }, + { + "name": "i", + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 2 + }, + { + "name": "the-default", + "docs": { + "contents": null + }, + "types": { + "some-type": 0 + }, + "functions": {}, + "package": 3 + }, + { + "name": "the-default", + "docs": { + "contents": null + }, + "types": { + "from-default": 1 + }, + "functions": {}, + "package": 4 + }, + { + "name": "some-interface", + "docs": { + "contents": null + }, + "types": { + "another-type": 2 + }, + "functions": {}, + "package": 4 + }, + { + "name": "another-interface", + "docs": { + "contents": null + }, + "types": { + "yet-another-type": 3 + }, + "functions": {}, + "package": 4 + }, + { + "name": "clocks", + "docs": { + "contents": null + }, + "types": { + "timestamp": 4 + }, + "functions": {}, + "package": 5 + }, + { + "name": "filesystem", + "docs": { + "contents": null + }, + "types": { + "stat": 5 + }, + "functions": {}, + "package": 5 + }, + { + "name": "foo", + "docs": { + "contents": null + }, + "types": { + "timestamp": 6, + "stat": 7 + }, + "functions": {}, + "package": 6 + }, + { + "name": "bar", + "docs": { + "contents": null + }, + "types": { + "from-default": 8, + "another-type": 9, + "yet-another-type": 10 + }, + "functions": {}, + "package": 6 + }, + { + "name": "use1", + "docs": { + "contents": null + }, + "types": { + "some-type": 11 + }, + "functions": {}, + "package": 6 + }, + { + "name": "use2", + "docs": { + "contents": null + }, + "types": { + "some-type": 12 + }, + "functions": {}, + "package": 6 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "some-type", + "owner": { + "interface": 3 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "string" + }, + "name": "from-default", + "owner": { + "interface": 4 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "another-type", + "owner": { + "interface": 5 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "u8" + }, + "name": "yet-another-type", + "owner": { + "interface": 6 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "u64" + }, + "name": "timestamp", + "owner": { + "interface": 7 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "record": { + "fields": [ + { + "docs": { + "contents": null + }, + "name": "ino", + "type": "u64" + } + ] + } + }, + "name": "stat", + "owner": { + "interface": 8 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 4 + }, + "name": "timestamp", + "owner": { + "interface": 9 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 5 + }, + "name": "stat", + "owner": { + "interface": 9 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 1 + }, + "name": "from-default", + "owner": { + "interface": 10 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 2 + }, + "name": "another-type", + "owner": { + "interface": 10 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 3 + }, + "name": "yet-another-type", + "owner": { + "interface": 10 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 0 + }, + "name": "some-type", + "owner": { + "interface": 11 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 0 + }, + "name": "some-type", + "owner": { + "interface": 12 + } + } + ], + "packages": [ + { + "name": "foo:another-pkg", + "docs": { + "contents": null + }, + "interfaces": { + "other-interface": 0 + }, + "worlds": {} + }, + { + "name": "foo:corp", + "docs": { + "contents": null + }, + "interfaces": { + "saas": 1 + }, + "worlds": {} + }, + { + "name": "foo:different-pkg", + "docs": { + "contents": null + }, + "interfaces": { + "i": 2 + }, + "worlds": {} + }, + { + "name": "foo:foreign-pkg", + "docs": { + "contents": null + }, + "interfaces": { + "the-default": 3 + }, + "worlds": {} + }, + { + "name": "foo:some-pkg", + "docs": { + "contents": null + }, + "interfaces": { + "the-default": 4, + "some-interface": 5, + "another-interface": 6 + }, + "worlds": {} + }, + { + "name": "foo:wasi", + "docs": { + "contents": null + }, + "interfaces": { + "clocks": 7, + "filesystem": 8 + }, + "worlds": { + "wasi": 0 + } + }, + { + "name": "foo:root", + "docs": { + "contents": null + }, + "interfaces": { + "foo": 9, + "bar": 10, + "use1": 11, + "use2": 12 + }, + "worlds": { + "my-world": 1, + "my-world2": 2, + "bars-world": 3, + "unionw-world": 4 + } + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/foreign-deps.wit.json b/crates/wit-parser/tests/ui/foreign-deps.wit.json new file mode 100644 index 0000000000..24298fde6b --- /dev/null +++ b/crates/wit-parser/tests/ui/foreign-deps.wit.json @@ -0,0 +1,455 @@ +{ + "worlds": [ + { + "name": "my-world", + "docs": { + "contents": null + }, + "imports": { + "interface-8": { + "interface": 8 + }, + "interface-7": { + "interface": 7 + } + }, + "exports": { + "interface-1": { + "interface": 1 + } + }, + "package": 6 + }, + { + "name": "my-world2", + "docs": { + "contents": null + }, + "imports": { + "interface-8": { + "interface": 8 + }, + "interface-7": { + "interface": 7 + } + }, + "exports": { + "interface-9": { + "interface": 9 + }, + "interface-1": { + "interface": 1 + } + }, + "package": 6 + }, + { + "name": "bars-world", + "docs": { + "contents": null + }, + "imports": { + "interface-4": { + "interface": 4 + }, + "interface-0": { + "interface": 0 + } + }, + "exports": {}, + "package": 6 + } + ], + "interfaces": [ + { + "name": "other-interface", + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 0 + }, + { + "name": "saas", + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 1 + }, + { + "name": "i", + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 2 + }, + { + "name": "the-default", + "docs": { + "contents": null + }, + "types": { + "some-type": 0 + }, + "functions": {}, + "package": 3 + }, + { + "name": "the-default", + "docs": { + "contents": null + }, + "types": { + "from-default": 1 + }, + "functions": {}, + "package": 4 + }, + { + "name": "some-interface", + "docs": { + "contents": null + }, + "types": { + "another-type": 2 + }, + "functions": {}, + "package": 4 + }, + { + "name": "another-interface", + "docs": { + "contents": null + }, + "types": { + "yet-another-type": 3 + }, + "functions": {}, + "package": 4 + }, + { + "name": "clocks", + "docs": { + "contents": null + }, + "types": { + "timestamp": 4 + }, + "functions": {}, + "package": 5 + }, + { + "name": "filesystem", + "docs": { + "contents": null + }, + "types": { + "stat": 5 + }, + "functions": {}, + "package": 5 + }, + { + "name": "foo", + "docs": { + "contents": null + }, + "types": { + "timestamp": 6, + "stat": 7 + }, + "functions": {}, + "package": 6 + }, + { + "name": "bar", + "docs": { + "contents": null + }, + "types": { + "from-default": 8, + "another-type": 9, + "yet-another-type": 10 + }, + "functions": {}, + "package": 6 + }, + { + "name": "use1", + "docs": { + "contents": null + }, + "types": { + "some-type": 11 + }, + "functions": {}, + "package": 6 + }, + { + "name": "use2", + "docs": { + "contents": null + }, + "types": { + "some-type": 12 + }, + "functions": {}, + "package": 6 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "some-type", + "owner": { + "interface": 3 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "string" + }, + "name": "from-default", + "owner": { + "interface": 4 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "another-type", + "owner": { + "interface": 5 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "u8" + }, + "name": "yet-another-type", + "owner": { + "interface": 6 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "u64" + }, + "name": "timestamp", + "owner": { + "interface": 7 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "record": { + "fields": [ + { + "docs": { + "contents": null + }, + "name": "ino", + "type": "u64" + } + ] + } + }, + "name": "stat", + "owner": { + "interface": 8 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 4 + }, + "name": "timestamp", + "owner": { + "interface": 9 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 5 + }, + "name": "stat", + "owner": { + "interface": 9 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 1 + }, + "name": "from-default", + "owner": { + "interface": 10 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 2 + }, + "name": "another-type", + "owner": { + "interface": 10 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 3 + }, + "name": "yet-another-type", + "owner": { + "interface": 10 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 0 + }, + "name": "some-type", + "owner": { + "interface": 11 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 0 + }, + "name": "some-type", + "owner": { + "interface": 12 + } + } + ], + "packages": [ + { + "name": "foo:another-pkg", + "docs": { + "contents": null + }, + "interfaces": { + "other-interface": 0 + }, + "worlds": {} + }, + { + "name": "foo:corp", + "docs": { + "contents": null + }, + "interfaces": { + "saas": 1 + }, + "worlds": {} + }, + { + "name": "foo:different-pkg", + "docs": { + "contents": null + }, + "interfaces": { + "i": 2 + }, + "worlds": {} + }, + { + "name": "foo:foreign-pkg", + "docs": { + "contents": null + }, + "interfaces": { + "the-default": 3 + }, + "worlds": {} + }, + { + "name": "foo:some-pkg", + "docs": { + "contents": null + }, + "interfaces": { + "the-default": 4, + "some-interface": 5, + "another-interface": 6 + }, + "worlds": {} + }, + { + "name": "foo:wasi", + "docs": { + "contents": null + }, + "interfaces": { + "clocks": 7, + "filesystem": 8 + }, + "worlds": {} + }, + { + "name": "foo:root", + "docs": { + "contents": null + }, + "interfaces": { + "foo": 9, + "bar": 10, + "use1": 11, + "use2": 12 + }, + "worlds": { + "my-world": 0, + "my-world2": 1, + "bars-world": 2 + } + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/functions.wit.json b/crates/wit-parser/tests/ui/functions.wit.json new file mode 100644 index 0000000000..2ae4f157c9 --- /dev/null +++ b/crates/wit-parser/tests/ui/functions.wit.json @@ -0,0 +1,211 @@ +{ + "worlds": [], + "interfaces": [ + { + "name": "functions", + "docs": { + "contents": null + }, + "types": {}, + "functions": { + "f1": { + "docs": { + "contents": null + }, + "name": "f1", + "kind": "freestanding", + "params": [], + "results": [] + }, + "f2": { + "docs": { + "contents": null + }, + "name": "f2", + "kind": "freestanding", + "params": [ + { + "name": "a", + "type": "u32" + } + ], + "results": [] + }, + "f3": { + "docs": { + "contents": null + }, + "name": "f3", + "kind": "freestanding", + "params": [ + { + "name": "a", + "type": "u32" + } + ], + "results": [] + }, + "f4": { + "docs": { + "contents": null + }, + "name": "f4", + "kind": "freestanding", + "params": [], + "results": [ + { + "type": "u32" + } + ] + }, + "f6": { + "docs": { + "contents": null + }, + "name": "f6", + "kind": "freestanding", + "params": [], + "results": [ + { + "type": 0 + } + ] + }, + "f7": { + "docs": { + "contents": null + }, + "name": "f7", + "kind": "freestanding", + "params": [ + { + "name": "a", + "type": "float32" + }, + { + "name": "b", + "type": "float32" + } + ], + "results": [ + { + "type": 0 + } + ] + }, + "f8": { + "docs": { + "contents": null + }, + "name": "f8", + "kind": "freestanding", + "params": [ + { + "name": "a", + "type": 1 + } + ], + "results": [ + { + "type": 2 + } + ] + }, + "f9": { + "docs": { + "contents": null + }, + "name": "f9", + "kind": "freestanding", + "params": [], + "results": [ + { + "name": "u", + "type": "u32" + }, + { + "name": "f", + "type": "float32" + } + ] + }, + "f10": { + "docs": { + "contents": null + }, + "name": "f10", + "kind": "freestanding", + "params": [], + "results": [ + { + "name": "u", + "type": "u32" + } + ] + }, + "f11": { + "docs": { + "contents": null + }, + "name": "f11", + "kind": "freestanding", + "params": [], + "results": [] + } + }, + "package": 0 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": { + "tuple": { + "types": [ + "u32", + "u32" + ] + } + }, + "name": null, + "owner": "none" + }, + { + "docs": { + "contents": null + }, + "kind": { + "option": "u32" + }, + "name": null, + "owner": "none" + }, + { + "docs": { + "contents": null + }, + "kind": { + "result": { + "ok": "u32", + "err": "float32" + } + }, + "name": null, + "owner": "none" + } + ], + "packages": [ + { + "name": "foo:functions", + "docs": { + "contents": null + }, + "interfaces": { + "functions": 0 + }, + "worlds": {} + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/ignore-files-deps.wit.json b/crates/wit-parser/tests/ui/ignore-files-deps.wit.json new file mode 100644 index 0000000000..ede65764bc --- /dev/null +++ b/crates/wit-parser/tests/ui/ignore-files-deps.wit.json @@ -0,0 +1,51 @@ +{ + "worlds": [ + { + "name": "foo", + "docs": { + "contents": null + }, + "imports": { + "interface-0": { + "interface": 0 + } + }, + "exports": {}, + "package": 1 + } + ], + "interfaces": [ + { + "name": "types", + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 0 + } + ], + "types": [], + "packages": [ + { + "name": "foo:bar", + "docs": { + "contents": null + }, + "interfaces": { + "types": 0 + }, + "worlds": {} + }, + { + "name": "foo:foo", + "docs": { + "contents": null + }, + "interfaces": {}, + "worlds": { + "foo": 0 + } + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/include-reps.wit.json b/crates/wit-parser/tests/ui/include-reps.wit.json new file mode 100644 index 0000000000..96dff73da6 --- /dev/null +++ b/crates/wit-parser/tests/ui/include-reps.wit.json @@ -0,0 +1,75 @@ +{ + "worlds": [ + { + "name": "bar", + "docs": { + "contents": null + }, + "imports": { + "interface-0": { + "interface": 0 + } + }, + "exports": { + "interface-1": { + "interface": 1 + } + }, + "package": 0 + }, + { + "name": "foo", + "docs": { + "contents": null + }, + "imports": { + "interface-0": { + "interface": 0 + } + }, + "exports": { + "interface-1": { + "interface": 1 + } + }, + "package": 0 + } + ], + "interfaces": [ + { + "name": "a", + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 0 + }, + { + "name": "b", + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 0 + } + ], + "types": [], + "packages": [ + { + "name": "foo:foo", + "docs": { + "contents": null + }, + "interfaces": { + "a": 0, + "b": 1 + }, + "worlds": { + "bar": 0, + "foo": 1 + } + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/kebab-name-include-with.wit.json b/crates/wit-parser/tests/ui/kebab-name-include-with.wit.json new file mode 100644 index 0000000000..f08e01461f --- /dev/null +++ b/crates/wit-parser/tests/ui/kebab-name-include-with.wit.json @@ -0,0 +1,94 @@ +{ + "worlds": [ + { + "name": "foo", + "docs": { + "contents": null + }, + "imports": { + "a": { + "function": { + "docs": { + "contents": null + }, + "name": "a", + "kind": "freestanding", + "params": [], + "results": [] + } + } + }, + "exports": {}, + "package": 0 + }, + { + "name": "bar", + "docs": { + "contents": null + }, + "imports": { + "a": { + "function": { + "docs": { + "contents": null + }, + "name": "a", + "kind": "freestanding", + "params": [], + "results": [] + } + } + }, + "exports": {}, + "package": 0 + }, + { + "name": "baz", + "docs": { + "contents": null + }, + "imports": { + "b": { + "function": { + "docs": { + "contents": null + }, + "name": "a", + "kind": "freestanding", + "params": [], + "results": [] + } + }, + "a": { + "function": { + "docs": { + "contents": null + }, + "name": "a", + "kind": "freestanding", + "params": [], + "results": [] + } + } + }, + "exports": {}, + "package": 0 + } + ], + "interfaces": [], + "types": [], + "packages": [ + { + "name": "foo:foo", + "docs": { + "contents": null + }, + "interfaces": {}, + "worlds": { + "foo": 0, + "bar": 1, + "baz": 2 + } + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/many-names.wit.json b/crates/wit-parser/tests/ui/many-names.wit.json new file mode 100644 index 0000000000..efd8747777 --- /dev/null +++ b/crates/wit-parser/tests/ui/many-names.wit.json @@ -0,0 +1,52 @@ +{ + "worlds": [ + { + "name": "name", + "docs": { + "contents": null + }, + "imports": { + "name": { + "interface": 1 + } + }, + "exports": {}, + "package": 0 + } + ], + "interfaces": [ + { + "name": "x", + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 0 + }, + { + "name": null, + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 0 + } + ], + "types": [], + "packages": [ + { + "name": "foo:name", + "docs": { + "contents": null + }, + "interfaces": { + "x": 0 + }, + "worlds": { + "name": 0 + } + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/multi-file.wit.json b/crates/wit-parser/tests/ui/multi-file.wit.json new file mode 100644 index 0000000000..1a66b5f6f8 --- /dev/null +++ b/crates/wit-parser/tests/ui/multi-file.wit.json @@ -0,0 +1,388 @@ +{ + "worlds": [ + { + "name": "more-depends-on-later-things", + "docs": { + "contents": null + }, + "imports": { + "interface-3": { + "interface": 3 + } + }, + "exports": { + "interface-3": { + "interface": 3 + } + }, + "package": 0 + }, + { + "name": "the-world", + "docs": { + "contents": null + }, + "imports": { + "interface-1": { + "interface": 1 + }, + "x": { + "type": 15 + }, + "foo": { + "function": { + "docs": { + "contents": null + }, + "name": "foo", + "kind": "freestanding", + "params": [], + "results": [ + { + "type": 15 + } + ] + } + } + }, + "exports": {}, + "package": 0 + } + ], + "interfaces": [ + { + "name": "irrelevant-name", + "docs": { + "contents": null + }, + "types": { + "a-name": 0 + }, + "functions": {}, + "package": 0 + }, + { + "name": "depend-on-me", + "docs": { + "contents": null + }, + "types": { + "x": 1 + }, + "functions": {}, + "package": 0 + }, + { + "name": "depends-on-later-item", + "docs": { + "contents": null + }, + "types": { + "x": 2 + }, + "functions": {}, + "package": 0 + }, + { + "name": "later-interface", + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 0 + }, + { + "name": "cycle1", + "docs": { + "contents": null + }, + "types": { + "t": 3 + }, + "functions": {}, + "package": 0 + }, + { + "name": "cycle2", + "docs": { + "contents": null + }, + "types": { + "t": 4 + }, + "functions": {}, + "package": 0 + }, + { + "name": "cycle3", + "docs": { + "contents": null + }, + "types": { + "t": 5 + }, + "functions": {}, + "package": 0 + }, + { + "name": "foo", + "docs": { + "contents": null + }, + "types": { + "x": 6 + }, + "functions": {}, + "package": 0 + }, + { + "name": "something-else", + "docs": { + "contents": null + }, + "types": { + "y": 7 + }, + "functions": {}, + "package": 0 + }, + { + "name": "bar", + "docs": { + "contents": null + }, + "types": { + "x": 8, + "x2": 9, + "x3": 10, + "x4": 11, + "y": 12, + "y2": 13, + "a-name": 14 + }, + "functions": {}, + "package": 0 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": { + "record": { + "fields": [] + } + }, + "name": "a-name", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "x", + "owner": { + "interface": 1 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 1 + }, + "name": "x", + "owner": { + "interface": 2 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "t", + "owner": { + "interface": 4 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 3 + }, + "name": "t", + "owner": { + "interface": 5 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 4 + }, + "name": "t", + "owner": { + "interface": 6 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "x", + "owner": { + "interface": 7 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "u64" + }, + "name": "y", + "owner": { + "interface": 8 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 6 + }, + "name": "x", + "owner": { + "interface": 9 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 6 + }, + "name": "x2", + "owner": { + "interface": 9 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 6 + }, + "name": "x3", + "owner": { + "interface": 9 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 1 + }, + "name": "x4", + "owner": { + "interface": 9 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 7 + }, + "name": "y", + "owner": { + "interface": 9 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 7 + }, + "name": "y2", + "owner": { + "interface": 9 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 0 + }, + "name": "a-name", + "owner": { + "interface": 9 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 1 + }, + "name": "x", + "owner": { + "world": 1 + } + } + ], + "packages": [ + { + "name": "foo:multi-file", + "docs": { + "contents": null + }, + "interfaces": { + "irrelevant-name": 0, + "depend-on-me": 1, + "depends-on-later-item": 2, + "later-interface": 3, + "cycle1": 4, + "cycle2": 5, + "cycle3": 6, + "foo": 7, + "something-else": 8, + "bar": 9 + }, + "worlds": { + "more-depends-on-later-things": 0, + "the-world": 1 + } + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/name-both-resource-and-type.wit.json b/crates/wit-parser/tests/ui/name-both-resource-and-type.wit.json new file mode 100644 index 0000000000..097b0f5488 --- /dev/null +++ b/crates/wit-parser/tests/ui/name-both-resource-and-type.wit.json @@ -0,0 +1,116 @@ +{ + "worlds": [], + "interfaces": [ + { + "name": "foo", + "docs": { + "contents": null + }, + "types": { + "a": 0 + }, + "functions": {}, + "package": 0 + }, + { + "name": "foo", + "docs": { + "contents": null + }, + "types": { + "a": 1, + "t1": 2, + "t2": 3, + "t3": 4 + }, + "functions": {}, + "package": 1 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": "resource", + "name": "a", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 0 + }, + "name": "a", + "owner": { + "interface": 1 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 1 + }, + "name": "t1", + "owner": { + "interface": 1 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "borrow": 1 + } + }, + "name": "t2", + "owner": { + "interface": 1 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "borrow": 2 + } + }, + "name": "t3", + "owner": { + "interface": 1 + } + } + ], + "packages": [ + { + "name": "some:dep", + "docs": { + "contents": null + }, + "interfaces": { + "foo": 0 + }, + "worlds": {} + }, + { + "name": "foo:bar", + "docs": { + "contents": null + }, + "interfaces": { + "foo": 1 + }, + "worlds": {} + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/package-syntax1.wit.json b/crates/wit-parser/tests/ui/package-syntax1.wit.json new file mode 100644 index 0000000000..32beadead1 --- /dev/null +++ b/crates/wit-parser/tests/ui/package-syntax1.wit.json @@ -0,0 +1,15 @@ +{ + "worlds": [], + "interfaces": [], + "types": [], + "packages": [ + { + "name": "foo:foo", + "docs": { + "contents": null + }, + "interfaces": {}, + "worlds": {} + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/package-syntax3.wit.json b/crates/wit-parser/tests/ui/package-syntax3.wit.json new file mode 100644 index 0000000000..37ed94219b --- /dev/null +++ b/crates/wit-parser/tests/ui/package-syntax3.wit.json @@ -0,0 +1,15 @@ +{ + "worlds": [], + "interfaces": [], + "types": [], + "packages": [ + { + "name": "foo:bar", + "docs": { + "contents": null + }, + "interfaces": {}, + "worlds": {} + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/package-syntax4.wit.json b/crates/wit-parser/tests/ui/package-syntax4.wit.json new file mode 100644 index 0000000000..43a9aec4cd --- /dev/null +++ b/crates/wit-parser/tests/ui/package-syntax4.wit.json @@ -0,0 +1,15 @@ +{ + "worlds": [], + "interfaces": [], + "types": [], + "packages": [ + { + "name": "foo:bar@2.0.0", + "docs": { + "contents": null + }, + "interfaces": {}, + "worlds": {} + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/resources-empty.wit.json b/crates/wit-parser/tests/ui/resources-empty.wit.json new file mode 100644 index 0000000000..516cafda9c --- /dev/null +++ b/crates/wit-parser/tests/ui/resources-empty.wit.json @@ -0,0 +1,93 @@ +{ + "worlds": [], + "interfaces": [ + { + "name": "resources-empty", + "docs": { + "contents": null + }, + "types": { + "r1": 0 + }, + "functions": { + "t1": { + "docs": { + "contents": null + }, + "name": "t1", + "kind": "freestanding", + "params": [ + { + "name": "a", + "type": 2 + } + ], + "results": [] + }, + "t2": { + "docs": { + "contents": null + }, + "name": "t2", + "kind": "freestanding", + "params": [ + { + "name": "a", + "type": 1 + } + ], + "results": [] + } + }, + "package": 0 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": "resource", + "name": "r1", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "borrow": 0 + } + }, + "name": null, + "owner": "none" + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "own": 0 + } + }, + "name": null, + "owner": "none" + } + ], + "packages": [ + { + "name": "foo:resources-empty", + "docs": { + "contents": null + }, + "interfaces": { + "resources-empty": 0 + }, + "worlds": {} + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/resources-multiple-returns-borrow.wit.json b/crates/wit-parser/tests/ui/resources-multiple-returns-borrow.wit.json new file mode 100644 index 0000000000..aba75f94c2 --- /dev/null +++ b/crates/wit-parser/tests/ui/resources-multiple-returns-borrow.wit.json @@ -0,0 +1,92 @@ +{ + "worlds": [], + "interfaces": [ + { + "name": "resources1", + "docs": { + "contents": null + }, + "types": { + "r1": 0 + }, + "functions": { + "t1": { + "docs": { + "contents": null + }, + "name": "t1", + "kind": "freestanding", + "params": [ + { + "name": "a", + "type": 1 + } + ], + "results": [] + }, + "[method]r1.f1": { + "docs": { + "contents": null + }, + "name": "[method]r1.f1", + "kind": { + "method": 0 + }, + "params": [ + { + "name": "self", + "type": 1 + } + ], + "results": [ + { + "name": "a", + "type": "s32" + }, + { + "name": "handle", + "type": 1 + } + ] + } + }, + "package": 0 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": "resource", + "name": "r1", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "borrow": 0 + } + }, + "name": null, + "owner": "none" + } + ], + "packages": [ + { + "name": "foo:resources1", + "docs": { + "contents": null + }, + "interfaces": { + "resources1": 0 + }, + "worlds": {} + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/resources-multiple-returns-own.wit.json b/crates/wit-parser/tests/ui/resources-multiple-returns-own.wit.json new file mode 100644 index 0000000000..8ccd93c61e --- /dev/null +++ b/crates/wit-parser/tests/ui/resources-multiple-returns-own.wit.json @@ -0,0 +1,104 @@ +{ + "worlds": [], + "interfaces": [ + { + "name": "resources1", + "docs": { + "contents": null + }, + "types": { + "r1": 0 + }, + "functions": { + "t1": { + "docs": { + "contents": null + }, + "name": "t1", + "kind": "freestanding", + "params": [ + { + "name": "a", + "type": 2 + } + ], + "results": [] + }, + "[method]r1.f1": { + "docs": { + "contents": null + }, + "name": "[method]r1.f1", + "kind": { + "method": 0 + }, + "params": [ + { + "name": "self", + "type": 1 + } + ], + "results": [ + { + "name": "a", + "type": "s32" + }, + { + "name": "handle", + "type": 2 + } + ] + } + }, + "package": 0 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": "resource", + "name": "r1", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "borrow": 0 + } + }, + "name": null, + "owner": "none" + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "own": 0 + } + }, + "name": null, + "owner": "none" + } + ], + "packages": [ + { + "name": "foo:resources1", + "docs": { + "contents": null + }, + "interfaces": { + "resources1": 0 + }, + "worlds": {} + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/resources-multiple.wit.json b/crates/wit-parser/tests/ui/resources-multiple.wit.json new file mode 100644 index 0000000000..9e926d7b32 --- /dev/null +++ b/crates/wit-parser/tests/ui/resources-multiple.wit.json @@ -0,0 +1,341 @@ +{ + "worlds": [], + "interfaces": [ + { + "name": "resources-multiple", + "docs": { + "contents": null + }, + "types": { + "r1": 0 + }, + "functions": { + "t1": { + "docs": { + "contents": null + }, + "name": "t1", + "kind": "freestanding", + "params": [ + { + "name": "a", + "type": 1 + } + ], + "results": [] + }, + "t2": { + "docs": { + "contents": null + }, + "name": "t2", + "kind": "freestanding", + "params": [ + { + "name": "a", + "type": 5 + } + ], + "results": [] + }, + "[method]r1.f1": { + "docs": { + "contents": null + }, + "name": "[method]r1.f1", + "kind": { + "method": 0 + }, + "params": [ + { + "name": "self", + "type": 1 + } + ], + "results": [] + }, + "[method]r1.f2": { + "docs": { + "contents": null + }, + "name": "[method]r1.f2", + "kind": { + "method": 0 + }, + "params": [ + { + "name": "self", + "type": 1 + }, + { + "name": "a", + "type": "u32" + } + ], + "results": [] + }, + "[method]r1.f3": { + "docs": { + "contents": null + }, + "name": "[method]r1.f3", + "kind": { + "method": 0 + }, + "params": [ + { + "name": "self", + "type": 1 + }, + { + "name": "a", + "type": "u32" + } + ], + "results": [] + }, + "[method]r1.f4": { + "docs": { + "contents": null + }, + "name": "[method]r1.f4", + "kind": { + "method": 0 + }, + "params": [ + { + "name": "self", + "type": 1 + } + ], + "results": [ + { + "type": "u32" + } + ] + }, + "[method]r1.f6": { + "docs": { + "contents": null + }, + "name": "[method]r1.f6", + "kind": { + "method": 0 + }, + "params": [ + { + "name": "self", + "type": 1 + } + ], + "results": [ + { + "type": 2 + } + ] + }, + "[method]r1.f7": { + "docs": { + "contents": null + }, + "name": "[method]r1.f7", + "kind": { + "method": 0 + }, + "params": [ + { + "name": "self", + "type": 1 + }, + { + "name": "a", + "type": "float32" + }, + { + "name": "b", + "type": "float32" + } + ], + "results": [ + { + "type": 2 + } + ] + }, + "[method]r1.f8": { + "docs": { + "contents": null + }, + "name": "[method]r1.f8", + "kind": { + "method": 0 + }, + "params": [ + { + "name": "self", + "type": 1 + }, + { + "name": "a", + "type": 3 + } + ], + "results": [ + { + "type": 4 + } + ] + }, + "[method]r1.f9": { + "docs": { + "contents": null + }, + "name": "[method]r1.f9", + "kind": { + "method": 0 + }, + "params": [ + { + "name": "self", + "type": 1 + } + ], + "results": [ + { + "name": "u", + "type": "u32" + }, + { + "name": "f", + "type": "float32" + } + ] + }, + "[method]r1.f10": { + "docs": { + "contents": null + }, + "name": "[method]r1.f10", + "kind": { + "method": 0 + }, + "params": [ + { + "name": "self", + "type": 1 + } + ], + "results": [ + { + "name": "u", + "type": "u32" + } + ] + }, + "[method]r1.f11": { + "docs": { + "contents": null + }, + "name": "[method]r1.f11", + "kind": { + "method": 0 + }, + "params": [ + { + "name": "self", + "type": 1 + } + ], + "results": [] + } + }, + "package": 0 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": "resource", + "name": "r1", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "borrow": 0 + } + }, + "name": null, + "owner": "none" + }, + { + "docs": { + "contents": null + }, + "kind": { + "tuple": { + "types": [ + "u32", + "u32" + ] + } + }, + "name": null, + "owner": "none" + }, + { + "docs": { + "contents": null + }, + "kind": { + "option": "u32" + }, + "name": null, + "owner": "none" + }, + { + "docs": { + "contents": null + }, + "kind": { + "result": { + "ok": "u32", + "err": "float32" + } + }, + "name": null, + "owner": "none" + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "own": 0 + } + }, + "name": null, + "owner": "none" + } + ], + "packages": [ + { + "name": "foo:resources-multiple", + "docs": { + "contents": null + }, + "interfaces": { + "resources-multiple": 0 + }, + "worlds": {} + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/resources-return-borrow.wit.json b/crates/wit-parser/tests/ui/resources-return-borrow.wit.json new file mode 100644 index 0000000000..cfeca1d305 --- /dev/null +++ b/crates/wit-parser/tests/ui/resources-return-borrow.wit.json @@ -0,0 +1,87 @@ +{ + "worlds": [], + "interfaces": [ + { + "name": "resources1", + "docs": { + "contents": null + }, + "types": { + "r1": 0 + }, + "functions": { + "t1": { + "docs": { + "contents": null + }, + "name": "t1", + "kind": "freestanding", + "params": [ + { + "name": "a", + "type": 1 + } + ], + "results": [] + }, + "[method]r1.f1": { + "docs": { + "contents": null + }, + "name": "[method]r1.f1", + "kind": { + "method": 0 + }, + "params": [ + { + "name": "self", + "type": 1 + } + ], + "results": [ + { + "type": 1 + } + ] + } + }, + "package": 0 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": "resource", + "name": "r1", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "borrow": 0 + } + }, + "name": null, + "owner": "none" + } + ], + "packages": [ + { + "name": "foo:resources1", + "docs": { + "contents": null + }, + "interfaces": { + "resources1": 0 + }, + "worlds": {} + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/resources-return-own.wit.json b/crates/wit-parser/tests/ui/resources-return-own.wit.json new file mode 100644 index 0000000000..9cddd741f3 --- /dev/null +++ b/crates/wit-parser/tests/ui/resources-return-own.wit.json @@ -0,0 +1,99 @@ +{ + "worlds": [], + "interfaces": [ + { + "name": "resources1", + "docs": { + "contents": null + }, + "types": { + "r1": 0 + }, + "functions": { + "t1": { + "docs": { + "contents": null + }, + "name": "t1", + "kind": "freestanding", + "params": [ + { + "name": "a", + "type": 2 + } + ], + "results": [] + }, + "[method]r1.f1": { + "docs": { + "contents": null + }, + "name": "[method]r1.f1", + "kind": { + "method": 0 + }, + "params": [ + { + "name": "self", + "type": 1 + } + ], + "results": [ + { + "type": 2 + } + ] + } + }, + "package": 0 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": "resource", + "name": "r1", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "borrow": 0 + } + }, + "name": null, + "owner": "none" + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "own": 0 + } + }, + "name": null, + "owner": "none" + } + ], + "packages": [ + { + "name": "foo:resources1", + "docs": { + "contents": null + }, + "interfaces": { + "resources1": 0 + }, + "worlds": {} + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/resources.wit.json b/crates/wit-parser/tests/ui/resources.wit.json new file mode 100644 index 0000000000..e0f623e203 --- /dev/null +++ b/crates/wit-parser/tests/ui/resources.wit.json @@ -0,0 +1,433 @@ +{ + "worlds": [ + { + "name": "w", + "docs": { + "contents": null + }, + "imports": { + "a": { + "type": 11 + }, + "b": { + "type": 12 + }, + "c": { + "type": 13 + }, + "[constructor]c": { + "function": { + "docs": { + "contents": null + }, + "name": "[constructor]c", + "kind": { + "constructor": 13 + }, + "params": [], + "results": [ + { + "type": 18 + } + ] + } + } + }, + "exports": {}, + "package": 0 + } + ], + "interfaces": [ + { + "name": "foo", + "docs": { + "contents": null + }, + "types": { + "a": 0, + "b": 1, + "c": 2, + "d": 3, + "e": 4 + }, + "functions": { + "[constructor]b": { + "docs": { + "contents": null + }, + "name": "[constructor]b", + "kind": { + "constructor": 1 + }, + "params": [], + "results": [ + { + "type": 14 + } + ] + }, + "[constructor]c": { + "docs": { + "contents": null + }, + "name": "[constructor]c", + "kind": { + "constructor": 2 + }, + "params": [ + { + "name": "x", + "type": "u32" + } + ], + "results": [ + { + "type": 15 + } + ] + }, + "[constructor]d": { + "docs": { + "contents": null + }, + "name": "[constructor]d", + "kind": { + "constructor": 3 + }, + "params": [ + { + "name": "x", + "type": "u32" + } + ], + "results": [ + { + "type": 16 + } + ] + }, + "[method]d.a": { + "docs": { + "contents": null + }, + "name": "[method]d.a", + "kind": { + "method": 3 + }, + "params": [ + { + "name": "self", + "type": 5 + } + ], + "results": [] + }, + "[static]d.b": { + "docs": { + "contents": null + }, + "name": "[static]d.b", + "kind": { + "static": 3 + }, + "params": [], + "results": [] + }, + "[constructor]e": { + "docs": { + "contents": null + }, + "name": "[constructor]e", + "kind": { + "constructor": 4 + }, + "params": [ + { + "name": "other", + "type": 17 + }, + { + "name": "other2", + "type": 6 + } + ], + "results": [ + { + "type": 17 + } + ] + }, + "[method]e.method": { + "docs": { + "contents": null + }, + "name": "[method]e.method", + "kind": { + "method": 4 + }, + "params": [ + { + "name": "self", + "type": 6 + }, + { + "name": "thing", + "type": 17 + }, + { + "name": "thing2", + "type": 6 + } + ], + "results": [] + } + }, + "package": 0 + }, + { + "name": "i", + "docs": { + "contents": null + }, + "types": { + "a": 7, + "t1": 8, + "t2": 9, + "t3": 10 + }, + "functions": {}, + "package": 0 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": "resource", + "name": "a", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": "resource", + "name": "b", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": "resource", + "name": "c", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": "resource", + "name": "d", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": "resource", + "name": "e", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "borrow": 3 + } + }, + "name": null, + "owner": "none" + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "borrow": 4 + } + }, + "name": null, + "owner": "none" + }, + { + "docs": { + "contents": null + }, + "kind": "resource", + "name": "a", + "owner": { + "interface": 1 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 7 + }, + "name": "t1", + "owner": { + "interface": 1 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "borrow": 7 + } + }, + "name": "t2", + "owner": { + "interface": 1 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "borrow": 8 + } + }, + "name": "t3", + "owner": { + "interface": 1 + } + }, + { + "docs": { + "contents": null + }, + "kind": "resource", + "name": "a", + "owner": { + "world": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": "resource", + "name": "b", + "owner": { + "world": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": "resource", + "name": "c", + "owner": { + "world": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "own": 1 + } + }, + "name": null, + "owner": "none" + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "own": 2 + } + }, + "name": null, + "owner": "none" + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "own": 3 + } + }, + "name": null, + "owner": "none" + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "own": 4 + } + }, + "name": null, + "owner": "none" + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "own": 13 + } + }, + "name": null, + "owner": "none" + } + ], + "packages": [ + { + "name": "foo:bar", + "docs": { + "contents": null + }, + "interfaces": { + "foo": 0, + "i": 1 + }, + "worlds": { + "w": 0 + } + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/resources1.wit.json b/crates/wit-parser/tests/ui/resources1.wit.json new file mode 100644 index 0000000000..f95ead453e --- /dev/null +++ b/crates/wit-parser/tests/ui/resources1.wit.json @@ -0,0 +1,123 @@ +{ + "worlds": [], + "interfaces": [ + { + "name": "resources1", + "docs": { + "contents": null + }, + "types": { + "r1": 0 + }, + "functions": { + "t1": { + "docs": { + "contents": null + }, + "name": "t1", + "kind": "freestanding", + "params": [ + { + "name": "a", + "type": 1 + } + ], + "results": [] + }, + "t2": { + "docs": { + "contents": null + }, + "name": "t2", + "kind": "freestanding", + "params": [ + { + "name": "a", + "type": 2 + } + ], + "results": [] + }, + "t3": { + "docs": { + "contents": null + }, + "name": "t3", + "kind": "freestanding", + "params": [ + { + "name": "a", + "type": 2 + } + ], + "results": [] + }, + "[method]r1.f1": { + "docs": { + "contents": null + }, + "name": "[method]r1.f1", + "kind": { + "method": 0 + }, + "params": [ + { + "name": "self", + "type": 1 + } + ], + "results": [] + } + }, + "package": 0 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": "resource", + "name": "r1", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "borrow": 0 + } + }, + "name": null, + "owner": "none" + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "own": 0 + } + }, + "name": null, + "owner": "none" + } + ], + "packages": [ + { + "name": "foo:resources1", + "docs": { + "contents": null + }, + "interfaces": { + "resources1": 0 + }, + "worlds": {} + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/shared-types.wit.json b/crates/wit-parser/tests/ui/shared-types.wit.json new file mode 100644 index 0000000000..48d6e5fe5e --- /dev/null +++ b/crates/wit-parser/tests/ui/shared-types.wit.json @@ -0,0 +1,107 @@ +{ + "worlds": [ + { + "name": "foo", + "docs": { + "contents": null + }, + "imports": { + "foo": { + "interface": 0 + } + }, + "exports": { + "bar": { + "interface": 1 + } + }, + "package": 0 + } + ], + "interfaces": [ + { + "name": null, + "docs": { + "contents": null + }, + "types": {}, + "functions": { + "a": { + "docs": { + "contents": null + }, + "name": "a", + "kind": "freestanding", + "params": [], + "results": [ + { + "type": 0 + } + ] + } + }, + "package": 0 + }, + { + "name": null, + "docs": { + "contents": null + }, + "types": {}, + "functions": { + "a": { + "docs": { + "contents": null + }, + "name": "a", + "kind": "freestanding", + "params": [], + "results": [ + { + "type": 1 + } + ] + } + }, + "package": 0 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": { + "list": "u8" + }, + "name": null, + "owner": "none" + }, + { + "docs": { + "contents": null + }, + "kind": { + "tuple": { + "types": [ + 0 + ] + } + }, + "name": null, + "owner": "none" + } + ], + "packages": [ + { + "name": "foo:shared-items", + "docs": { + "contents": null + }, + "interfaces": {}, + "worlds": { + "foo": 0 + } + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/stress-export-elaborate.wit.json b/crates/wit-parser/tests/ui/stress-export-elaborate.wit.json new file mode 100644 index 0000000000..aa5dca7cf1 --- /dev/null +++ b/crates/wit-parser/tests/ui/stress-export-elaborate.wit.json @@ -0,0 +1,1472 @@ +{ + "worlds": [ + { + "name": "foo", + "docs": { + "contents": null + }, + "imports": { + "interface-0": { + "interface": 0 + }, + "interface-1": { + "interface": 1 + }, + "interface-2": { + "interface": 2 + }, + "interface-3": { + "interface": 3 + }, + "interface-4": { + "interface": 4 + }, + "interface-5": { + "interface": 5 + }, + "interface-6": { + "interface": 6 + }, + "interface-7": { + "interface": 7 + }, + "interface-8": { + "interface": 8 + } + }, + "exports": { + "interface-9": { + "interface": 9 + } + }, + "package": 0 + } + ], + "interfaces": [ + { + "name": "i1", + "docs": { + "contents": null + }, + "types": { + "t1": 0, + "t2": 1, + "t3": 2, + "t4": 3, + "t5": 4, + "t6": 5, + "t7": 6, + "t8": 7, + "t9": 8, + "t10": 9 + }, + "functions": {}, + "package": 0 + }, + { + "name": "i2", + "docs": { + "contents": null + }, + "types": { + "t1": 10, + "t2": 11, + "t3": 12, + "t4": 13, + "t5": 14, + "t6": 15, + "t7": 16, + "t8": 17, + "t9": 18, + "t10": 19 + }, + "functions": {}, + "package": 0 + }, + { + "name": "i3", + "docs": { + "contents": null + }, + "types": { + "t1": 20, + "t2": 21, + "t3": 22, + "t4": 23, + "t5": 24, + "t6": 25, + "t7": 26, + "t8": 27, + "t9": 28, + "t10": 29 + }, + "functions": {}, + "package": 0 + }, + { + "name": "i4", + "docs": { + "contents": null + }, + "types": { + "t1": 30, + "t2": 31, + "t3": 32, + "t4": 33, + "t5": 34, + "t6": 35, + "t7": 36, + "t8": 37, + "t9": 38, + "t10": 39 + }, + "functions": {}, + "package": 0 + }, + { + "name": "i5", + "docs": { + "contents": null + }, + "types": { + "t1": 40, + "t2": 41, + "t3": 42, + "t4": 43, + "t5": 44, + "t6": 45, + "t7": 46, + "t8": 47, + "t9": 48, + "t10": 49 + }, + "functions": {}, + "package": 0 + }, + { + "name": "i6", + "docs": { + "contents": null + }, + "types": { + "t1": 50, + "t2": 51, + "t3": 52, + "t4": 53, + "t5": 54, + "t6": 55, + "t7": 56, + "t8": 57, + "t9": 58, + "t10": 59 + }, + "functions": {}, + "package": 0 + }, + { + "name": "i7", + "docs": { + "contents": null + }, + "types": { + "t1": 60, + "t2": 61, + "t3": 62, + "t4": 63, + "t5": 64, + "t6": 65, + "t7": 66, + "t8": 67, + "t9": 68, + "t10": 69 + }, + "functions": {}, + "package": 0 + }, + { + "name": "i8", + "docs": { + "contents": null + }, + "types": { + "t1": 70, + "t2": 71, + "t3": 72, + "t4": 73, + "t5": 74, + "t6": 75, + "t7": 76, + "t8": 77, + "t9": 78, + "t10": 79 + }, + "functions": {}, + "package": 0 + }, + { + "name": "i9", + "docs": { + "contents": null + }, + "types": { + "t1": 80, + "t2": 81, + "t3": 82, + "t4": 83, + "t5": 84, + "t6": 85, + "t7": 86, + "t8": 87, + "t9": 88, + "t10": 89 + }, + "functions": {}, + "package": 0 + }, + { + "name": "i10", + "docs": { + "contents": null + }, + "types": { + "t1": 90, + "t2": 91, + "t3": 92, + "t4": 93, + "t5": 94, + "t6": 95, + "t7": 96, + "t8": 97, + "t9": 98, + "t10": 99 + }, + "functions": {}, + "package": 0 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "t1", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "t2", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "t3", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "t4", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "t5", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "t6", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "t7", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "t8", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "t9", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "t10", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 0 + }, + "name": "t1", + "owner": { + "interface": 1 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 1 + }, + "name": "t2", + "owner": { + "interface": 1 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 2 + }, + "name": "t3", + "owner": { + "interface": 1 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 3 + }, + "name": "t4", + "owner": { + "interface": 1 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 4 + }, + "name": "t5", + "owner": { + "interface": 1 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 5 + }, + "name": "t6", + "owner": { + "interface": 1 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 6 + }, + "name": "t7", + "owner": { + "interface": 1 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 7 + }, + "name": "t8", + "owner": { + "interface": 1 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 8 + }, + "name": "t9", + "owner": { + "interface": 1 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 9 + }, + "name": "t10", + "owner": { + "interface": 1 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 10 + }, + "name": "t1", + "owner": { + "interface": 2 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 11 + }, + "name": "t2", + "owner": { + "interface": 2 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 12 + }, + "name": "t3", + "owner": { + "interface": 2 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 13 + }, + "name": "t4", + "owner": { + "interface": 2 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 14 + }, + "name": "t5", + "owner": { + "interface": 2 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 15 + }, + "name": "t6", + "owner": { + "interface": 2 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 16 + }, + "name": "t7", + "owner": { + "interface": 2 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 17 + }, + "name": "t8", + "owner": { + "interface": 2 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 18 + }, + "name": "t9", + "owner": { + "interface": 2 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 19 + }, + "name": "t10", + "owner": { + "interface": 2 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 20 + }, + "name": "t1", + "owner": { + "interface": 3 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 21 + }, + "name": "t2", + "owner": { + "interface": 3 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 22 + }, + "name": "t3", + "owner": { + "interface": 3 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 23 + }, + "name": "t4", + "owner": { + "interface": 3 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 24 + }, + "name": "t5", + "owner": { + "interface": 3 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 25 + }, + "name": "t6", + "owner": { + "interface": 3 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 26 + }, + "name": "t7", + "owner": { + "interface": 3 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 27 + }, + "name": "t8", + "owner": { + "interface": 3 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 28 + }, + "name": "t9", + "owner": { + "interface": 3 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 29 + }, + "name": "t10", + "owner": { + "interface": 3 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 30 + }, + "name": "t1", + "owner": { + "interface": 4 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 31 + }, + "name": "t2", + "owner": { + "interface": 4 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 32 + }, + "name": "t3", + "owner": { + "interface": 4 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 33 + }, + "name": "t4", + "owner": { + "interface": 4 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 34 + }, + "name": "t5", + "owner": { + "interface": 4 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 35 + }, + "name": "t6", + "owner": { + "interface": 4 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 36 + }, + "name": "t7", + "owner": { + "interface": 4 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 37 + }, + "name": "t8", + "owner": { + "interface": 4 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 38 + }, + "name": "t9", + "owner": { + "interface": 4 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 39 + }, + "name": "t10", + "owner": { + "interface": 4 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 40 + }, + "name": "t1", + "owner": { + "interface": 5 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 41 + }, + "name": "t2", + "owner": { + "interface": 5 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 42 + }, + "name": "t3", + "owner": { + "interface": 5 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 43 + }, + "name": "t4", + "owner": { + "interface": 5 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 44 + }, + "name": "t5", + "owner": { + "interface": 5 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 45 + }, + "name": "t6", + "owner": { + "interface": 5 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 46 + }, + "name": "t7", + "owner": { + "interface": 5 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 47 + }, + "name": "t8", + "owner": { + "interface": 5 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 48 + }, + "name": "t9", + "owner": { + "interface": 5 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 49 + }, + "name": "t10", + "owner": { + "interface": 5 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 50 + }, + "name": "t1", + "owner": { + "interface": 6 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 51 + }, + "name": "t2", + "owner": { + "interface": 6 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 52 + }, + "name": "t3", + "owner": { + "interface": 6 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 53 + }, + "name": "t4", + "owner": { + "interface": 6 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 54 + }, + "name": "t5", + "owner": { + "interface": 6 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 55 + }, + "name": "t6", + "owner": { + "interface": 6 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 56 + }, + "name": "t7", + "owner": { + "interface": 6 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 57 + }, + "name": "t8", + "owner": { + "interface": 6 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 58 + }, + "name": "t9", + "owner": { + "interface": 6 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 59 + }, + "name": "t10", + "owner": { + "interface": 6 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 60 + }, + "name": "t1", + "owner": { + "interface": 7 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 61 + }, + "name": "t2", + "owner": { + "interface": 7 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 62 + }, + "name": "t3", + "owner": { + "interface": 7 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 63 + }, + "name": "t4", + "owner": { + "interface": 7 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 64 + }, + "name": "t5", + "owner": { + "interface": 7 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 65 + }, + "name": "t6", + "owner": { + "interface": 7 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 66 + }, + "name": "t7", + "owner": { + "interface": 7 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 67 + }, + "name": "t8", + "owner": { + "interface": 7 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 68 + }, + "name": "t9", + "owner": { + "interface": 7 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 69 + }, + "name": "t10", + "owner": { + "interface": 7 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 70 + }, + "name": "t1", + "owner": { + "interface": 8 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 71 + }, + "name": "t2", + "owner": { + "interface": 8 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 72 + }, + "name": "t3", + "owner": { + "interface": 8 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 73 + }, + "name": "t4", + "owner": { + "interface": 8 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 74 + }, + "name": "t5", + "owner": { + "interface": 8 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 75 + }, + "name": "t6", + "owner": { + "interface": 8 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 76 + }, + "name": "t7", + "owner": { + "interface": 8 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 77 + }, + "name": "t8", + "owner": { + "interface": 8 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 78 + }, + "name": "t9", + "owner": { + "interface": 8 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 79 + }, + "name": "t10", + "owner": { + "interface": 8 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 80 + }, + "name": "t1", + "owner": { + "interface": 9 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 81 + }, + "name": "t2", + "owner": { + "interface": 9 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 82 + }, + "name": "t3", + "owner": { + "interface": 9 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 83 + }, + "name": "t4", + "owner": { + "interface": 9 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 84 + }, + "name": "t5", + "owner": { + "interface": 9 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 85 + }, + "name": "t6", + "owner": { + "interface": 9 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 86 + }, + "name": "t7", + "owner": { + "interface": 9 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 87 + }, + "name": "t8", + "owner": { + "interface": 9 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 88 + }, + "name": "t9", + "owner": { + "interface": 9 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 89 + }, + "name": "t10", + "owner": { + "interface": 9 + } + } + ], + "packages": [ + { + "name": "foo:bar", + "docs": { + "contents": null + }, + "interfaces": { + "i1": 0, + "i2": 1, + "i3": 2, + "i4": 3, + "i5": 4, + "i6": 5, + "i7": 6, + "i8": 7, + "i9": 8, + "i10": 9 + }, + "worlds": { + "foo": 0 + } + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/type-then-eof.wit.json b/crates/wit-parser/tests/ui/type-then-eof.wit.json new file mode 100644 index 0000000000..e952bc6f6e --- /dev/null +++ b/crates/wit-parser/tests/ui/type-then-eof.wit.json @@ -0,0 +1,41 @@ +{ + "worlds": [], + "interfaces": [ + { + "name": "foo", + "docs": { + "contents": null + }, + "types": {}, + "functions": { + "foo": { + "docs": { + "contents": null + }, + "name": "foo", + "kind": "freestanding", + "params": [], + "results": [ + { + "type": "string" + } + ] + } + }, + "package": 0 + } + ], + "types": [], + "packages": [ + { + "name": "foo:foo", + "docs": { + "contents": null + }, + "interfaces": { + "foo": 0 + }, + "worlds": {} + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/types.wit.json b/crates/wit-parser/tests/ui/types.wit.json new file mode 100644 index 0000000000..0e2da49d42 --- /dev/null +++ b/crates/wit-parser/tests/ui/types.wit.json @@ -0,0 +1,1006 @@ +{ + "worlds": [], + "interfaces": [ + { + "name": "types", + "docs": { + "contents": null + }, + "types": { + "t1": 0, + "t2": 1, + "t3": 2, + "t4": 3, + "t5": 4, + "t6": 5, + "t7": 6, + "t8": 7, + "t9": 8, + "t10": 9, + "t11": 10, + "t12": 11, + "t13": 12, + "t14": 13, + "t15": 14, + "t16": 15, + "t17": 16, + "t18": 17, + "t20": 18, + "t21": 19, + "t22": 20, + "t23": 21, + "t24": 22, + "t25": 23, + "record": 24, + "t26": 25, + "t27": 26, + "t28": 27, + "t29": 28, + "t30": 29, + "t31": 30, + "t32": 31, + "t33": 32, + "t34": 33, + "t35": 34, + "t36": 35, + "t37": 37, + "t41": 38, + "t42": 39, + "t43": 40, + "t44": 41, + "t45": 44, + "t46": 45, + "t47": 46, + "t48": 47, + "t49": 48, + "t50": 49, + "t51": 50, + "t52": 51, + "t53": 52, + "bar": 53, + "foo": 54 + }, + "functions": {}, + "package": 0 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": { + "type": "u8" + }, + "name": "t1", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "u16" + }, + "name": "t2", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "t3", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "u64" + }, + "name": "t4", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "s8" + }, + "name": "t5", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "s16" + }, + "name": "t6", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "s32" + }, + "name": "t7", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "s64" + }, + "name": "t8", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "float32" + }, + "name": "t9", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "float64" + }, + "name": "t10", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "char" + }, + "name": "t11", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "list": "char" + }, + "name": "t12", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "string" + }, + "name": "t13", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "option": "u32" + }, + "name": "t14", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "result": { + "ok": "u32", + "err": "u32" + } + }, + "name": "t15", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "result": { + "ok": null, + "err": "u32" + } + }, + "name": "t16", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "result": { + "ok": "u32", + "err": null + } + }, + "name": "t17", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "result": { + "ok": null, + "err": null + } + }, + "name": "t18", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "record": { + "fields": [] + } + }, + "name": "t20", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "record": { + "fields": [ + { + "docs": { + "contents": null + }, + "name": "a", + "type": "u32" + } + ] + } + }, + "name": "t21", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "record": { + "fields": [ + { + "docs": { + "contents": null + }, + "name": "a", + "type": "u32" + } + ] + } + }, + "name": "t22", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "record": { + "fields": [ + { + "docs": { + "contents": null + }, + "name": "a", + "type": "u32" + }, + { + "docs": { + "contents": null + }, + "name": "b", + "type": "u64" + } + ] + } + }, + "name": "t23", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "record": { + "fields": [ + { + "docs": { + "contents": null + }, + "name": "a", + "type": "u32" + }, + { + "docs": { + "contents": null + }, + "name": "b", + "type": "u64" + } + ] + } + }, + "name": "t24", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "record": { + "fields": [ + { + "docs": { + "contents": null + }, + "name": "x", + "type": "u32" + } + ] + } + }, + "name": "t25", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "record": { + "fields": [] + } + }, + "name": "record", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "tuple": { + "types": [] + } + }, + "name": "t26", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "tuple": { + "types": [ + "u32" + ] + } + }, + "name": "t27", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "tuple": { + "types": [ + "u32" + ] + } + }, + "name": "t28", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "tuple": { + "types": [ + "u32", + "u64" + ] + } + }, + "name": "t29", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "flags": { + "flags": [] + } + }, + "name": "t30", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "flags": { + "flags": [ + { + "docs": { + "contents": null + }, + "name": "a" + }, + { + "docs": { + "contents": null + }, + "name": "b" + }, + { + "docs": { + "contents": null + }, + "name": "c" + } + ] + } + }, + "name": "t31", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "flags": { + "flags": [ + { + "docs": { + "contents": null + }, + "name": "a" + }, + { + "docs": { + "contents": null + }, + "name": "b" + }, + { + "docs": { + "contents": null + }, + "name": "c" + } + ] + } + }, + "name": "t32", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "variant": { + "cases": [ + { + "docs": { + "contents": null + }, + "name": "a", + "type": null + } + ] + } + }, + "name": "t33", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "variant": { + "cases": [ + { + "docs": { + "contents": null + }, + "name": "a", + "type": null + }, + { + "docs": { + "contents": null + }, + "name": "b", + "type": null + } + ] + } + }, + "name": "t34", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "variant": { + "cases": [ + { + "docs": { + "contents": null + }, + "name": "a", + "type": null + }, + { + "docs": { + "contents": null + }, + "name": "b", + "type": null + } + ] + } + }, + "name": "t35", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "variant": { + "cases": [ + { + "docs": { + "contents": null + }, + "name": "a", + "type": null + }, + { + "docs": { + "contents": null + }, + "name": "b", + "type": "u32" + } + ] + } + }, + "name": "t36", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "option": "u32" + }, + "name": null, + "owner": "none" + }, + { + "docs": { + "contents": null + }, + "kind": { + "variant": { + "cases": [ + { + "docs": { + "contents": null + }, + "name": "a", + "type": null + }, + { + "docs": { + "contents": null + }, + "name": "b", + "type": 36 + } + ] + } + }, + "name": "t37", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "enum": { + "cases": [ + { + "docs": { + "contents": null + }, + "name": "a" + }, + { + "docs": { + "contents": null + }, + "name": "b" + }, + { + "docs": { + "contents": null + }, + "name": "c" + } + ] + } + }, + "name": "t41", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "enum": { + "cases": [ + { + "docs": { + "contents": null + }, + "name": "a" + }, + { + "docs": { + "contents": null + }, + "name": "b" + }, + { + "docs": { + "contents": null + }, + "name": "c" + } + ] + } + }, + "name": "t42", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "bool" + }, + "name": "t43", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "string" + }, + "name": "t44", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "list": 31 + }, + "name": null, + "owner": "none" + }, + { + "docs": { + "contents": null + }, + "kind": { + "list": 42 + }, + "name": null, + "owner": "none" + }, + { + "docs": { + "contents": null + }, + "kind": { + "list": 43 + }, + "name": "t45", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 41 + }, + "name": "t46", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 41 + }, + "name": "t47", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "stream": { + "element": "u32", + "end": "u32" + } + }, + "name": "t48", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "stream": { + "element": null, + "end": "u32" + } + }, + "name": "t49", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "stream": { + "element": "u32", + "end": null + } + }, + "name": "t50", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "stream": { + "element": null, + "end": null + } + }, + "name": "t51", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "future": "u32" + }, + "name": "t52", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "future": null + }, + "name": "t53", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "bar", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 53 + }, + "name": "foo", + "owner": { + "interface": 0 + } + } + ], + "packages": [ + { + "name": "foo:types", + "docs": { + "contents": null + }, + "interfaces": { + "types": 0 + }, + "worlds": {} + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/union-fuzz-1.wit.json b/crates/wit-parser/tests/ui/union-fuzz-1.wit.json new file mode 100644 index 0000000000..0cf17afef4 --- /dev/null +++ b/crates/wit-parser/tests/ui/union-fuzz-1.wit.json @@ -0,0 +1,47 @@ +{ + "worlds": [ + { + "name": "xo", + "docs": { + "contents": null + }, + "imports": {}, + "exports": {}, + "package": 0 + }, + { + "name": "name", + "docs": { + "contents": null + }, + "imports": {}, + "exports": {}, + "package": 0 + }, + { + "name": "x", + "docs": { + "contents": null + }, + "imports": {}, + "exports": {}, + "package": 0 + } + ], + "interfaces": [], + "types": [], + "packages": [ + { + "name": "foo:bar", + "docs": { + "contents": null + }, + "interfaces": {}, + "worlds": { + "xo": 0, + "name": 1, + "x": 2 + } + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/use-chain.wit.json b/crates/wit-parser/tests/ui/use-chain.wit.json new file mode 100644 index 0000000000..fbdaead822 --- /dev/null +++ b/crates/wit-parser/tests/ui/use-chain.wit.json @@ -0,0 +1,68 @@ +{ + "worlds": [], + "interfaces": [ + { + "name": "foo", + "docs": { + "contents": null + }, + "types": { + "foo": 0 + }, + "functions": {}, + "package": 0 + }, + { + "name": "name", + "docs": { + "contents": null + }, + "types": { + "foo": 1 + }, + "functions": {}, + "package": 0 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": { + "record": { + "fields": [] + } + }, + "name": "foo", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 0 + }, + "name": "foo", + "owner": { + "interface": 1 + } + } + ], + "packages": [ + { + "name": "foo:name", + "docs": { + "contents": null + }, + "interfaces": { + "foo": 0, + "name": 1 + }, + "worlds": {} + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/use.wit.json b/crates/wit-parser/tests/ui/use.wit.json new file mode 100644 index 0000000000..a1244137ca --- /dev/null +++ b/crates/wit-parser/tests/ui/use.wit.json @@ -0,0 +1,226 @@ +{ + "worlds": [], + "interfaces": [ + { + "name": "bar", + "docs": { + "contents": null + }, + "types": { + "the-type": 0 + }, + "functions": {}, + "package": 0 + }, + { + "name": "foo", + "docs": { + "contents": null + }, + "types": { + "the-type": 1 + }, + "functions": {}, + "package": 0 + }, + { + "name": "baz", + "docs": { + "contents": null + }, + "types": { + "the-type": 2, + "test": 3 + }, + "functions": {}, + "package": 0 + }, + { + "name": "empty", + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 0 + }, + { + "name": "use-from-empty", + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 0 + }, + { + "name": "use-multiple", + "docs": { + "contents": null + }, + "types": { + "the-type": 4, + "test": 5 + }, + "functions": { + "some-function": { + "docs": { + "contents": null + }, + "name": "some-function", + "kind": "freestanding", + "params": [ + { + "name": "x", + "type": 4 + } + ], + "results": [ + { + "type": 5 + } + ] + } + }, + "package": 0 + }, + { + "name": "trailing-comma", + "docs": { + "contents": null + }, + "types": { + "the-type": 6, + "the-foo": 7 + }, + "functions": {}, + "package": 0 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "the-type", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 0 + }, + "name": "the-type", + "owner": { + "interface": 1 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 1 + }, + "name": "the-type", + "owner": { + "interface": 2 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 0 + }, + "name": "test", + "owner": { + "interface": 2 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 2 + }, + "name": "the-type", + "owner": { + "interface": 5 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 3 + }, + "name": "test", + "owner": { + "interface": 5 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 1 + }, + "name": "the-type", + "owner": { + "interface": 6 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "record": { + "fields": [ + { + "docs": { + "contents": null + }, + "name": "a", + "type": 6 + } + ] + } + }, + "name": "the-foo", + "owner": { + "interface": 6 + } + } + ], + "packages": [ + { + "name": "foo:foo", + "docs": { + "contents": null + }, + "interfaces": { + "bar": 0, + "foo": 1, + "baz": 2, + "empty": 3, + "use-from-empty": 4, + "use-multiple": 5, + "trailing-comma": 6 + }, + "worlds": {} + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/versions.wit.json b/crates/wit-parser/tests/ui/versions.wit.json new file mode 100644 index 0000000000..e4eb184a1e --- /dev/null +++ b/crates/wit-parser/tests/ui/versions.wit.json @@ -0,0 +1,121 @@ +{ + "worlds": [], + "interfaces": [ + { + "name": "foo", + "docs": { + "contents": null + }, + "types": { + "t": 0 + }, + "functions": {}, + "package": 0 + }, + { + "name": "foo", + "docs": { + "contents": null + }, + "types": { + "t": 1 + }, + "functions": {}, + "package": 1 + }, + { + "name": "foo", + "docs": { + "contents": null + }, + "types": { + "t": 2, + "t2": 3 + }, + "functions": {}, + "package": 2 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "t", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "t", + "owner": { + "interface": 1 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 0 + }, + "name": "t", + "owner": { + "interface": 2 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 1 + }, + "name": "t2", + "owner": { + "interface": 2 + } + } + ], + "packages": [ + { + "name": "a:a@1.0.0", + "docs": { + "contents": null + }, + "interfaces": { + "foo": 0 + }, + "worlds": {} + }, + { + "name": "a:a@2.0.0", + "docs": { + "contents": null + }, + "interfaces": { + "foo": 1 + }, + "worlds": {} + }, + { + "name": "foo:versions", + "docs": { + "contents": null + }, + "interfaces": { + "foo": 2 + }, + "worlds": {} + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/wasi.wit.json b/crates/wit-parser/tests/ui/wasi.wit.json new file mode 100644 index 0000000000..8b29d54aca --- /dev/null +++ b/crates/wit-parser/tests/ui/wasi.wit.json @@ -0,0 +1,548 @@ +{ + "worlds": [], + "interfaces": [ + { + "name": "wasi", + "docs": { + "contents": null + }, + "types": { + "clockid": 0, + "timestamp": 1, + "errno": 2 + }, + "functions": {}, + "package": 0 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": { + "enum": { + "cases": [ + { + "docs": { + "contents": null + }, + "name": "realtime" + }, + { + "docs": { + "contents": null + }, + "name": "monotonic" + } + ] + } + }, + "name": "clockid", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "u64" + }, + "name": "timestamp", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "enum": { + "cases": [ + { + "docs": { + "contents": null + }, + "name": "success" + }, + { + "docs": { + "contents": null + }, + "name": "toobig" + }, + { + "docs": { + "contents": null + }, + "name": "access" + }, + { + "docs": { + "contents": null + }, + "name": "addrinuse" + }, + { + "docs": { + "contents": null + }, + "name": "addrnotavail" + }, + { + "docs": { + "contents": null + }, + "name": "afnosupport" + }, + { + "docs": { + "contents": null + }, + "name": "again" + }, + { + "docs": { + "contents": null + }, + "name": "already" + }, + { + "docs": { + "contents": null + }, + "name": "badf" + }, + { + "docs": { + "contents": null + }, + "name": "badmsg" + }, + { + "docs": { + "contents": null + }, + "name": "busy" + }, + { + "docs": { + "contents": null + }, + "name": "canceled" + }, + { + "docs": { + "contents": null + }, + "name": "child" + }, + { + "docs": { + "contents": null + }, + "name": "connaborted" + }, + { + "docs": { + "contents": null + }, + "name": "connrefused" + }, + { + "docs": { + "contents": null + }, + "name": "connreset" + }, + { + "docs": { + "contents": null + }, + "name": "deadlk" + }, + { + "docs": { + "contents": null + }, + "name": "destaddrreq" + }, + { + "docs": { + "contents": null + }, + "name": "dom" + }, + { + "docs": { + "contents": null + }, + "name": "dquot" + }, + { + "docs": { + "contents": null + }, + "name": "exist" + }, + { + "docs": { + "contents": null + }, + "name": "fault" + }, + { + "docs": { + "contents": null + }, + "name": "fbig" + }, + { + "docs": { + "contents": null + }, + "name": "hostunreach" + }, + { + "docs": { + "contents": null + }, + "name": "idrm" + }, + { + "docs": { + "contents": null + }, + "name": "ilseq" + }, + { + "docs": { + "contents": null + }, + "name": "inprogress" + }, + { + "docs": { + "contents": null + }, + "name": "intr" + }, + { + "docs": { + "contents": null + }, + "name": "inval" + }, + { + "docs": { + "contents": null + }, + "name": "io" + }, + { + "docs": { + "contents": null + }, + "name": "isconn" + }, + { + "docs": { + "contents": null + }, + "name": "isdir" + }, + { + "docs": { + "contents": null + }, + "name": "loop" + }, + { + "docs": { + "contents": null + }, + "name": "mfile" + }, + { + "docs": { + "contents": null + }, + "name": "mlink" + }, + { + "docs": { + "contents": null + }, + "name": "msgsize" + }, + { + "docs": { + "contents": null + }, + "name": "multihop" + }, + { + "docs": { + "contents": null + }, + "name": "nametoolong" + }, + { + "docs": { + "contents": null + }, + "name": "netdown" + }, + { + "docs": { + "contents": null + }, + "name": "netreset" + }, + { + "docs": { + "contents": null + }, + "name": "netunreach" + }, + { + "docs": { + "contents": null + }, + "name": "nfile" + }, + { + "docs": { + "contents": null + }, + "name": "nobufs" + }, + { + "docs": { + "contents": null + }, + "name": "nodev" + }, + { + "docs": { + "contents": null + }, + "name": "noent" + }, + { + "docs": { + "contents": null + }, + "name": "noexec" + }, + { + "docs": { + "contents": null + }, + "name": "nolck" + }, + { + "docs": { + "contents": null + }, + "name": "nolink" + }, + { + "docs": { + "contents": null + }, + "name": "nomem" + }, + { + "docs": { + "contents": null + }, + "name": "nomsg" + }, + { + "docs": { + "contents": null + }, + "name": "noprotoopt" + }, + { + "docs": { + "contents": null + }, + "name": "nospc" + }, + { + "docs": { + "contents": null + }, + "name": "nosys" + }, + { + "docs": { + "contents": null + }, + "name": "notconn" + }, + { + "docs": { + "contents": null + }, + "name": "notdir" + }, + { + "docs": { + "contents": null + }, + "name": "notempty" + }, + { + "docs": { + "contents": null + }, + "name": "notrecoverable" + }, + { + "docs": { + "contents": null + }, + "name": "notsock" + }, + { + "docs": { + "contents": null + }, + "name": "notsup" + }, + { + "docs": { + "contents": null + }, + "name": "notty" + }, + { + "docs": { + "contents": null + }, + "name": "nxio" + }, + { + "docs": { + "contents": null + }, + "name": "overflow" + }, + { + "docs": { + "contents": null + }, + "name": "ownerdead" + }, + { + "docs": { + "contents": null + }, + "name": "perm" + }, + { + "docs": { + "contents": null + }, + "name": "pipe" + }, + { + "docs": { + "contents": null + }, + "name": "proto" + }, + { + "docs": { + "contents": null + }, + "name": "protonosupport" + }, + { + "docs": { + "contents": null + }, + "name": "prototype" + }, + { + "docs": { + "contents": null + }, + "name": "range" + }, + { + "docs": { + "contents": null + }, + "name": "rofs" + }, + { + "docs": { + "contents": null + }, + "name": "spipe" + }, + { + "docs": { + "contents": null + }, + "name": "srch" + }, + { + "docs": { + "contents": null + }, + "name": "stale" + }, + { + "docs": { + "contents": null + }, + "name": "timedout" + }, + { + "docs": { + "contents": null + }, + "name": "txtbsy" + }, + { + "docs": { + "contents": null + }, + "name": "xdev" + }, + { + "docs": { + "contents": null + }, + "name": "notcapable" + } + ] + } + }, + "name": "errno", + "owner": { + "interface": 0 + } + } + ], + "packages": [ + { + "name": "wasi:filesystem", + "docs": { + "contents": null + }, + "interfaces": { + "wasi": 0 + }, + "worlds": {} + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/world-diamond.wit.json b/crates/wit-parser/tests/ui/world-diamond.wit.json new file mode 100644 index 0000000000..c87c6e6a0e --- /dev/null +++ b/crates/wit-parser/tests/ui/world-diamond.wit.json @@ -0,0 +1,151 @@ +{ + "worlds": [ + { + "name": "the-world", + "docs": { + "contents": null + }, + "imports": { + "interface-0": { + "interface": 0 + }, + "interface-1": { + "interface": 1 + }, + "interface-2": { + "interface": 2 + }, + "a": { + "function": { + "docs": { + "contents": null + }, + "name": "a", + "kind": "freestanding", + "params": [], + "results": [] + } + } + }, + "exports": {}, + "package": 0 + } + ], + "interfaces": [ + { + "name": "shared-items", + "docs": { + "contents": null + }, + "types": { + "foo": 0 + }, + "functions": {}, + "package": 0 + }, + { + "name": "i1", + "docs": { + "contents": null + }, + "types": { + "foo": 1 + }, + "functions": { + "a": { + "docs": { + "contents": null + }, + "name": "a", + "kind": "freestanding", + "params": [], + "results": [ + { + "type": 1 + } + ] + } + }, + "package": 0 + }, + { + "name": "i2", + "docs": { + "contents": null + }, + "types": { + "foo": 2 + }, + "functions": { + "a": { + "docs": { + "contents": null + }, + "name": "a", + "kind": "freestanding", + "params": [], + "results": [ + { + "type": 2 + } + ] + } + }, + "package": 0 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "foo", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 0 + }, + "name": "foo", + "owner": { + "interface": 1 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 0 + }, + "name": "foo", + "owner": { + "interface": 2 + } + } + ], + "packages": [ + { + "name": "foo:foo", + "docs": { + "contents": null + }, + "interfaces": { + "shared-items": 0, + "i1": 1, + "i2": 2 + }, + "worlds": { + "the-world": 0 + } + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/world-iface-no-collide.wit.json b/crates/wit-parser/tests/ui/world-iface-no-collide.wit.json new file mode 100644 index 0000000000..5ad69d83ae --- /dev/null +++ b/crates/wit-parser/tests/ui/world-iface-no-collide.wit.json @@ -0,0 +1,84 @@ +{ + "worlds": [ + { + "name": "bar", + "docs": { + "contents": null + }, + "imports": { + "interface-0": { + "interface": 0 + }, + "t": { + "type": 1 + }, + "foo": { + "function": { + "docs": { + "contents": null + }, + "name": "foo", + "kind": "freestanding", + "params": [], + "results": [] + } + } + }, + "exports": {}, + "package": 0 + } + ], + "interfaces": [ + { + "name": "foo", + "docs": { + "contents": null + }, + "types": { + "t": 0 + }, + "functions": {}, + "package": 0 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "t", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 0 + }, + "name": "t", + "owner": { + "world": 0 + } + } + ], + "packages": [ + { + "name": "foo:foo", + "docs": { + "contents": null + }, + "interfaces": { + "foo": 0 + }, + "worlds": { + "bar": 0 + } + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/world-implicit-import1.wit.json b/crates/wit-parser/tests/ui/world-implicit-import1.wit.json new file mode 100644 index 0000000000..50eb58b252 --- /dev/null +++ b/crates/wit-parser/tests/ui/world-implicit-import1.wit.json @@ -0,0 +1,96 @@ +{ + "worlds": [ + { + "name": "the-world", + "docs": { + "contents": null + }, + "imports": { + "interface-0": { + "interface": 0 + }, + "bar": { + "interface": 1 + }, + "foo": { + "interface": 2 + } + }, + "exports": {}, + "package": 0 + } + ], + "interfaces": [ + { + "name": "foo", + "docs": { + "contents": null + }, + "types": { + "a": 0 + }, + "functions": {}, + "package": 0 + }, + { + "name": null, + "docs": { + "contents": null + }, + "types": { + "a": 1 + }, + "functions": {}, + "package": 0 + }, + { + "name": null, + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 0 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "a", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 0 + }, + "name": "a", + "owner": { + "interface": 1 + } + } + ], + "packages": [ + { + "name": "foo:foo", + "docs": { + "contents": null + }, + "interfaces": { + "foo": 0 + }, + "worlds": { + "the-world": 0 + } + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/world-implicit-import2.wit.json b/crates/wit-parser/tests/ui/world-implicit-import2.wit.json new file mode 100644 index 0000000000..d675126eb3 --- /dev/null +++ b/crates/wit-parser/tests/ui/world-implicit-import2.wit.json @@ -0,0 +1,88 @@ +{ + "worlds": [ + { + "name": "w", + "docs": { + "contents": null + }, + "imports": { + "interface-0": { + "interface": 0 + }, + "g": { + "type": 1 + }, + "foo": { + "function": { + "docs": { + "contents": null + }, + "name": "foo", + "kind": "freestanding", + "params": [], + "results": [ + { + "type": 1 + } + ] + } + } + }, + "exports": {}, + "package": 0 + } + ], + "interfaces": [ + { + "name": "foo", + "docs": { + "contents": null + }, + "types": { + "g": 0 + }, + "functions": {}, + "package": 0 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": { + "type": "char" + }, + "name": "g", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 0 + }, + "name": "g", + "owner": { + "world": 0 + } + } + ], + "packages": [ + { + "name": "foo:foo", + "docs": { + "contents": null + }, + "interfaces": { + "foo": 0 + }, + "worlds": { + "w": 0 + } + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/world-implicit-import3.wit.json b/crates/wit-parser/tests/ui/world-implicit-import3.wit.json new file mode 100644 index 0000000000..450a23af04 --- /dev/null +++ b/crates/wit-parser/tests/ui/world-implicit-import3.wit.json @@ -0,0 +1,89 @@ +{ + "worlds": [ + { + "name": "w", + "docs": { + "contents": null + }, + "imports": { + "interface-0": { + "interface": 0 + }, + "g": { + "type": 1 + } + }, + "exports": { + "foo": { + "function": { + "docs": { + "contents": null + }, + "name": "foo", + "kind": "freestanding", + "params": [], + "results": [ + { + "type": 1 + } + ] + } + } + }, + "package": 0 + } + ], + "interfaces": [ + { + "name": "foo", + "docs": { + "contents": null + }, + "types": { + "g": 0 + }, + "functions": {}, + "package": 0 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": { + "type": "char" + }, + "name": "g", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 0 + }, + "name": "g", + "owner": { + "world": 0 + } + } + ], + "packages": [ + { + "name": "foo:foo", + "docs": { + "contents": null + }, + "interfaces": { + "foo": 0 + }, + "worlds": { + "w": 0 + } + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/world-same-fields4.wit.json b/crates/wit-parser/tests/ui/world-same-fields4.wit.json new file mode 100644 index 0000000000..c156687a70 --- /dev/null +++ b/crates/wit-parser/tests/ui/world-same-fields4.wit.json @@ -0,0 +1,97 @@ +{ + "worlds": [ + { + "name": "foo", + "docs": { + "contents": null + }, + "imports": { + "shared-items": { + "interface": 1 + }, + "interface-0": { + "interface": 0 + } + }, + "exports": { + "a-name": { + "interface": 2 + } + }, + "package": 0 + } + ], + "interfaces": [ + { + "name": "shared-items", + "docs": { + "contents": null + }, + "types": { + "a": 0 + }, + "functions": {}, + "package": 0 + }, + { + "name": null, + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 0 + }, + { + "name": null, + "docs": { + "contents": null + }, + "types": { + "a": 1 + }, + "functions": {}, + "package": 0 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "a", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 0 + }, + "name": "a", + "owner": { + "interface": 2 + } + } + ], + "packages": [ + { + "name": "foo:foo", + "docs": { + "contents": null + }, + "interfaces": { + "shared-items": 0 + }, + "worlds": { + "foo": 0 + } + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/world-top-level-funcs.wit.json b/crates/wit-parser/tests/ui/world-top-level-funcs.wit.json new file mode 100644 index 0000000000..c694982f0c --- /dev/null +++ b/crates/wit-parser/tests/ui/world-top-level-funcs.wit.json @@ -0,0 +1,113 @@ +{ + "worlds": [ + { + "name": "foo", + "docs": { + "contents": null + }, + "imports": { + "foo": { + "function": { + "docs": { + "contents": null + }, + "name": "foo", + "kind": "freestanding", + "params": [], + "results": [] + } + }, + "bar": { + "function": { + "docs": { + "contents": null + }, + "name": "bar", + "kind": "freestanding", + "params": [ + { + "name": "arg", + "type": 0 + } + ], + "results": [] + } + } + }, + "exports": { + "foo2": { + "function": { + "docs": { + "contents": null + }, + "name": "foo2", + "kind": "freestanding", + "params": [], + "results": [] + } + }, + "some-name": { + "function": { + "docs": { + "contents": null + }, + "name": "some-name", + "kind": "freestanding", + "params": [], + "results": [ + { + "type": 2 + } + ] + } + } + }, + "package": 0 + } + ], + "interfaces": [], + "types": [ + { + "docs": { + "contents": null + }, + "kind": { + "list": "u32" + }, + "name": null, + "owner": "none" + }, + { + "docs": { + "contents": null + }, + "kind": { + "option": "u32" + }, + "name": null, + "owner": "none" + }, + { + "docs": { + "contents": null + }, + "kind": { + "list": 1 + }, + "name": null, + "owner": "none" + } + ], + "packages": [ + { + "name": "foo:foo", + "docs": { + "contents": null + }, + "interfaces": {}, + "worlds": { + "foo": 0 + } + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/world-top-level-resources.wit.json b/crates/wit-parser/tests/ui/world-top-level-resources.wit.json new file mode 100644 index 0000000000..58d19b03e5 --- /dev/null +++ b/crates/wit-parser/tests/ui/world-top-level-resources.wit.json @@ -0,0 +1,303 @@ +{ + "worlds": [ + { + "name": "proxy", + "docs": { + "contents": null + }, + "imports": { + "interface-0": { + "interface": 0 + }, + "interface-1": { + "interface": 1 + } + }, + "exports": { + "interface-1": { + "interface": 1 + } + }, + "package": 0 + } + ], + "interfaces": [ + { + "name": "types", + "docs": { + "contents": null + }, + "types": { + "request": 0, + "response": 1 + }, + "functions": { + "[method]request.foo": { + "docs": { + "contents": null + }, + "name": "[method]request.foo", + "kind": { + "method": 0 + }, + "params": [ + { + "name": "self", + "type": 2 + } + ], + "results": [] + }, + "[method]request.bar": { + "docs": { + "contents": null + }, + "name": "[method]request.bar", + "kind": { + "method": 0 + }, + "params": [ + { + "name": "self", + "type": 2 + }, + { + "name": "arg", + "type": 3 + } + ], + "results": [] + }, + "[method]response.foo": { + "docs": { + "contents": null + }, + "name": "[method]response.foo", + "kind": { + "method": 1 + }, + "params": [ + { + "name": "self", + "type": 4 + } + ], + "results": [] + }, + "[method]response.bar": { + "docs": { + "contents": null + }, + "name": "[method]response.bar", + "kind": { + "method": 1 + }, + "params": [ + { + "name": "self", + "type": 4 + }, + { + "name": "arg", + "type": 3 + } + ], + "results": [] + } + }, + "package": 0 + }, + { + "name": "handler", + "docs": { + "contents": null + }, + "types": { + "request": 5, + "response": 6 + }, + "functions": { + "handle": { + "docs": { + "contents": null + }, + "name": "handle", + "kind": "freestanding", + "params": [ + { + "name": "some", + "type": 7 + } + ], + "results": [ + { + "type": 8 + } + ] + }, + "handle-owned": { + "docs": { + "contents": null + }, + "name": "handle-owned", + "kind": "freestanding", + "params": [ + { + "name": "some", + "type": 9 + } + ], + "results": [ + { + "type": 10 + } + ] + } + }, + "package": 0 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": "resource", + "name": "request", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": "resource", + "name": "response", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "borrow": 0 + } + }, + "name": null, + "owner": "none" + }, + { + "docs": { + "contents": null + }, + "kind": { + "list": "u32" + }, + "name": null, + "owner": "none" + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "borrow": 1 + } + }, + "name": null, + "owner": "none" + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 0 + }, + "name": "request", + "owner": { + "interface": 1 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 1 + }, + "name": "response", + "owner": { + "interface": 1 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "borrow": 5 + } + }, + "name": null, + "owner": "none" + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "borrow": 6 + } + }, + "name": null, + "owner": "none" + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "own": 5 + } + }, + "name": null, + "owner": "none" + }, + { + "docs": { + "contents": null + }, + "kind": { + "handle": { + "own": 6 + } + }, + "name": null, + "owner": "none" + } + ], + "packages": [ + { + "name": "foo:foo", + "docs": { + "contents": null + }, + "interfaces": { + "types": 0, + "handler": 1 + }, + "worlds": { + "proxy": 0 + } + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/worlds-union-dedup.wit.json b/crates/wit-parser/tests/ui/worlds-union-dedup.wit.json new file mode 100644 index 0000000000..75e4dba0f2 --- /dev/null +++ b/crates/wit-parser/tests/ui/worlds-union-dedup.wit.json @@ -0,0 +1,130 @@ +{ + "worlds": [ + { + "name": "my-world-a", + "docs": { + "contents": null + }, + "imports": { + "interface-0": { + "interface": 0 + }, + "interface-2": { + "interface": 2 + } + }, + "exports": {}, + "package": 0 + }, + { + "name": "my-world-b", + "docs": { + "contents": null + }, + "imports": { + "interface-0": { + "interface": 0 + }, + "interface-2": { + "interface": 2 + } + }, + "exports": {}, + "package": 0 + }, + { + "name": "union-my-world", + "docs": { + "contents": null + }, + "imports": { + "interface-0": { + "interface": 0 + }, + "interface-2": { + "interface": 2 + } + }, + "exports": {}, + "package": 0 + } + ], + "interfaces": [ + { + "name": "a1", + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 0 + }, + { + "name": "a2", + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 0 + }, + { + "name": "b1", + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 0 + }, + { + "name": "b2", + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 0 + }, + { + "name": "c", + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 0 + }, + { + "name": "d", + "docs": { + "contents": null + }, + "types": {}, + "functions": {}, + "package": 0 + } + ], + "types": [], + "packages": [ + { + "name": "foo:foo", + "docs": { + "contents": null + }, + "interfaces": { + "a1": 0, + "a2": 1, + "b1": 2, + "b2": 3, + "c": 4, + "d": 5 + }, + "worlds": { + "my-world-a": 0, + "my-world-b": 1, + "union-my-world": 2 + } + } + ] +} \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/worlds-with-types.wit.json b/crates/wit-parser/tests/ui/worlds-with-types.wit.json new file mode 100644 index 0000000000..cb0e0ab70c --- /dev/null +++ b/crates/wit-parser/tests/ui/worlds-with-types.wit.json @@ -0,0 +1,253 @@ +{ + "worlds": [ + { + "name": "foo", + "docs": { + "contents": null + }, + "imports": { + "a": { + "type": 1 + }, + "b": { + "type": 2 + } + }, + "exports": { + "c": { + "function": { + "docs": { + "contents": null + }, + "name": "c", + "kind": "freestanding", + "params": [ + { + "name": "a", + "type": 1 + } + ], + "results": [ + { + "type": 2 + } + ] + } + } + }, + "package": 0 + }, + { + "name": "bar", + "docs": { + "contents": null + }, + "imports": { + "interface-0": { + "interface": 0 + }, + "t": { + "type": 3 + } + }, + "exports": { + "foo": { + "function": { + "docs": { + "contents": null + }, + "name": "foo", + "kind": "freestanding", + "params": [], + "results": [ + { + "type": 3 + } + ] + } + } + }, + "package": 0 + }, + { + "name": "the-test", + "docs": { + "contents": null + }, + "imports": { + "a": { + "type": 4 + }, + "b": { + "type": 5 + }, + "foo": { + "function": { + "docs": { + "contents": null + }, + "name": "foo", + "kind": "freestanding", + "params": [ + { + "name": "a", + "type": 4 + } + ], + "results": [ + { + "type": 5 + } + ] + } + } + }, + "exports": { + "bar": { + "function": { + "docs": { + "contents": null + }, + "name": "bar", + "kind": "freestanding", + "params": [ + { + "name": "a", + "type": 4 + } + ], + "results": [ + { + "type": 5 + } + ] + } + } + }, + "package": 0 + } + ], + "interfaces": [ + { + "name": "disambiguate", + "docs": { + "contents": null + }, + "types": { + "t": 0 + }, + "functions": {}, + "package": 0 + } + ], + "types": [ + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "t", + "owner": { + "interface": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": "u32" + }, + "name": "a", + "owner": { + "world": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 1 + }, + "name": "b", + "owner": { + "world": 0 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "type": 0 + }, + "name": "t", + "owner": { + "world": 1 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "record": { + "fields": [ + { + "docs": { + "contents": null + }, + "name": "x", + "type": "u32" + } + ] + } + }, + "name": "a", + "owner": { + "world": 2 + } + }, + { + "docs": { + "contents": null + }, + "kind": { + "variant": { + "cases": [ + { + "docs": { + "contents": null + }, + "name": "c", + "type": 4 + } + ] + } + }, + "name": "b", + "owner": { + "world": 2 + } + } + ], + "packages": [ + { + "name": "foo:foo", + "docs": { + "contents": null + }, + "interfaces": { + "disambiguate": 0 + }, + "worlds": { + "foo": 0, + "bar": 1, + "the-test": 2 + } + } + ] +} \ No newline at end of file From 9bd23094c238ae61c3434166b43b6519087348b9 Mon Sep 17 00:00:00 2001 From: "Jiaxiao Zhou (Mossaka)" Date: Wed, 13 Sep 2023 21:06:31 -0700 Subject: [PATCH 34/40] delete the unit tests in resolve.rs Signed-off-by: Jiaxiao Zhou (Mossaka) --- crates/wit-parser/src/resolve.rs | 180 ------------------------------- crates/wit-parser/tests/all.rs | 9 +- 2 files changed, 7 insertions(+), 182 deletions(-) diff --git a/crates/wit-parser/src/resolve.rs b/crates/wit-parser/src/resolve.rs index afe722aad9..b71b37b766 100644 --- a/crates/wit-parser/src/resolve.rs +++ b/crates/wit-parser/src/resolve.rs @@ -1754,183 +1754,3 @@ impl<'a> MergeMap<'a> { Ok(()) } } - -#[cfg(test)] -mod tests { - use crate::Record; - use anyhow::Result; - - use super::*; - - const EMPTY_RESOLVE: &str = - r#"{ "worlds": [], "interfaces": [], "types": [], "packages": [] }"#; - - const JSON_RESOLVE: &str = r#"{ - "worlds": [ - { - "name": "world1", - "docs": { "contents": null }, - "imports": {}, - "exports": {}, - "package": null - }, - { - "name": "world2", - "docs": { "contents": null }, - "imports": {}, - "exports": {}, - "package": null - } - ], - "interfaces": [ - { - "name": "interface1", - "docs": { "contents": null }, - "types": {}, - "functions": {}, - "package": null - }, - { - "name": "interface2", - "docs": { "contents": null }, - "types": {}, - "functions": {}, - "package": null - } - ], - "types": [ - { - "docs": { "contents": null }, - "kind": { "type": "bool" }, - "name": "type1", - "owner": "none" - }, - { - "docs": { "contents": null }, - "kind": { "record": { "fields": [] } }, - "name": "type2", - "owner": "none" - } - ], - "packages": [ - { - "name": "foo:package1", - "docs": { "contents": null }, - "interfaces": {}, - "worlds": {} - }, - { - "name": "foo:package2", - "docs": { "contents": null }, - "interfaces": {}, - "worlds": {} - } - ] - }"#; - - #[test] - fn serialize_empty_resolve() -> Result<()> { - let resolve = Resolve::default(); - let s = serde_json::to_string(&resolve)?; - let empty_resolve = EMPTY_RESOLVE.replace(" ", "").replace("\n", ""); - assert_eq!(s, empty_resolve); - Ok(()) - } - - #[test] - fn serialize_resolve() -> Result<()> { - let mut worlds: Arena = Arena::new(); - let world1 = World { - name: "world1".to_string(), - docs: Default::default(), - imports: Default::default(), - exports: Default::default(), - includes: Default::default(), - include_names: Default::default(), - package: None, - }; - let world2 = World { - name: "world2".to_string(), - docs: Default::default(), - imports: Default::default(), - exports: Default::default(), - includes: Default::default(), - include_names: Default::default(), - package: None, - }; - worlds.alloc(world1); - worlds.alloc(world2); - - let mut interfaces: Arena = Arena::new(); - let interface1 = Interface { - name: Some("interface1".to_string()), - docs: Default::default(), - types: Default::default(), - functions: Default::default(), - package: None, - }; - let interface2 = Interface { - name: Some("interface2".to_string()), - docs: Default::default(), - types: Default::default(), - functions: Default::default(), - package: None, - }; - interfaces.alloc(interface1); - interfaces.alloc(interface2); - - let mut types: Arena = Arena::new(); - let type1 = TypeDef { - name: Some("type1".to_string()), - owner: TypeOwner::None, - kind: TypeDefKind::Type(Type::Bool), - docs: Default::default(), - }; - let type2 = TypeDef { - name: Some("type2".to_string()), - owner: TypeOwner::None, - kind: TypeDefKind::Record(Record { - fields: Default::default(), - }), - docs: Default::default(), - }; - types.alloc(type1); - types.alloc(type2); - - let mut packages: Arena = Arena::new(); - let package1 = Package { - name: PackageName { - namespace: "foo".into(), - name: "package1".into(), - version: None, - }, - docs: Default::default(), - interfaces: Default::default(), - worlds: Default::default(), - }; - let package2 = Package { - name: PackageName { - namespace: "foo".into(), - name: "package2".into(), - version: None, - }, - docs: Default::default(), - interfaces: Default::default(), - worlds: Default::default(), - }; - packages.alloc(package1); - packages.alloc(package2); - - let resolve = Resolve { - packages, - interfaces, - types, - worlds, - package_names: Default::default(), - }; - let s = serde_json::to_string(&resolve).unwrap(); - let json_resolve = JSON_RESOLVE.replace(" ", "").replace("\n", ""); - assert_eq!(s, json_resolve); - Ok(()) - } -} diff --git a/crates/wit-parser/tests/all.rs b/crates/wit-parser/tests/all.rs index a9395da8ec..c883039121 100644 --- a/crates/wit-parser/tests/all.rs +++ b/crates/wit-parser/tests/all.rs @@ -137,7 +137,12 @@ impl Runner<'_> { return Ok(()); } - fn read_or_write_to_file(&mut self, test: &Path, result: &str, extension: &str) -> Result<(), anyhow::Error> { + fn read_or_write_to_file( + &mut self, + test: &Path, + result: &str, + extension: &str, + ) -> Result<(), anyhow::Error> { let result_file = if test.extension() == Some(OsStr::new("md")) && test .file_stem() @@ -174,4 +179,4 @@ impl Runner<'_> { fn normalize(s: &str) -> String { s.replace('\\', "/").replace("\r\n", "\n") -} \ No newline at end of file +} From 60ccab1cc38088bc5525e9ddd5887790e787c1f4 Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Thu, 14 Sep 2023 10:12:53 -0700 Subject: [PATCH 35/40] wit-parser: remove Serialize from IncludeName PR feedback on wasm-tools#177 --- crates/wit-parser/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/wit-parser/src/lib.rs b/crates/wit-parser/src/lib.rs index df0bbe2cb9..91e946113a 100644 --- a/crates/wit-parser/src/lib.rs +++ b/crates/wit-parser/src/lib.rs @@ -274,7 +274,7 @@ pub struct World { pub include_names: Vec>, } -#[derive(Debug, Clone, Serialize)] +#[derive(Debug, Clone)] pub struct IncludeName { /// The name of the item pub name: String, From 68b52f6ed5cbb7f9bdbe8830426bbabaa0fd6127 Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Thu, 14 Sep 2023 10:22:55 -0700 Subject: [PATCH 36/40] wit-parser: skip serializing Docs if empty PR feedback on wasm-tools#177 --- crates/wit-parser/src/lib.rs | 14 ++++++++++++++ crates/wit-parser/src/resolve.rs | 1 + 2 files changed, 15 insertions(+) diff --git a/crates/wit-parser/src/lib.rs b/crates/wit-parser/src/lib.rs index 91e946113a..30afeab37e 100644 --- a/crates/wit-parser/src/lib.rs +++ b/crates/wit-parser/src/lib.rs @@ -253,6 +253,7 @@ pub struct World { pub name: String, /// Documentation associated with this world declaration. + #[serde(skip_serializing_if = "Docs::is_empty")] pub docs: Docs, /// All imported items into this interface, both worlds and functions. @@ -340,6 +341,7 @@ pub struct Interface { pub name: Option, /// Documentation associated with this interface. + #[serde(skip_serializing_if = "Docs::is_empty")] pub docs: Docs, /// Exported types from this interface. @@ -359,6 +361,7 @@ pub struct Interface { #[derive(Debug, Clone, PartialEq, Serialize)] pub struct TypeDef { + #[serde(skip_serializing_if = "Docs::is_empty")] pub docs: Docs, pub kind: TypeDefKind, pub name: Option, @@ -470,6 +473,7 @@ pub struct Record { #[derive(Debug, Clone, PartialEq, Serialize)] pub struct Field { + #[serde(skip_serializing_if = "Docs::is_empty")] pub docs: Docs, pub name: String, #[serde(rename = "type")] @@ -483,6 +487,7 @@ pub struct Flags { #[derive(Debug, Clone, PartialEq, Serialize)] pub struct Flag { + #[serde(skip_serializing_if = "Docs::is_empty")] pub docs: Docs, pub name: String, } @@ -527,6 +532,7 @@ pub struct Variant { #[derive(Debug, Clone, PartialEq, Serialize)] pub struct Case { + #[serde(skip_serializing_if = "Docs::is_empty")] pub docs: Docs, pub name: String, #[serde(rename = "type")] @@ -551,6 +557,7 @@ pub struct Enum { #[derive(Debug, Clone, PartialEq, Serialize)] pub struct EnumCase { + #[serde(skip_serializing_if = "Docs::is_empty")] pub docs: Docs, pub name: String, } @@ -583,6 +590,12 @@ pub struct Docs { pub contents: Option, } +impl Docs { + pub fn is_empty(&self) -> bool { + self.contents.is_none() + } +} + pub type Params = Vec<(String, Type)>; #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize)] @@ -655,6 +668,7 @@ impl Results { #[derive(Debug, Clone, PartialEq, Eq, Serialize)] pub struct Function { + #[serde(skip_serializing_if = "Docs::is_empty")] pub docs: Docs, pub name: String, pub kind: FunctionKind, diff --git a/crates/wit-parser/src/resolve.rs b/crates/wit-parser/src/resolve.rs index b71b37b766..2bd16e583a 100644 --- a/crates/wit-parser/src/resolve.rs +++ b/crates/wit-parser/src/resolve.rs @@ -52,6 +52,7 @@ pub struct Package { pub name: PackageName, /// Documentation associated with this package. + #[serde(skip_serializing_if = "Docs::is_empty")] pub docs: Docs, /// All interfaces contained in this packaged, keyed by the interface's From fdfd7cc35356547fd42a84904b46c6923b45ba96 Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Thu, 14 Sep 2023 10:23:43 -0700 Subject: [PATCH 37/40] wit-parser: commit blessed JSON output with empty Docs skipped --- crates/wit-parser/tests/ui/comments.wit.json | 12 - .../tests/ui/complex-include.wit.json | 45 --- .../tests/ui/cross-package-resource.wit.json | 21 -- crates/wit-parser/tests/ui/diamond1.wit.json | 18 - .../tests/ui/disambiguate-diamond.wit.json | 30 -- .../wit-parser/tests/ui/embedded.wit.md.json | 15 - crates/wit-parser/tests/ui/empty.wit.json | 3 - .../tests/ui/foreign-deps-union.wit.json | 117 ------ .../wit-parser/tests/ui/foreign-deps.wit.json | 111 ------ crates/wit-parser/tests/ui/functions.wit.json | 45 --- .../tests/ui/ignore-files-deps.wit.json | 12 - .../wit-parser/tests/ui/include-reps.wit.json | 15 - .../tests/ui/kebab-name-include-with.wit.json | 24 -- .../wit-parser/tests/ui/many-names.wit.json | 12 - .../wit-parser/tests/ui/multi-file.wit.json | 90 ----- .../ui/name-both-resource-and-type.wit.json | 27 -- .../tests/ui/package-syntax1.wit.json | 3 - .../tests/ui/package-syntax3.wit.json | 3 - .../tests/ui/package-syntax4.wit.json | 3 - .../tests/ui/resources-empty.wit.json | 21 -- ...resources-multiple-returns-borrow.wit.json | 18 - .../resources-multiple-returns-own.wit.json | 21 -- .../tests/ui/resources-multiple.wit.json | 60 ---- .../tests/ui/resources-return-borrow.wit.json | 18 - .../tests/ui/resources-return-own.wit.json | 21 -- crates/wit-parser/tests/ui/resources.wit.json | 93 ----- .../wit-parser/tests/ui/resources1.wit.json | 27 -- .../wit-parser/tests/ui/shared-types.wit.json | 24 -- .../tests/ui/stress-export-elaborate.wit.json | 336 ------------------ .../tests/ui/type-then-eof.wit.json | 9 - crates/wit-parser/tests/ui/types.wit.json | 255 ------------- .../wit-parser/tests/ui/union-fuzz-1.wit.json | 12 - crates/wit-parser/tests/ui/use-chain.wit.json | 15 - crates/wit-parser/tests/ui/use.wit.json | 54 --- crates/wit-parser/tests/ui/versions.wit.json | 30 -- crates/wit-parser/tests/ui/wasi.wit.json | 252 ------------- .../tests/ui/world-diamond.wit.json | 33 -- .../tests/ui/world-iface-no-collide.wit.json | 18 - .../tests/ui/world-implicit-import1.wit.json | 21 -- .../tests/ui/world-implicit-import2.wit.json | 18 - .../tests/ui/world-implicit-import3.wit.json | 18 - .../tests/ui/world-same-fields4.wit.json | 21 -- .../tests/ui/world-top-level-funcs.wit.json | 27 -- .../ui/world-top-level-resources.wit.json | 63 ---- .../tests/ui/worlds-union-dedup.wit.json | 30 -- .../tests/ui/worlds-with-types.wit.json | 51 --- 46 files changed, 2172 deletions(-) diff --git a/crates/wit-parser/tests/ui/comments.wit.json b/crates/wit-parser/tests/ui/comments.wit.json index e41ad846f4..bd49b9432f 100644 --- a/crates/wit-parser/tests/ui/comments.wit.json +++ b/crates/wit-parser/tests/ui/comments.wit.json @@ -3,9 +3,6 @@ "interfaces": [ { "name": "foo", - "docs": { - "contents": null - }, "types": { "x": 0, "bar": 1 @@ -16,9 +13,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -28,9 +22,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "stream": { "element": 0, @@ -46,9 +37,6 @@ "packages": [ { "name": "foo:comments", - "docs": { - "contents": null - }, "interfaces": { "foo": 0 }, diff --git a/crates/wit-parser/tests/ui/complex-include.wit.json b/crates/wit-parser/tests/ui/complex-include.wit.json index 54e6d5d71d..2c657bea8b 100644 --- a/crates/wit-parser/tests/ui/complex-include.wit.json +++ b/crates/wit-parser/tests/ui/complex-include.wit.json @@ -2,9 +2,6 @@ "worlds": [ { "name": "bar-a", - "docs": { - "contents": null - }, "imports": { "interface-0": { "interface": 0 @@ -18,9 +15,6 @@ }, { "name": "baz-a", - "docs": { - "contents": null - }, "imports": { "interface-2": { "interface": 2 @@ -34,9 +28,6 @@ }, { "name": "a", - "docs": { - "contents": null - }, "imports": { "interface-4": { "interface": 4 @@ -50,9 +41,6 @@ }, { "name": "b", - "docs": { - "contents": null - }, "imports": { "interface-0": { "interface": 0 @@ -66,9 +54,6 @@ }, { "name": "c", - "docs": { - "contents": null - }, "imports": { "interface-0": { "interface": 0 @@ -82,9 +67,6 @@ }, { "name": "union-world", - "docs": { - "contents": null - }, "imports": { "interface-4": { "interface": 4 @@ -112,54 +94,36 @@ "interfaces": [ { "name": "a", - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 0 }, { "name": "b", - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 0 }, { "name": "a", - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 1 }, { "name": "b", - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 1 }, { "name": "ai", - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 2 }, { "name": "bi", - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 2 @@ -169,9 +133,6 @@ "packages": [ { "name": "foo:bar", - "docs": { - "contents": null - }, "interfaces": { "a": 0, "b": 1 @@ -182,9 +143,6 @@ }, { "name": "foo:baz", - "docs": { - "contents": null - }, "interfaces": { "a": 2, "b": 3 @@ -195,9 +153,6 @@ }, { "name": "foo:root", - "docs": { - "contents": null - }, "interfaces": { "ai": 4, "bi": 5 diff --git a/crates/wit-parser/tests/ui/cross-package-resource.wit.json b/crates/wit-parser/tests/ui/cross-package-resource.wit.json index ee8f63584e..437bc014cf 100644 --- a/crates/wit-parser/tests/ui/cross-package-resource.wit.json +++ b/crates/wit-parser/tests/ui/cross-package-resource.wit.json @@ -3,9 +3,6 @@ "interfaces": [ { "name": "foo", - "docs": { - "contents": null - }, "types": { "r": 0 }, @@ -14,9 +11,6 @@ }, { "name": "foo", - "docs": { - "contents": null - }, "types": { "r": 1, "t": 2 @@ -27,9 +21,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": "resource", "name": "r", "owner": { @@ -37,9 +28,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 0 }, @@ -49,9 +37,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "handle": { "own": 1 @@ -66,9 +51,6 @@ "packages": [ { "name": "some:dep", - "docs": { - "contents": null - }, "interfaces": { "foo": 0 }, @@ -76,9 +58,6 @@ }, { "name": "foo:bar", - "docs": { - "contents": null - }, "interfaces": { "foo": 1 }, diff --git a/crates/wit-parser/tests/ui/diamond1.wit.json b/crates/wit-parser/tests/ui/diamond1.wit.json index 64d18c76f8..8d7ce082ea 100644 --- a/crates/wit-parser/tests/ui/diamond1.wit.json +++ b/crates/wit-parser/tests/ui/diamond1.wit.json @@ -2,9 +2,6 @@ "worlds": [ { "name": "foo", - "docs": { - "contents": null - }, "imports": { "interface-0": { "interface": 0 @@ -20,18 +17,12 @@ "interfaces": [ { "name": "types", - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 0 }, { "name": "types", - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 1 @@ -41,9 +32,6 @@ "packages": [ { "name": "foo:dep1", - "docs": { - "contents": null - }, "interfaces": { "types": 0 }, @@ -51,9 +39,6 @@ }, { "name": "foo:dep2", - "docs": { - "contents": null - }, "interfaces": { "types": 1 }, @@ -61,9 +46,6 @@ }, { "name": "foo:foo", - "docs": { - "contents": null - }, "interfaces": {}, "worlds": { "foo": 0 diff --git a/crates/wit-parser/tests/ui/disambiguate-diamond.wit.json b/crates/wit-parser/tests/ui/disambiguate-diamond.wit.json index 237081a0d6..c3d2a8e183 100644 --- a/crates/wit-parser/tests/ui/disambiguate-diamond.wit.json +++ b/crates/wit-parser/tests/ui/disambiguate-diamond.wit.json @@ -2,9 +2,6 @@ "worlds": [ { "name": "foo", - "docs": { - "contents": null - }, "imports": { "interface-0": { "interface": 0 @@ -26,9 +23,6 @@ "interfaces": [ { "name": "shared1", - "docs": { - "contents": null - }, "types": { "the-type": 0 }, @@ -37,9 +31,6 @@ }, { "name": "shared2", - "docs": { - "contents": null - }, "types": { "the-type": 1 }, @@ -48,9 +39,6 @@ }, { "name": null, - "docs": { - "contents": null - }, "types": { "the-type": 2 }, @@ -59,9 +47,6 @@ }, { "name": null, - "docs": { - "contents": null - }, "types": { "the-type": 3 }, @@ -71,9 +56,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -83,9 +65,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -95,9 +74,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 0 }, @@ -107,9 +83,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 1 }, @@ -122,9 +95,6 @@ "packages": [ { "name": "foo:diamond", - "docs": { - "contents": null - }, "interfaces": { "shared1": 0, "shared2": 1 diff --git a/crates/wit-parser/tests/ui/embedded.wit.md.json b/crates/wit-parser/tests/ui/embedded.wit.md.json index 76896ee1dd..83a2a44afa 100644 --- a/crates/wit-parser/tests/ui/embedded.wit.md.json +++ b/crates/wit-parser/tests/ui/embedded.wit.md.json @@ -3,33 +3,21 @@ "interfaces": [ { "name": "foo", - "docs": { - "contents": null - }, "types": {}, "functions": { "x": { - "docs": { - "contents": null - }, "name": "x", "kind": "freestanding", "params": [], "results": [] }, "y": { - "docs": { - "contents": null - }, "name": "y", "kind": "freestanding", "params": [], "results": [] }, "z": { - "docs": { - "contents": null - }, "name": "z", "kind": "freestanding", "params": [], @@ -43,9 +31,6 @@ "packages": [ { "name": "foo:foo", - "docs": { - "contents": null - }, "interfaces": { "foo": 0 }, diff --git a/crates/wit-parser/tests/ui/empty.wit.json b/crates/wit-parser/tests/ui/empty.wit.json index 703caa711d..092abe5e1d 100644 --- a/crates/wit-parser/tests/ui/empty.wit.json +++ b/crates/wit-parser/tests/ui/empty.wit.json @@ -5,9 +5,6 @@ "packages": [ { "name": "foo:empty", - "docs": { - "contents": null - }, "interfaces": {}, "worlds": {} } diff --git a/crates/wit-parser/tests/ui/foreign-deps-union.wit.json b/crates/wit-parser/tests/ui/foreign-deps-union.wit.json index 7525e05b45..6a7cd7f1f2 100644 --- a/crates/wit-parser/tests/ui/foreign-deps-union.wit.json +++ b/crates/wit-parser/tests/ui/foreign-deps-union.wit.json @@ -2,9 +2,6 @@ "worlds": [ { "name": "wasi", - "docs": { - "contents": null - }, "imports": { "interface-8": { "interface": 8 @@ -18,9 +15,6 @@ }, { "name": "my-world", - "docs": { - "contents": null - }, "imports": { "interface-8": { "interface": 8 @@ -38,9 +32,6 @@ }, { "name": "my-world2", - "docs": { - "contents": null - }, "imports": { "interface-8": { "interface": 8 @@ -61,9 +52,6 @@ }, { "name": "bars-world", - "docs": { - "contents": null - }, "imports": { "interface-4": { "interface": 4 @@ -77,9 +65,6 @@ }, { "name": "unionw-world", - "docs": { - "contents": null - }, "imports": { "interface-8": { "interface": 8 @@ -102,36 +87,24 @@ "interfaces": [ { "name": "other-interface", - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 0 }, { "name": "saas", - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 1 }, { "name": "i", - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 2 }, { "name": "the-default", - "docs": { - "contents": null - }, "types": { "some-type": 0 }, @@ -140,9 +113,6 @@ }, { "name": "the-default", - "docs": { - "contents": null - }, "types": { "from-default": 1 }, @@ -151,9 +121,6 @@ }, { "name": "some-interface", - "docs": { - "contents": null - }, "types": { "another-type": 2 }, @@ -162,9 +129,6 @@ }, { "name": "another-interface", - "docs": { - "contents": null - }, "types": { "yet-another-type": 3 }, @@ -173,9 +137,6 @@ }, { "name": "clocks", - "docs": { - "contents": null - }, "types": { "timestamp": 4 }, @@ -184,9 +145,6 @@ }, { "name": "filesystem", - "docs": { - "contents": null - }, "types": { "stat": 5 }, @@ -195,9 +153,6 @@ }, { "name": "foo", - "docs": { - "contents": null - }, "types": { "timestamp": 6, "stat": 7 @@ -207,9 +162,6 @@ }, { "name": "bar", - "docs": { - "contents": null - }, "types": { "from-default": 8, "another-type": 9, @@ -220,9 +172,6 @@ }, { "name": "use1", - "docs": { - "contents": null - }, "types": { "some-type": 11 }, @@ -231,9 +180,6 @@ }, { "name": "use2", - "docs": { - "contents": null - }, "types": { "some-type": 12 }, @@ -243,9 +189,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -255,9 +198,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "string" }, @@ -267,9 +207,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -279,9 +216,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "u8" }, @@ -291,9 +225,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "u64" }, @@ -303,16 +234,10 @@ } }, { - "docs": { - "contents": null - }, "kind": { "record": { "fields": [ { - "docs": { - "contents": null - }, "name": "ino", "type": "u64" } @@ -325,9 +250,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 4 }, @@ -337,9 +259,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 5 }, @@ -349,9 +268,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 1 }, @@ -361,9 +277,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 2 }, @@ -373,9 +286,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 3 }, @@ -385,9 +295,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 0 }, @@ -397,9 +304,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 0 }, @@ -412,9 +316,6 @@ "packages": [ { "name": "foo:another-pkg", - "docs": { - "contents": null - }, "interfaces": { "other-interface": 0 }, @@ -422,9 +323,6 @@ }, { "name": "foo:corp", - "docs": { - "contents": null - }, "interfaces": { "saas": 1 }, @@ -432,9 +330,6 @@ }, { "name": "foo:different-pkg", - "docs": { - "contents": null - }, "interfaces": { "i": 2 }, @@ -442,9 +337,6 @@ }, { "name": "foo:foreign-pkg", - "docs": { - "contents": null - }, "interfaces": { "the-default": 3 }, @@ -452,9 +344,6 @@ }, { "name": "foo:some-pkg", - "docs": { - "contents": null - }, "interfaces": { "the-default": 4, "some-interface": 5, @@ -464,9 +353,6 @@ }, { "name": "foo:wasi", - "docs": { - "contents": null - }, "interfaces": { "clocks": 7, "filesystem": 8 @@ -477,9 +363,6 @@ }, { "name": "foo:root", - "docs": { - "contents": null - }, "interfaces": { "foo": 9, "bar": 10, diff --git a/crates/wit-parser/tests/ui/foreign-deps.wit.json b/crates/wit-parser/tests/ui/foreign-deps.wit.json index 24298fde6b..d75bd5add0 100644 --- a/crates/wit-parser/tests/ui/foreign-deps.wit.json +++ b/crates/wit-parser/tests/ui/foreign-deps.wit.json @@ -2,9 +2,6 @@ "worlds": [ { "name": "my-world", - "docs": { - "contents": null - }, "imports": { "interface-8": { "interface": 8 @@ -22,9 +19,6 @@ }, { "name": "my-world2", - "docs": { - "contents": null - }, "imports": { "interface-8": { "interface": 8 @@ -45,9 +39,6 @@ }, { "name": "bars-world", - "docs": { - "contents": null - }, "imports": { "interface-4": { "interface": 4 @@ -63,36 +54,24 @@ "interfaces": [ { "name": "other-interface", - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 0 }, { "name": "saas", - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 1 }, { "name": "i", - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 2 }, { "name": "the-default", - "docs": { - "contents": null - }, "types": { "some-type": 0 }, @@ -101,9 +80,6 @@ }, { "name": "the-default", - "docs": { - "contents": null - }, "types": { "from-default": 1 }, @@ -112,9 +88,6 @@ }, { "name": "some-interface", - "docs": { - "contents": null - }, "types": { "another-type": 2 }, @@ -123,9 +96,6 @@ }, { "name": "another-interface", - "docs": { - "contents": null - }, "types": { "yet-another-type": 3 }, @@ -134,9 +104,6 @@ }, { "name": "clocks", - "docs": { - "contents": null - }, "types": { "timestamp": 4 }, @@ -145,9 +112,6 @@ }, { "name": "filesystem", - "docs": { - "contents": null - }, "types": { "stat": 5 }, @@ -156,9 +120,6 @@ }, { "name": "foo", - "docs": { - "contents": null - }, "types": { "timestamp": 6, "stat": 7 @@ -168,9 +129,6 @@ }, { "name": "bar", - "docs": { - "contents": null - }, "types": { "from-default": 8, "another-type": 9, @@ -181,9 +139,6 @@ }, { "name": "use1", - "docs": { - "contents": null - }, "types": { "some-type": 11 }, @@ -192,9 +147,6 @@ }, { "name": "use2", - "docs": { - "contents": null - }, "types": { "some-type": 12 }, @@ -204,9 +156,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -216,9 +165,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "string" }, @@ -228,9 +174,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -240,9 +183,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "u8" }, @@ -252,9 +192,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "u64" }, @@ -264,16 +201,10 @@ } }, { - "docs": { - "contents": null - }, "kind": { "record": { "fields": [ { - "docs": { - "contents": null - }, "name": "ino", "type": "u64" } @@ -286,9 +217,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 4 }, @@ -298,9 +226,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 5 }, @@ -310,9 +235,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 1 }, @@ -322,9 +244,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 2 }, @@ -334,9 +253,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 3 }, @@ -346,9 +262,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 0 }, @@ -358,9 +271,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 0 }, @@ -373,9 +283,6 @@ "packages": [ { "name": "foo:another-pkg", - "docs": { - "contents": null - }, "interfaces": { "other-interface": 0 }, @@ -383,9 +290,6 @@ }, { "name": "foo:corp", - "docs": { - "contents": null - }, "interfaces": { "saas": 1 }, @@ -393,9 +297,6 @@ }, { "name": "foo:different-pkg", - "docs": { - "contents": null - }, "interfaces": { "i": 2 }, @@ -403,9 +304,6 @@ }, { "name": "foo:foreign-pkg", - "docs": { - "contents": null - }, "interfaces": { "the-default": 3 }, @@ -413,9 +311,6 @@ }, { "name": "foo:some-pkg", - "docs": { - "contents": null - }, "interfaces": { "the-default": 4, "some-interface": 5, @@ -425,9 +320,6 @@ }, { "name": "foo:wasi", - "docs": { - "contents": null - }, "interfaces": { "clocks": 7, "filesystem": 8 @@ -436,9 +328,6 @@ }, { "name": "foo:root", - "docs": { - "contents": null - }, "interfaces": { "foo": 9, "bar": 10, diff --git a/crates/wit-parser/tests/ui/functions.wit.json b/crates/wit-parser/tests/ui/functions.wit.json index 2ae4f157c9..0fae5b8bda 100644 --- a/crates/wit-parser/tests/ui/functions.wit.json +++ b/crates/wit-parser/tests/ui/functions.wit.json @@ -3,24 +3,15 @@ "interfaces": [ { "name": "functions", - "docs": { - "contents": null - }, "types": {}, "functions": { "f1": { - "docs": { - "contents": null - }, "name": "f1", "kind": "freestanding", "params": [], "results": [] }, "f2": { - "docs": { - "contents": null - }, "name": "f2", "kind": "freestanding", "params": [ @@ -32,9 +23,6 @@ "results": [] }, "f3": { - "docs": { - "contents": null - }, "name": "f3", "kind": "freestanding", "params": [ @@ -46,9 +34,6 @@ "results": [] }, "f4": { - "docs": { - "contents": null - }, "name": "f4", "kind": "freestanding", "params": [], @@ -59,9 +44,6 @@ ] }, "f6": { - "docs": { - "contents": null - }, "name": "f6", "kind": "freestanding", "params": [], @@ -72,9 +54,6 @@ ] }, "f7": { - "docs": { - "contents": null - }, "name": "f7", "kind": "freestanding", "params": [ @@ -94,9 +73,6 @@ ] }, "f8": { - "docs": { - "contents": null - }, "name": "f8", "kind": "freestanding", "params": [ @@ -112,9 +88,6 @@ ] }, "f9": { - "docs": { - "contents": null - }, "name": "f9", "kind": "freestanding", "params": [], @@ -130,9 +103,6 @@ ] }, "f10": { - "docs": { - "contents": null - }, "name": "f10", "kind": "freestanding", "params": [], @@ -144,9 +114,6 @@ ] }, "f11": { - "docs": { - "contents": null - }, "name": "f11", "kind": "freestanding", "params": [], @@ -158,9 +125,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": { "tuple": { "types": [ @@ -173,9 +137,6 @@ "owner": "none" }, { - "docs": { - "contents": null - }, "kind": { "option": "u32" }, @@ -183,9 +144,6 @@ "owner": "none" }, { - "docs": { - "contents": null - }, "kind": { "result": { "ok": "u32", @@ -199,9 +157,6 @@ "packages": [ { "name": "foo:functions", - "docs": { - "contents": null - }, "interfaces": { "functions": 0 }, diff --git a/crates/wit-parser/tests/ui/ignore-files-deps.wit.json b/crates/wit-parser/tests/ui/ignore-files-deps.wit.json index ede65764bc..1b9d00c360 100644 --- a/crates/wit-parser/tests/ui/ignore-files-deps.wit.json +++ b/crates/wit-parser/tests/ui/ignore-files-deps.wit.json @@ -2,9 +2,6 @@ "worlds": [ { "name": "foo", - "docs": { - "contents": null - }, "imports": { "interface-0": { "interface": 0 @@ -17,9 +14,6 @@ "interfaces": [ { "name": "types", - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 0 @@ -29,9 +23,6 @@ "packages": [ { "name": "foo:bar", - "docs": { - "contents": null - }, "interfaces": { "types": 0 }, @@ -39,9 +30,6 @@ }, { "name": "foo:foo", - "docs": { - "contents": null - }, "interfaces": {}, "worlds": { "foo": 0 diff --git a/crates/wit-parser/tests/ui/include-reps.wit.json b/crates/wit-parser/tests/ui/include-reps.wit.json index 96dff73da6..8217e2ee33 100644 --- a/crates/wit-parser/tests/ui/include-reps.wit.json +++ b/crates/wit-parser/tests/ui/include-reps.wit.json @@ -2,9 +2,6 @@ "worlds": [ { "name": "bar", - "docs": { - "contents": null - }, "imports": { "interface-0": { "interface": 0 @@ -19,9 +16,6 @@ }, { "name": "foo", - "docs": { - "contents": null - }, "imports": { "interface-0": { "interface": 0 @@ -38,18 +32,12 @@ "interfaces": [ { "name": "a", - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 0 }, { "name": "b", - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 0 @@ -59,9 +47,6 @@ "packages": [ { "name": "foo:foo", - "docs": { - "contents": null - }, "interfaces": { "a": 0, "b": 1 diff --git a/crates/wit-parser/tests/ui/kebab-name-include-with.wit.json b/crates/wit-parser/tests/ui/kebab-name-include-with.wit.json index f08e01461f..14c6d0d048 100644 --- a/crates/wit-parser/tests/ui/kebab-name-include-with.wit.json +++ b/crates/wit-parser/tests/ui/kebab-name-include-with.wit.json @@ -2,15 +2,9 @@ "worlds": [ { "name": "foo", - "docs": { - "contents": null - }, "imports": { "a": { "function": { - "docs": { - "contents": null - }, "name": "a", "kind": "freestanding", "params": [], @@ -23,15 +17,9 @@ }, { "name": "bar", - "docs": { - "contents": null - }, "imports": { "a": { "function": { - "docs": { - "contents": null - }, "name": "a", "kind": "freestanding", "params": [], @@ -44,15 +32,9 @@ }, { "name": "baz", - "docs": { - "contents": null - }, "imports": { "b": { "function": { - "docs": { - "contents": null - }, "name": "a", "kind": "freestanding", "params": [], @@ -61,9 +43,6 @@ }, "a": { "function": { - "docs": { - "contents": null - }, "name": "a", "kind": "freestanding", "params": [], @@ -80,9 +59,6 @@ "packages": [ { "name": "foo:foo", - "docs": { - "contents": null - }, "interfaces": {}, "worlds": { "foo": 0, diff --git a/crates/wit-parser/tests/ui/many-names.wit.json b/crates/wit-parser/tests/ui/many-names.wit.json index efd8747777..87d111bd1f 100644 --- a/crates/wit-parser/tests/ui/many-names.wit.json +++ b/crates/wit-parser/tests/ui/many-names.wit.json @@ -2,9 +2,6 @@ "worlds": [ { "name": "name", - "docs": { - "contents": null - }, "imports": { "name": { "interface": 1 @@ -17,18 +14,12 @@ "interfaces": [ { "name": "x", - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 0 }, { "name": null, - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 0 @@ -38,9 +29,6 @@ "packages": [ { "name": "foo:name", - "docs": { - "contents": null - }, "interfaces": { "x": 0 }, diff --git a/crates/wit-parser/tests/ui/multi-file.wit.json b/crates/wit-parser/tests/ui/multi-file.wit.json index 1a66b5f6f8..c7055676b9 100644 --- a/crates/wit-parser/tests/ui/multi-file.wit.json +++ b/crates/wit-parser/tests/ui/multi-file.wit.json @@ -2,9 +2,6 @@ "worlds": [ { "name": "more-depends-on-later-things", - "docs": { - "contents": null - }, "imports": { "interface-3": { "interface": 3 @@ -19,9 +16,6 @@ }, { "name": "the-world", - "docs": { - "contents": null - }, "imports": { "interface-1": { "interface": 1 @@ -31,9 +25,6 @@ }, "foo": { "function": { - "docs": { - "contents": null - }, "name": "foo", "kind": "freestanding", "params": [], @@ -52,9 +43,6 @@ "interfaces": [ { "name": "irrelevant-name", - "docs": { - "contents": null - }, "types": { "a-name": 0 }, @@ -63,9 +51,6 @@ }, { "name": "depend-on-me", - "docs": { - "contents": null - }, "types": { "x": 1 }, @@ -74,9 +59,6 @@ }, { "name": "depends-on-later-item", - "docs": { - "contents": null - }, "types": { "x": 2 }, @@ -85,18 +67,12 @@ }, { "name": "later-interface", - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 0 }, { "name": "cycle1", - "docs": { - "contents": null - }, "types": { "t": 3 }, @@ -105,9 +81,6 @@ }, { "name": "cycle2", - "docs": { - "contents": null - }, "types": { "t": 4 }, @@ -116,9 +89,6 @@ }, { "name": "cycle3", - "docs": { - "contents": null - }, "types": { "t": 5 }, @@ -127,9 +97,6 @@ }, { "name": "foo", - "docs": { - "contents": null - }, "types": { "x": 6 }, @@ -138,9 +105,6 @@ }, { "name": "something-else", - "docs": { - "contents": null - }, "types": { "y": 7 }, @@ -149,9 +113,6 @@ }, { "name": "bar", - "docs": { - "contents": null - }, "types": { "x": 8, "x2": 9, @@ -167,9 +128,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": { "record": { "fields": [] @@ -181,9 +139,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -193,9 +148,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 1 }, @@ -205,9 +157,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -217,9 +166,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 3 }, @@ -229,9 +175,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 4 }, @@ -241,9 +184,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -253,9 +193,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "u64" }, @@ -265,9 +202,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 6 }, @@ -277,9 +211,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 6 }, @@ -289,9 +220,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 6 }, @@ -301,9 +229,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 1 }, @@ -313,9 +238,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 7 }, @@ -325,9 +247,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 7 }, @@ -337,9 +256,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 0 }, @@ -349,9 +265,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 1 }, @@ -364,9 +277,6 @@ "packages": [ { "name": "foo:multi-file", - "docs": { - "contents": null - }, "interfaces": { "irrelevant-name": 0, "depend-on-me": 1, diff --git a/crates/wit-parser/tests/ui/name-both-resource-and-type.wit.json b/crates/wit-parser/tests/ui/name-both-resource-and-type.wit.json index 097b0f5488..d0bcb7d483 100644 --- a/crates/wit-parser/tests/ui/name-both-resource-and-type.wit.json +++ b/crates/wit-parser/tests/ui/name-both-resource-and-type.wit.json @@ -3,9 +3,6 @@ "interfaces": [ { "name": "foo", - "docs": { - "contents": null - }, "types": { "a": 0 }, @@ -14,9 +11,6 @@ }, { "name": "foo", - "docs": { - "contents": null - }, "types": { "a": 1, "t1": 2, @@ -29,9 +23,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": "resource", "name": "a", "owner": { @@ -39,9 +30,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 0 }, @@ -51,9 +39,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 1 }, @@ -63,9 +48,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "handle": { "borrow": 1 @@ -77,9 +59,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "handle": { "borrow": 2 @@ -94,9 +73,6 @@ "packages": [ { "name": "some:dep", - "docs": { - "contents": null - }, "interfaces": { "foo": 0 }, @@ -104,9 +80,6 @@ }, { "name": "foo:bar", - "docs": { - "contents": null - }, "interfaces": { "foo": 1 }, diff --git a/crates/wit-parser/tests/ui/package-syntax1.wit.json b/crates/wit-parser/tests/ui/package-syntax1.wit.json index 32beadead1..80af0cbb3b 100644 --- a/crates/wit-parser/tests/ui/package-syntax1.wit.json +++ b/crates/wit-parser/tests/ui/package-syntax1.wit.json @@ -5,9 +5,6 @@ "packages": [ { "name": "foo:foo", - "docs": { - "contents": null - }, "interfaces": {}, "worlds": {} } diff --git a/crates/wit-parser/tests/ui/package-syntax3.wit.json b/crates/wit-parser/tests/ui/package-syntax3.wit.json index 37ed94219b..e0323c511b 100644 --- a/crates/wit-parser/tests/ui/package-syntax3.wit.json +++ b/crates/wit-parser/tests/ui/package-syntax3.wit.json @@ -5,9 +5,6 @@ "packages": [ { "name": "foo:bar", - "docs": { - "contents": null - }, "interfaces": {}, "worlds": {} } diff --git a/crates/wit-parser/tests/ui/package-syntax4.wit.json b/crates/wit-parser/tests/ui/package-syntax4.wit.json index 43a9aec4cd..7bacc86f03 100644 --- a/crates/wit-parser/tests/ui/package-syntax4.wit.json +++ b/crates/wit-parser/tests/ui/package-syntax4.wit.json @@ -5,9 +5,6 @@ "packages": [ { "name": "foo:bar@2.0.0", - "docs": { - "contents": null - }, "interfaces": {}, "worlds": {} } diff --git a/crates/wit-parser/tests/ui/resources-empty.wit.json b/crates/wit-parser/tests/ui/resources-empty.wit.json index 516cafda9c..ddb0ce928e 100644 --- a/crates/wit-parser/tests/ui/resources-empty.wit.json +++ b/crates/wit-parser/tests/ui/resources-empty.wit.json @@ -3,17 +3,11 @@ "interfaces": [ { "name": "resources-empty", - "docs": { - "contents": null - }, "types": { "r1": 0 }, "functions": { "t1": { - "docs": { - "contents": null - }, "name": "t1", "kind": "freestanding", "params": [ @@ -25,9 +19,6 @@ "results": [] }, "t2": { - "docs": { - "contents": null - }, "name": "t2", "kind": "freestanding", "params": [ @@ -44,9 +35,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": "resource", "name": "r1", "owner": { @@ -54,9 +42,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "handle": { "borrow": 0 @@ -66,9 +51,6 @@ "owner": "none" }, { - "docs": { - "contents": null - }, "kind": { "handle": { "own": 0 @@ -81,9 +63,6 @@ "packages": [ { "name": "foo:resources-empty", - "docs": { - "contents": null - }, "interfaces": { "resources-empty": 0 }, diff --git a/crates/wit-parser/tests/ui/resources-multiple-returns-borrow.wit.json b/crates/wit-parser/tests/ui/resources-multiple-returns-borrow.wit.json index aba75f94c2..3109f6f366 100644 --- a/crates/wit-parser/tests/ui/resources-multiple-returns-borrow.wit.json +++ b/crates/wit-parser/tests/ui/resources-multiple-returns-borrow.wit.json @@ -3,17 +3,11 @@ "interfaces": [ { "name": "resources1", - "docs": { - "contents": null - }, "types": { "r1": 0 }, "functions": { "t1": { - "docs": { - "contents": null - }, "name": "t1", "kind": "freestanding", "params": [ @@ -25,9 +19,6 @@ "results": [] }, "[method]r1.f1": { - "docs": { - "contents": null - }, "name": "[method]r1.f1", "kind": { "method": 0 @@ -55,9 +46,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": "resource", "name": "r1", "owner": { @@ -65,9 +53,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "handle": { "borrow": 0 @@ -80,9 +65,6 @@ "packages": [ { "name": "foo:resources1", - "docs": { - "contents": null - }, "interfaces": { "resources1": 0 }, diff --git a/crates/wit-parser/tests/ui/resources-multiple-returns-own.wit.json b/crates/wit-parser/tests/ui/resources-multiple-returns-own.wit.json index 8ccd93c61e..91d496319f 100644 --- a/crates/wit-parser/tests/ui/resources-multiple-returns-own.wit.json +++ b/crates/wit-parser/tests/ui/resources-multiple-returns-own.wit.json @@ -3,17 +3,11 @@ "interfaces": [ { "name": "resources1", - "docs": { - "contents": null - }, "types": { "r1": 0 }, "functions": { "t1": { - "docs": { - "contents": null - }, "name": "t1", "kind": "freestanding", "params": [ @@ -25,9 +19,6 @@ "results": [] }, "[method]r1.f1": { - "docs": { - "contents": null - }, "name": "[method]r1.f1", "kind": { "method": 0 @@ -55,9 +46,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": "resource", "name": "r1", "owner": { @@ -65,9 +53,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "handle": { "borrow": 0 @@ -77,9 +62,6 @@ "owner": "none" }, { - "docs": { - "contents": null - }, "kind": { "handle": { "own": 0 @@ -92,9 +74,6 @@ "packages": [ { "name": "foo:resources1", - "docs": { - "contents": null - }, "interfaces": { "resources1": 0 }, diff --git a/crates/wit-parser/tests/ui/resources-multiple.wit.json b/crates/wit-parser/tests/ui/resources-multiple.wit.json index 9e926d7b32..79674fb618 100644 --- a/crates/wit-parser/tests/ui/resources-multiple.wit.json +++ b/crates/wit-parser/tests/ui/resources-multiple.wit.json @@ -3,17 +3,11 @@ "interfaces": [ { "name": "resources-multiple", - "docs": { - "contents": null - }, "types": { "r1": 0 }, "functions": { "t1": { - "docs": { - "contents": null - }, "name": "t1", "kind": "freestanding", "params": [ @@ -25,9 +19,6 @@ "results": [] }, "t2": { - "docs": { - "contents": null - }, "name": "t2", "kind": "freestanding", "params": [ @@ -39,9 +30,6 @@ "results": [] }, "[method]r1.f1": { - "docs": { - "contents": null - }, "name": "[method]r1.f1", "kind": { "method": 0 @@ -55,9 +43,6 @@ "results": [] }, "[method]r1.f2": { - "docs": { - "contents": null - }, "name": "[method]r1.f2", "kind": { "method": 0 @@ -75,9 +60,6 @@ "results": [] }, "[method]r1.f3": { - "docs": { - "contents": null - }, "name": "[method]r1.f3", "kind": { "method": 0 @@ -95,9 +77,6 @@ "results": [] }, "[method]r1.f4": { - "docs": { - "contents": null - }, "name": "[method]r1.f4", "kind": { "method": 0 @@ -115,9 +94,6 @@ ] }, "[method]r1.f6": { - "docs": { - "contents": null - }, "name": "[method]r1.f6", "kind": { "method": 0 @@ -135,9 +111,6 @@ ] }, "[method]r1.f7": { - "docs": { - "contents": null - }, "name": "[method]r1.f7", "kind": { "method": 0 @@ -163,9 +136,6 @@ ] }, "[method]r1.f8": { - "docs": { - "contents": null - }, "name": "[method]r1.f8", "kind": { "method": 0 @@ -187,9 +157,6 @@ ] }, "[method]r1.f9": { - "docs": { - "contents": null - }, "name": "[method]r1.f9", "kind": { "method": 0 @@ -212,9 +179,6 @@ ] }, "[method]r1.f10": { - "docs": { - "contents": null - }, "name": "[method]r1.f10", "kind": { "method": 0 @@ -233,9 +197,6 @@ ] }, "[method]r1.f11": { - "docs": { - "contents": null - }, "name": "[method]r1.f11", "kind": { "method": 0 @@ -254,9 +215,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": "resource", "name": "r1", "owner": { @@ -264,9 +222,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "handle": { "borrow": 0 @@ -276,9 +231,6 @@ "owner": "none" }, { - "docs": { - "contents": null - }, "kind": { "tuple": { "types": [ @@ -291,9 +243,6 @@ "owner": "none" }, { - "docs": { - "contents": null - }, "kind": { "option": "u32" }, @@ -301,9 +250,6 @@ "owner": "none" }, { - "docs": { - "contents": null - }, "kind": { "result": { "ok": "u32", @@ -314,9 +260,6 @@ "owner": "none" }, { - "docs": { - "contents": null - }, "kind": { "handle": { "own": 0 @@ -329,9 +272,6 @@ "packages": [ { "name": "foo:resources-multiple", - "docs": { - "contents": null - }, "interfaces": { "resources-multiple": 0 }, diff --git a/crates/wit-parser/tests/ui/resources-return-borrow.wit.json b/crates/wit-parser/tests/ui/resources-return-borrow.wit.json index cfeca1d305..7e52922f12 100644 --- a/crates/wit-parser/tests/ui/resources-return-borrow.wit.json +++ b/crates/wit-parser/tests/ui/resources-return-borrow.wit.json @@ -3,17 +3,11 @@ "interfaces": [ { "name": "resources1", - "docs": { - "contents": null - }, "types": { "r1": 0 }, "functions": { "t1": { - "docs": { - "contents": null - }, "name": "t1", "kind": "freestanding", "params": [ @@ -25,9 +19,6 @@ "results": [] }, "[method]r1.f1": { - "docs": { - "contents": null - }, "name": "[method]r1.f1", "kind": { "method": 0 @@ -50,9 +41,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": "resource", "name": "r1", "owner": { @@ -60,9 +48,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "handle": { "borrow": 0 @@ -75,9 +60,6 @@ "packages": [ { "name": "foo:resources1", - "docs": { - "contents": null - }, "interfaces": { "resources1": 0 }, diff --git a/crates/wit-parser/tests/ui/resources-return-own.wit.json b/crates/wit-parser/tests/ui/resources-return-own.wit.json index 9cddd741f3..c7e2936c21 100644 --- a/crates/wit-parser/tests/ui/resources-return-own.wit.json +++ b/crates/wit-parser/tests/ui/resources-return-own.wit.json @@ -3,17 +3,11 @@ "interfaces": [ { "name": "resources1", - "docs": { - "contents": null - }, "types": { "r1": 0 }, "functions": { "t1": { - "docs": { - "contents": null - }, "name": "t1", "kind": "freestanding", "params": [ @@ -25,9 +19,6 @@ "results": [] }, "[method]r1.f1": { - "docs": { - "contents": null - }, "name": "[method]r1.f1", "kind": { "method": 0 @@ -50,9 +41,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": "resource", "name": "r1", "owner": { @@ -60,9 +48,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "handle": { "borrow": 0 @@ -72,9 +57,6 @@ "owner": "none" }, { - "docs": { - "contents": null - }, "kind": { "handle": { "own": 0 @@ -87,9 +69,6 @@ "packages": [ { "name": "foo:resources1", - "docs": { - "contents": null - }, "interfaces": { "resources1": 0 }, diff --git a/crates/wit-parser/tests/ui/resources.wit.json b/crates/wit-parser/tests/ui/resources.wit.json index e0f623e203..8df576af6b 100644 --- a/crates/wit-parser/tests/ui/resources.wit.json +++ b/crates/wit-parser/tests/ui/resources.wit.json @@ -2,9 +2,6 @@ "worlds": [ { "name": "w", - "docs": { - "contents": null - }, "imports": { "a": { "type": 11 @@ -17,9 +14,6 @@ }, "[constructor]c": { "function": { - "docs": { - "contents": null - }, "name": "[constructor]c", "kind": { "constructor": 13 @@ -40,9 +34,6 @@ "interfaces": [ { "name": "foo", - "docs": { - "contents": null - }, "types": { "a": 0, "b": 1, @@ -52,9 +43,6 @@ }, "functions": { "[constructor]b": { - "docs": { - "contents": null - }, "name": "[constructor]b", "kind": { "constructor": 1 @@ -67,9 +55,6 @@ ] }, "[constructor]c": { - "docs": { - "contents": null - }, "name": "[constructor]c", "kind": { "constructor": 2 @@ -87,9 +72,6 @@ ] }, "[constructor]d": { - "docs": { - "contents": null - }, "name": "[constructor]d", "kind": { "constructor": 3 @@ -107,9 +89,6 @@ ] }, "[method]d.a": { - "docs": { - "contents": null - }, "name": "[method]d.a", "kind": { "method": 3 @@ -123,9 +102,6 @@ "results": [] }, "[static]d.b": { - "docs": { - "contents": null - }, "name": "[static]d.b", "kind": { "static": 3 @@ -134,9 +110,6 @@ "results": [] }, "[constructor]e": { - "docs": { - "contents": null - }, "name": "[constructor]e", "kind": { "constructor": 4 @@ -158,9 +131,6 @@ ] }, "[method]e.method": { - "docs": { - "contents": null - }, "name": "[method]e.method", "kind": { "method": 4 @@ -186,9 +156,6 @@ }, { "name": "i", - "docs": { - "contents": null - }, "types": { "a": 7, "t1": 8, @@ -201,9 +168,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": "resource", "name": "a", "owner": { @@ -211,9 +175,6 @@ } }, { - "docs": { - "contents": null - }, "kind": "resource", "name": "b", "owner": { @@ -221,9 +182,6 @@ } }, { - "docs": { - "contents": null - }, "kind": "resource", "name": "c", "owner": { @@ -231,9 +189,6 @@ } }, { - "docs": { - "contents": null - }, "kind": "resource", "name": "d", "owner": { @@ -241,9 +196,6 @@ } }, { - "docs": { - "contents": null - }, "kind": "resource", "name": "e", "owner": { @@ -251,9 +203,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "handle": { "borrow": 3 @@ -263,9 +212,6 @@ "owner": "none" }, { - "docs": { - "contents": null - }, "kind": { "handle": { "borrow": 4 @@ -275,9 +221,6 @@ "owner": "none" }, { - "docs": { - "contents": null - }, "kind": "resource", "name": "a", "owner": { @@ -285,9 +228,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 7 }, @@ -297,9 +237,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "handle": { "borrow": 7 @@ -311,9 +248,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "handle": { "borrow": 8 @@ -325,9 +259,6 @@ } }, { - "docs": { - "contents": null - }, "kind": "resource", "name": "a", "owner": { @@ -335,9 +266,6 @@ } }, { - "docs": { - "contents": null - }, "kind": "resource", "name": "b", "owner": { @@ -345,9 +273,6 @@ } }, { - "docs": { - "contents": null - }, "kind": "resource", "name": "c", "owner": { @@ -355,9 +280,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "handle": { "own": 1 @@ -367,9 +289,6 @@ "owner": "none" }, { - "docs": { - "contents": null - }, "kind": { "handle": { "own": 2 @@ -379,9 +298,6 @@ "owner": "none" }, { - "docs": { - "contents": null - }, "kind": { "handle": { "own": 3 @@ -391,9 +307,6 @@ "owner": "none" }, { - "docs": { - "contents": null - }, "kind": { "handle": { "own": 4 @@ -403,9 +316,6 @@ "owner": "none" }, { - "docs": { - "contents": null - }, "kind": { "handle": { "own": 13 @@ -418,9 +328,6 @@ "packages": [ { "name": "foo:bar", - "docs": { - "contents": null - }, "interfaces": { "foo": 0, "i": 1 diff --git a/crates/wit-parser/tests/ui/resources1.wit.json b/crates/wit-parser/tests/ui/resources1.wit.json index f95ead453e..0945e57392 100644 --- a/crates/wit-parser/tests/ui/resources1.wit.json +++ b/crates/wit-parser/tests/ui/resources1.wit.json @@ -3,17 +3,11 @@ "interfaces": [ { "name": "resources1", - "docs": { - "contents": null - }, "types": { "r1": 0 }, "functions": { "t1": { - "docs": { - "contents": null - }, "name": "t1", "kind": "freestanding", "params": [ @@ -25,9 +19,6 @@ "results": [] }, "t2": { - "docs": { - "contents": null - }, "name": "t2", "kind": "freestanding", "params": [ @@ -39,9 +30,6 @@ "results": [] }, "t3": { - "docs": { - "contents": null - }, "name": "t3", "kind": "freestanding", "params": [ @@ -53,9 +41,6 @@ "results": [] }, "[method]r1.f1": { - "docs": { - "contents": null - }, "name": "[method]r1.f1", "kind": { "method": 0 @@ -74,9 +59,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": "resource", "name": "r1", "owner": { @@ -84,9 +66,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "handle": { "borrow": 0 @@ -96,9 +75,6 @@ "owner": "none" }, { - "docs": { - "contents": null - }, "kind": { "handle": { "own": 0 @@ -111,9 +87,6 @@ "packages": [ { "name": "foo:resources1", - "docs": { - "contents": null - }, "interfaces": { "resources1": 0 }, diff --git a/crates/wit-parser/tests/ui/shared-types.wit.json b/crates/wit-parser/tests/ui/shared-types.wit.json index 48d6e5fe5e..76729dd3ee 100644 --- a/crates/wit-parser/tests/ui/shared-types.wit.json +++ b/crates/wit-parser/tests/ui/shared-types.wit.json @@ -2,9 +2,6 @@ "worlds": [ { "name": "foo", - "docs": { - "contents": null - }, "imports": { "foo": { "interface": 0 @@ -21,15 +18,9 @@ "interfaces": [ { "name": null, - "docs": { - "contents": null - }, "types": {}, "functions": { "a": { - "docs": { - "contents": null - }, "name": "a", "kind": "freestanding", "params": [], @@ -44,15 +35,9 @@ }, { "name": null, - "docs": { - "contents": null - }, "types": {}, "functions": { "a": { - "docs": { - "contents": null - }, "name": "a", "kind": "freestanding", "params": [], @@ -68,9 +53,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": { "list": "u8" }, @@ -78,9 +60,6 @@ "owner": "none" }, { - "docs": { - "contents": null - }, "kind": { "tuple": { "types": [ @@ -95,9 +74,6 @@ "packages": [ { "name": "foo:shared-items", - "docs": { - "contents": null - }, "interfaces": {}, "worlds": { "foo": 0 diff --git a/crates/wit-parser/tests/ui/stress-export-elaborate.wit.json b/crates/wit-parser/tests/ui/stress-export-elaborate.wit.json index aa5dca7cf1..e7081d15e0 100644 --- a/crates/wit-parser/tests/ui/stress-export-elaborate.wit.json +++ b/crates/wit-parser/tests/ui/stress-export-elaborate.wit.json @@ -2,9 +2,6 @@ "worlds": [ { "name": "foo", - "docs": { - "contents": null - }, "imports": { "interface-0": { "interface": 0 @@ -45,9 +42,6 @@ "interfaces": [ { "name": "i1", - "docs": { - "contents": null - }, "types": { "t1": 0, "t2": 1, @@ -65,9 +59,6 @@ }, { "name": "i2", - "docs": { - "contents": null - }, "types": { "t1": 10, "t2": 11, @@ -85,9 +76,6 @@ }, { "name": "i3", - "docs": { - "contents": null - }, "types": { "t1": 20, "t2": 21, @@ -105,9 +93,6 @@ }, { "name": "i4", - "docs": { - "contents": null - }, "types": { "t1": 30, "t2": 31, @@ -125,9 +110,6 @@ }, { "name": "i5", - "docs": { - "contents": null - }, "types": { "t1": 40, "t2": 41, @@ -145,9 +127,6 @@ }, { "name": "i6", - "docs": { - "contents": null - }, "types": { "t1": 50, "t2": 51, @@ -165,9 +144,6 @@ }, { "name": "i7", - "docs": { - "contents": null - }, "types": { "t1": 60, "t2": 61, @@ -185,9 +161,6 @@ }, { "name": "i8", - "docs": { - "contents": null - }, "types": { "t1": 70, "t2": 71, @@ -205,9 +178,6 @@ }, { "name": "i9", - "docs": { - "contents": null - }, "types": { "t1": 80, "t2": 81, @@ -225,9 +195,6 @@ }, { "name": "i10", - "docs": { - "contents": null - }, "types": { "t1": 90, "t2": 91, @@ -246,9 +213,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -258,9 +222,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -270,9 +231,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -282,9 +240,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -294,9 +249,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -306,9 +258,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -318,9 +267,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -330,9 +276,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -342,9 +285,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -354,9 +294,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -366,9 +303,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 0 }, @@ -378,9 +312,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 1 }, @@ -390,9 +321,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 2 }, @@ -402,9 +330,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 3 }, @@ -414,9 +339,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 4 }, @@ -426,9 +348,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 5 }, @@ -438,9 +357,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 6 }, @@ -450,9 +366,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 7 }, @@ -462,9 +375,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 8 }, @@ -474,9 +384,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 9 }, @@ -486,9 +393,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 10 }, @@ -498,9 +402,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 11 }, @@ -510,9 +411,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 12 }, @@ -522,9 +420,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 13 }, @@ -534,9 +429,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 14 }, @@ -546,9 +438,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 15 }, @@ -558,9 +447,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 16 }, @@ -570,9 +456,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 17 }, @@ -582,9 +465,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 18 }, @@ -594,9 +474,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 19 }, @@ -606,9 +483,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 20 }, @@ -618,9 +492,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 21 }, @@ -630,9 +501,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 22 }, @@ -642,9 +510,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 23 }, @@ -654,9 +519,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 24 }, @@ -666,9 +528,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 25 }, @@ -678,9 +537,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 26 }, @@ -690,9 +546,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 27 }, @@ -702,9 +555,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 28 }, @@ -714,9 +564,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 29 }, @@ -726,9 +573,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 30 }, @@ -738,9 +582,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 31 }, @@ -750,9 +591,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 32 }, @@ -762,9 +600,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 33 }, @@ -774,9 +609,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 34 }, @@ -786,9 +618,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 35 }, @@ -798,9 +627,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 36 }, @@ -810,9 +636,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 37 }, @@ -822,9 +645,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 38 }, @@ -834,9 +654,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 39 }, @@ -846,9 +663,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 40 }, @@ -858,9 +672,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 41 }, @@ -870,9 +681,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 42 }, @@ -882,9 +690,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 43 }, @@ -894,9 +699,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 44 }, @@ -906,9 +708,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 45 }, @@ -918,9 +717,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 46 }, @@ -930,9 +726,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 47 }, @@ -942,9 +735,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 48 }, @@ -954,9 +744,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 49 }, @@ -966,9 +753,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 50 }, @@ -978,9 +762,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 51 }, @@ -990,9 +771,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 52 }, @@ -1002,9 +780,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 53 }, @@ -1014,9 +789,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 54 }, @@ -1026,9 +798,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 55 }, @@ -1038,9 +807,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 56 }, @@ -1050,9 +816,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 57 }, @@ -1062,9 +825,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 58 }, @@ -1074,9 +834,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 59 }, @@ -1086,9 +843,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 60 }, @@ -1098,9 +852,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 61 }, @@ -1110,9 +861,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 62 }, @@ -1122,9 +870,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 63 }, @@ -1134,9 +879,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 64 }, @@ -1146,9 +888,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 65 }, @@ -1158,9 +897,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 66 }, @@ -1170,9 +906,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 67 }, @@ -1182,9 +915,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 68 }, @@ -1194,9 +924,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 69 }, @@ -1206,9 +933,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 70 }, @@ -1218,9 +942,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 71 }, @@ -1230,9 +951,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 72 }, @@ -1242,9 +960,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 73 }, @@ -1254,9 +969,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 74 }, @@ -1266,9 +978,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 75 }, @@ -1278,9 +987,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 76 }, @@ -1290,9 +996,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 77 }, @@ -1302,9 +1005,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 78 }, @@ -1314,9 +1014,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 79 }, @@ -1326,9 +1023,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 80 }, @@ -1338,9 +1032,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 81 }, @@ -1350,9 +1041,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 82 }, @@ -1362,9 +1050,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 83 }, @@ -1374,9 +1059,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 84 }, @@ -1386,9 +1068,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 85 }, @@ -1398,9 +1077,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 86 }, @@ -1410,9 +1086,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 87 }, @@ -1422,9 +1095,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 88 }, @@ -1434,9 +1104,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 89 }, @@ -1449,9 +1116,6 @@ "packages": [ { "name": "foo:bar", - "docs": { - "contents": null - }, "interfaces": { "i1": 0, "i2": 1, diff --git a/crates/wit-parser/tests/ui/type-then-eof.wit.json b/crates/wit-parser/tests/ui/type-then-eof.wit.json index e952bc6f6e..beb0a7adca 100644 --- a/crates/wit-parser/tests/ui/type-then-eof.wit.json +++ b/crates/wit-parser/tests/ui/type-then-eof.wit.json @@ -3,15 +3,9 @@ "interfaces": [ { "name": "foo", - "docs": { - "contents": null - }, "types": {}, "functions": { "foo": { - "docs": { - "contents": null - }, "name": "foo", "kind": "freestanding", "params": [], @@ -29,9 +23,6 @@ "packages": [ { "name": "foo:foo", - "docs": { - "contents": null - }, "interfaces": { "foo": 0 }, diff --git a/crates/wit-parser/tests/ui/types.wit.json b/crates/wit-parser/tests/ui/types.wit.json index 0e2da49d42..46c3452ef7 100644 --- a/crates/wit-parser/tests/ui/types.wit.json +++ b/crates/wit-parser/tests/ui/types.wit.json @@ -3,9 +3,6 @@ "interfaces": [ { "name": "types", - "docs": { - "contents": null - }, "types": { "t1": 0, "t2": 1, @@ -66,9 +63,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": { "type": "u8" }, @@ -78,9 +72,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "u16" }, @@ -90,9 +81,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -102,9 +90,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "u64" }, @@ -114,9 +99,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "s8" }, @@ -126,9 +108,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "s16" }, @@ -138,9 +117,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "s32" }, @@ -150,9 +126,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "s64" }, @@ -162,9 +135,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "float32" }, @@ -174,9 +144,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "float64" }, @@ -186,9 +153,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "char" }, @@ -198,9 +162,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "list": "char" }, @@ -210,9 +171,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "string" }, @@ -222,9 +180,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "option": "u32" }, @@ -234,9 +189,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "result": { "ok": "u32", @@ -249,9 +201,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "result": { "ok": null, @@ -264,9 +213,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "result": { "ok": "u32", @@ -279,9 +225,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "result": { "ok": null, @@ -294,9 +237,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "record": { "fields": [] @@ -308,16 +248,10 @@ } }, { - "docs": { - "contents": null - }, "kind": { "record": { "fields": [ { - "docs": { - "contents": null - }, "name": "a", "type": "u32" } @@ -330,16 +264,10 @@ } }, { - "docs": { - "contents": null - }, "kind": { "record": { "fields": [ { - "docs": { - "contents": null - }, "name": "a", "type": "u32" } @@ -352,23 +280,14 @@ } }, { - "docs": { - "contents": null - }, "kind": { "record": { "fields": [ { - "docs": { - "contents": null - }, "name": "a", "type": "u32" }, { - "docs": { - "contents": null - }, "name": "b", "type": "u64" } @@ -381,23 +300,14 @@ } }, { - "docs": { - "contents": null - }, "kind": { "record": { "fields": [ { - "docs": { - "contents": null - }, "name": "a", "type": "u32" }, { - "docs": { - "contents": null - }, "name": "b", "type": "u64" } @@ -410,16 +320,10 @@ } }, { - "docs": { - "contents": null - }, "kind": { "record": { "fields": [ { - "docs": { - "contents": null - }, "name": "x", "type": "u32" } @@ -432,9 +336,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "record": { "fields": [] @@ -446,9 +347,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "tuple": { "types": [] @@ -460,9 +358,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "tuple": { "types": [ @@ -476,9 +371,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "tuple": { "types": [ @@ -492,9 +384,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "tuple": { "types": [ @@ -509,9 +398,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "flags": { "flags": [] @@ -523,28 +409,16 @@ } }, { - "docs": { - "contents": null - }, "kind": { "flags": { "flags": [ { - "docs": { - "contents": null - }, "name": "a" }, { - "docs": { - "contents": null - }, "name": "b" }, { - "docs": { - "contents": null - }, "name": "c" } ] @@ -556,28 +430,16 @@ } }, { - "docs": { - "contents": null - }, "kind": { "flags": { "flags": [ { - "docs": { - "contents": null - }, "name": "a" }, { - "docs": { - "contents": null - }, "name": "b" }, { - "docs": { - "contents": null - }, "name": "c" } ] @@ -589,16 +451,10 @@ } }, { - "docs": { - "contents": null - }, "kind": { "variant": { "cases": [ { - "docs": { - "contents": null - }, "name": "a", "type": null } @@ -611,23 +467,14 @@ } }, { - "docs": { - "contents": null - }, "kind": { "variant": { "cases": [ { - "docs": { - "contents": null - }, "name": "a", "type": null }, { - "docs": { - "contents": null - }, "name": "b", "type": null } @@ -640,23 +487,14 @@ } }, { - "docs": { - "contents": null - }, "kind": { "variant": { "cases": [ { - "docs": { - "contents": null - }, "name": "a", "type": null }, { - "docs": { - "contents": null - }, "name": "b", "type": null } @@ -669,23 +507,14 @@ } }, { - "docs": { - "contents": null - }, "kind": { "variant": { "cases": [ { - "docs": { - "contents": null - }, "name": "a", "type": null }, { - "docs": { - "contents": null - }, "name": "b", "type": "u32" } @@ -698,9 +527,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "option": "u32" }, @@ -708,23 +534,14 @@ "owner": "none" }, { - "docs": { - "contents": null - }, "kind": { "variant": { "cases": [ { - "docs": { - "contents": null - }, "name": "a", "type": null }, { - "docs": { - "contents": null - }, "name": "b", "type": 36 } @@ -737,28 +554,16 @@ } }, { - "docs": { - "contents": null - }, "kind": { "enum": { "cases": [ { - "docs": { - "contents": null - }, "name": "a" }, { - "docs": { - "contents": null - }, "name": "b" }, { - "docs": { - "contents": null - }, "name": "c" } ] @@ -770,28 +575,16 @@ } }, { - "docs": { - "contents": null - }, "kind": { "enum": { "cases": [ { - "docs": { - "contents": null - }, "name": "a" }, { - "docs": { - "contents": null - }, "name": "b" }, { - "docs": { - "contents": null - }, "name": "c" } ] @@ -803,9 +596,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "bool" }, @@ -815,9 +605,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "string" }, @@ -827,9 +614,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "list": 31 }, @@ -837,9 +621,6 @@ "owner": "none" }, { - "docs": { - "contents": null - }, "kind": { "list": 42 }, @@ -847,9 +628,6 @@ "owner": "none" }, { - "docs": { - "contents": null - }, "kind": { "list": 43 }, @@ -859,9 +637,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 41 }, @@ -871,9 +646,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 41 }, @@ -883,9 +655,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "stream": { "element": "u32", @@ -898,9 +667,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "stream": { "element": null, @@ -913,9 +679,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "stream": { "element": "u32", @@ -928,9 +691,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "stream": { "element": null, @@ -943,9 +703,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "future": "u32" }, @@ -955,9 +712,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "future": null }, @@ -967,9 +721,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -979,9 +730,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 53 }, @@ -994,9 +742,6 @@ "packages": [ { "name": "foo:types", - "docs": { - "contents": null - }, "interfaces": { "types": 0 }, diff --git a/crates/wit-parser/tests/ui/union-fuzz-1.wit.json b/crates/wit-parser/tests/ui/union-fuzz-1.wit.json index 0cf17afef4..31c7c82687 100644 --- a/crates/wit-parser/tests/ui/union-fuzz-1.wit.json +++ b/crates/wit-parser/tests/ui/union-fuzz-1.wit.json @@ -2,27 +2,18 @@ "worlds": [ { "name": "xo", - "docs": { - "contents": null - }, "imports": {}, "exports": {}, "package": 0 }, { "name": "name", - "docs": { - "contents": null - }, "imports": {}, "exports": {}, "package": 0 }, { "name": "x", - "docs": { - "contents": null - }, "imports": {}, "exports": {}, "package": 0 @@ -33,9 +24,6 @@ "packages": [ { "name": "foo:bar", - "docs": { - "contents": null - }, "interfaces": {}, "worlds": { "xo": 0, diff --git a/crates/wit-parser/tests/ui/use-chain.wit.json b/crates/wit-parser/tests/ui/use-chain.wit.json index fbdaead822..f8598bcb15 100644 --- a/crates/wit-parser/tests/ui/use-chain.wit.json +++ b/crates/wit-parser/tests/ui/use-chain.wit.json @@ -3,9 +3,6 @@ "interfaces": [ { "name": "foo", - "docs": { - "contents": null - }, "types": { "foo": 0 }, @@ -14,9 +11,6 @@ }, { "name": "name", - "docs": { - "contents": null - }, "types": { "foo": 1 }, @@ -26,9 +20,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": { "record": { "fields": [] @@ -40,9 +31,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 0 }, @@ -55,9 +43,6 @@ "packages": [ { "name": "foo:name", - "docs": { - "contents": null - }, "interfaces": { "foo": 0, "name": 1 diff --git a/crates/wit-parser/tests/ui/use.wit.json b/crates/wit-parser/tests/ui/use.wit.json index a1244137ca..e37de2c14c 100644 --- a/crates/wit-parser/tests/ui/use.wit.json +++ b/crates/wit-parser/tests/ui/use.wit.json @@ -3,9 +3,6 @@ "interfaces": [ { "name": "bar", - "docs": { - "contents": null - }, "types": { "the-type": 0 }, @@ -14,9 +11,6 @@ }, { "name": "foo", - "docs": { - "contents": null - }, "types": { "the-type": 1 }, @@ -25,9 +19,6 @@ }, { "name": "baz", - "docs": { - "contents": null - }, "types": { "the-type": 2, "test": 3 @@ -37,36 +28,24 @@ }, { "name": "empty", - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 0 }, { "name": "use-from-empty", - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 0 }, { "name": "use-multiple", - "docs": { - "contents": null - }, "types": { "the-type": 4, "test": 5 }, "functions": { "some-function": { - "docs": { - "contents": null - }, "name": "some-function", "kind": "freestanding", "params": [ @@ -86,9 +65,6 @@ }, { "name": "trailing-comma", - "docs": { - "contents": null - }, "types": { "the-type": 6, "the-foo": 7 @@ -99,9 +75,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -111,9 +84,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 0 }, @@ -123,9 +93,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 1 }, @@ -135,9 +102,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 0 }, @@ -147,9 +111,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 2 }, @@ -159,9 +120,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 3 }, @@ -171,9 +129,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 1 }, @@ -183,16 +138,10 @@ } }, { - "docs": { - "contents": null - }, "kind": { "record": { "fields": [ { - "docs": { - "contents": null - }, "name": "a", "type": 6 } @@ -208,9 +157,6 @@ "packages": [ { "name": "foo:foo", - "docs": { - "contents": null - }, "interfaces": { "bar": 0, "foo": 1, diff --git a/crates/wit-parser/tests/ui/versions.wit.json b/crates/wit-parser/tests/ui/versions.wit.json index e4eb184a1e..aabcc1b65d 100644 --- a/crates/wit-parser/tests/ui/versions.wit.json +++ b/crates/wit-parser/tests/ui/versions.wit.json @@ -3,9 +3,6 @@ "interfaces": [ { "name": "foo", - "docs": { - "contents": null - }, "types": { "t": 0 }, @@ -14,9 +11,6 @@ }, { "name": "foo", - "docs": { - "contents": null - }, "types": { "t": 1 }, @@ -25,9 +19,6 @@ }, { "name": "foo", - "docs": { - "contents": null - }, "types": { "t": 2, "t2": 3 @@ -38,9 +29,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -50,9 +38,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -62,9 +47,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 0 }, @@ -74,9 +56,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 1 }, @@ -89,9 +68,6 @@ "packages": [ { "name": "a:a@1.0.0", - "docs": { - "contents": null - }, "interfaces": { "foo": 0 }, @@ -99,9 +75,6 @@ }, { "name": "a:a@2.0.0", - "docs": { - "contents": null - }, "interfaces": { "foo": 1 }, @@ -109,9 +82,6 @@ }, { "name": "foo:versions", - "docs": { - "contents": null - }, "interfaces": { "foo": 2 }, diff --git a/crates/wit-parser/tests/ui/wasi.wit.json b/crates/wit-parser/tests/ui/wasi.wit.json index 8b29d54aca..43e6102d0b 100644 --- a/crates/wit-parser/tests/ui/wasi.wit.json +++ b/crates/wit-parser/tests/ui/wasi.wit.json @@ -3,9 +3,6 @@ "interfaces": [ { "name": "wasi", - "docs": { - "contents": null - }, "types": { "clockid": 0, "timestamp": 1, @@ -17,22 +14,13 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": { "enum": { "cases": [ { - "docs": { - "contents": null - }, "name": "realtime" }, { - "docs": { - "contents": null - }, "name": "monotonic" } ] @@ -44,9 +32,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "u64" }, @@ -56,472 +41,238 @@ } }, { - "docs": { - "contents": null - }, "kind": { "enum": { "cases": [ { - "docs": { - "contents": null - }, "name": "success" }, { - "docs": { - "contents": null - }, "name": "toobig" }, { - "docs": { - "contents": null - }, "name": "access" }, { - "docs": { - "contents": null - }, "name": "addrinuse" }, { - "docs": { - "contents": null - }, "name": "addrnotavail" }, { - "docs": { - "contents": null - }, "name": "afnosupport" }, { - "docs": { - "contents": null - }, "name": "again" }, { - "docs": { - "contents": null - }, "name": "already" }, { - "docs": { - "contents": null - }, "name": "badf" }, { - "docs": { - "contents": null - }, "name": "badmsg" }, { - "docs": { - "contents": null - }, "name": "busy" }, { - "docs": { - "contents": null - }, "name": "canceled" }, { - "docs": { - "contents": null - }, "name": "child" }, { - "docs": { - "contents": null - }, "name": "connaborted" }, { - "docs": { - "contents": null - }, "name": "connrefused" }, { - "docs": { - "contents": null - }, "name": "connreset" }, { - "docs": { - "contents": null - }, "name": "deadlk" }, { - "docs": { - "contents": null - }, "name": "destaddrreq" }, { - "docs": { - "contents": null - }, "name": "dom" }, { - "docs": { - "contents": null - }, "name": "dquot" }, { - "docs": { - "contents": null - }, "name": "exist" }, { - "docs": { - "contents": null - }, "name": "fault" }, { - "docs": { - "contents": null - }, "name": "fbig" }, { - "docs": { - "contents": null - }, "name": "hostunreach" }, { - "docs": { - "contents": null - }, "name": "idrm" }, { - "docs": { - "contents": null - }, "name": "ilseq" }, { - "docs": { - "contents": null - }, "name": "inprogress" }, { - "docs": { - "contents": null - }, "name": "intr" }, { - "docs": { - "contents": null - }, "name": "inval" }, { - "docs": { - "contents": null - }, "name": "io" }, { - "docs": { - "contents": null - }, "name": "isconn" }, { - "docs": { - "contents": null - }, "name": "isdir" }, { - "docs": { - "contents": null - }, "name": "loop" }, { - "docs": { - "contents": null - }, "name": "mfile" }, { - "docs": { - "contents": null - }, "name": "mlink" }, { - "docs": { - "contents": null - }, "name": "msgsize" }, { - "docs": { - "contents": null - }, "name": "multihop" }, { - "docs": { - "contents": null - }, "name": "nametoolong" }, { - "docs": { - "contents": null - }, "name": "netdown" }, { - "docs": { - "contents": null - }, "name": "netreset" }, { - "docs": { - "contents": null - }, "name": "netunreach" }, { - "docs": { - "contents": null - }, "name": "nfile" }, { - "docs": { - "contents": null - }, "name": "nobufs" }, { - "docs": { - "contents": null - }, "name": "nodev" }, { - "docs": { - "contents": null - }, "name": "noent" }, { - "docs": { - "contents": null - }, "name": "noexec" }, { - "docs": { - "contents": null - }, "name": "nolck" }, { - "docs": { - "contents": null - }, "name": "nolink" }, { - "docs": { - "contents": null - }, "name": "nomem" }, { - "docs": { - "contents": null - }, "name": "nomsg" }, { - "docs": { - "contents": null - }, "name": "noprotoopt" }, { - "docs": { - "contents": null - }, "name": "nospc" }, { - "docs": { - "contents": null - }, "name": "nosys" }, { - "docs": { - "contents": null - }, "name": "notconn" }, { - "docs": { - "contents": null - }, "name": "notdir" }, { - "docs": { - "contents": null - }, "name": "notempty" }, { - "docs": { - "contents": null - }, "name": "notrecoverable" }, { - "docs": { - "contents": null - }, "name": "notsock" }, { - "docs": { - "contents": null - }, "name": "notsup" }, { - "docs": { - "contents": null - }, "name": "notty" }, { - "docs": { - "contents": null - }, "name": "nxio" }, { - "docs": { - "contents": null - }, "name": "overflow" }, { - "docs": { - "contents": null - }, "name": "ownerdead" }, { - "docs": { - "contents": null - }, "name": "perm" }, { - "docs": { - "contents": null - }, "name": "pipe" }, { - "docs": { - "contents": null - }, "name": "proto" }, { - "docs": { - "contents": null - }, "name": "protonosupport" }, { - "docs": { - "contents": null - }, "name": "prototype" }, { - "docs": { - "contents": null - }, "name": "range" }, { - "docs": { - "contents": null - }, "name": "rofs" }, { - "docs": { - "contents": null - }, "name": "spipe" }, { - "docs": { - "contents": null - }, "name": "srch" }, { - "docs": { - "contents": null - }, "name": "stale" }, { - "docs": { - "contents": null - }, "name": "timedout" }, { - "docs": { - "contents": null - }, "name": "txtbsy" }, { - "docs": { - "contents": null - }, "name": "xdev" }, { - "docs": { - "contents": null - }, "name": "notcapable" } ] @@ -536,9 +287,6 @@ "packages": [ { "name": "wasi:filesystem", - "docs": { - "contents": null - }, "interfaces": { "wasi": 0 }, diff --git a/crates/wit-parser/tests/ui/world-diamond.wit.json b/crates/wit-parser/tests/ui/world-diamond.wit.json index c87c6e6a0e..75c8900e1f 100644 --- a/crates/wit-parser/tests/ui/world-diamond.wit.json +++ b/crates/wit-parser/tests/ui/world-diamond.wit.json @@ -2,9 +2,6 @@ "worlds": [ { "name": "the-world", - "docs": { - "contents": null - }, "imports": { "interface-0": { "interface": 0 @@ -17,9 +14,6 @@ }, "a": { "function": { - "docs": { - "contents": null - }, "name": "a", "kind": "freestanding", "params": [], @@ -34,9 +28,6 @@ "interfaces": [ { "name": "shared-items", - "docs": { - "contents": null - }, "types": { "foo": 0 }, @@ -45,17 +36,11 @@ }, { "name": "i1", - "docs": { - "contents": null - }, "types": { "foo": 1 }, "functions": { "a": { - "docs": { - "contents": null - }, "name": "a", "kind": "freestanding", "params": [], @@ -70,17 +55,11 @@ }, { "name": "i2", - "docs": { - "contents": null - }, "types": { "foo": 2 }, "functions": { "a": { - "docs": { - "contents": null - }, "name": "a", "kind": "freestanding", "params": [], @@ -96,9 +75,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -108,9 +84,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 0 }, @@ -120,9 +93,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 0 }, @@ -135,9 +105,6 @@ "packages": [ { "name": "foo:foo", - "docs": { - "contents": null - }, "interfaces": { "shared-items": 0, "i1": 1, diff --git a/crates/wit-parser/tests/ui/world-iface-no-collide.wit.json b/crates/wit-parser/tests/ui/world-iface-no-collide.wit.json index 5ad69d83ae..9d705deeef 100644 --- a/crates/wit-parser/tests/ui/world-iface-no-collide.wit.json +++ b/crates/wit-parser/tests/ui/world-iface-no-collide.wit.json @@ -2,9 +2,6 @@ "worlds": [ { "name": "bar", - "docs": { - "contents": null - }, "imports": { "interface-0": { "interface": 0 @@ -14,9 +11,6 @@ }, "foo": { "function": { - "docs": { - "contents": null - }, "name": "foo", "kind": "freestanding", "params": [], @@ -31,9 +25,6 @@ "interfaces": [ { "name": "foo", - "docs": { - "contents": null - }, "types": { "t": 0 }, @@ -43,9 +34,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -55,9 +43,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 0 }, @@ -70,9 +55,6 @@ "packages": [ { "name": "foo:foo", - "docs": { - "contents": null - }, "interfaces": { "foo": 0 }, diff --git a/crates/wit-parser/tests/ui/world-implicit-import1.wit.json b/crates/wit-parser/tests/ui/world-implicit-import1.wit.json index 50eb58b252..03bfab3251 100644 --- a/crates/wit-parser/tests/ui/world-implicit-import1.wit.json +++ b/crates/wit-parser/tests/ui/world-implicit-import1.wit.json @@ -2,9 +2,6 @@ "worlds": [ { "name": "the-world", - "docs": { - "contents": null - }, "imports": { "interface-0": { "interface": 0 @@ -23,9 +20,6 @@ "interfaces": [ { "name": "foo", - "docs": { - "contents": null - }, "types": { "a": 0 }, @@ -34,9 +28,6 @@ }, { "name": null, - "docs": { - "contents": null - }, "types": { "a": 1 }, @@ -45,9 +36,6 @@ }, { "name": null, - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 0 @@ -55,9 +43,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -67,9 +52,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 0 }, @@ -82,9 +64,6 @@ "packages": [ { "name": "foo:foo", - "docs": { - "contents": null - }, "interfaces": { "foo": 0 }, diff --git a/crates/wit-parser/tests/ui/world-implicit-import2.wit.json b/crates/wit-parser/tests/ui/world-implicit-import2.wit.json index d675126eb3..7bd1a87146 100644 --- a/crates/wit-parser/tests/ui/world-implicit-import2.wit.json +++ b/crates/wit-parser/tests/ui/world-implicit-import2.wit.json @@ -2,9 +2,6 @@ "worlds": [ { "name": "w", - "docs": { - "contents": null - }, "imports": { "interface-0": { "interface": 0 @@ -14,9 +11,6 @@ }, "foo": { "function": { - "docs": { - "contents": null - }, "name": "foo", "kind": "freestanding", "params": [], @@ -35,9 +29,6 @@ "interfaces": [ { "name": "foo", - "docs": { - "contents": null - }, "types": { "g": 0 }, @@ -47,9 +38,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": { "type": "char" }, @@ -59,9 +47,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 0 }, @@ -74,9 +59,6 @@ "packages": [ { "name": "foo:foo", - "docs": { - "contents": null - }, "interfaces": { "foo": 0 }, diff --git a/crates/wit-parser/tests/ui/world-implicit-import3.wit.json b/crates/wit-parser/tests/ui/world-implicit-import3.wit.json index 450a23af04..3dcbde535f 100644 --- a/crates/wit-parser/tests/ui/world-implicit-import3.wit.json +++ b/crates/wit-parser/tests/ui/world-implicit-import3.wit.json @@ -2,9 +2,6 @@ "worlds": [ { "name": "w", - "docs": { - "contents": null - }, "imports": { "interface-0": { "interface": 0 @@ -16,9 +13,6 @@ "exports": { "foo": { "function": { - "docs": { - "contents": null - }, "name": "foo", "kind": "freestanding", "params": [], @@ -36,9 +30,6 @@ "interfaces": [ { "name": "foo", - "docs": { - "contents": null - }, "types": { "g": 0 }, @@ -48,9 +39,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": { "type": "char" }, @@ -60,9 +48,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 0 }, @@ -75,9 +60,6 @@ "packages": [ { "name": "foo:foo", - "docs": { - "contents": null - }, "interfaces": { "foo": 0 }, diff --git a/crates/wit-parser/tests/ui/world-same-fields4.wit.json b/crates/wit-parser/tests/ui/world-same-fields4.wit.json index c156687a70..83bb910d57 100644 --- a/crates/wit-parser/tests/ui/world-same-fields4.wit.json +++ b/crates/wit-parser/tests/ui/world-same-fields4.wit.json @@ -2,9 +2,6 @@ "worlds": [ { "name": "foo", - "docs": { - "contents": null - }, "imports": { "shared-items": { "interface": 1 @@ -24,9 +21,6 @@ "interfaces": [ { "name": "shared-items", - "docs": { - "contents": null - }, "types": { "a": 0 }, @@ -35,18 +29,12 @@ }, { "name": null, - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 0 }, { "name": null, - "docs": { - "contents": null - }, "types": { "a": 1 }, @@ -56,9 +44,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -68,9 +53,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 0 }, @@ -83,9 +65,6 @@ "packages": [ { "name": "foo:foo", - "docs": { - "contents": null - }, "interfaces": { "shared-items": 0 }, diff --git a/crates/wit-parser/tests/ui/world-top-level-funcs.wit.json b/crates/wit-parser/tests/ui/world-top-level-funcs.wit.json index c694982f0c..43401ee367 100644 --- a/crates/wit-parser/tests/ui/world-top-level-funcs.wit.json +++ b/crates/wit-parser/tests/ui/world-top-level-funcs.wit.json @@ -2,15 +2,9 @@ "worlds": [ { "name": "foo", - "docs": { - "contents": null - }, "imports": { "foo": { "function": { - "docs": { - "contents": null - }, "name": "foo", "kind": "freestanding", "params": [], @@ -19,9 +13,6 @@ }, "bar": { "function": { - "docs": { - "contents": null - }, "name": "bar", "kind": "freestanding", "params": [ @@ -37,9 +28,6 @@ "exports": { "foo2": { "function": { - "docs": { - "contents": null - }, "name": "foo2", "kind": "freestanding", "params": [], @@ -48,9 +36,6 @@ }, "some-name": { "function": { - "docs": { - "contents": null - }, "name": "some-name", "kind": "freestanding", "params": [], @@ -68,9 +53,6 @@ "interfaces": [], "types": [ { - "docs": { - "contents": null - }, "kind": { "list": "u32" }, @@ -78,9 +60,6 @@ "owner": "none" }, { - "docs": { - "contents": null - }, "kind": { "option": "u32" }, @@ -88,9 +67,6 @@ "owner": "none" }, { - "docs": { - "contents": null - }, "kind": { "list": 1 }, @@ -101,9 +77,6 @@ "packages": [ { "name": "foo:foo", - "docs": { - "contents": null - }, "interfaces": {}, "worlds": { "foo": 0 diff --git a/crates/wit-parser/tests/ui/world-top-level-resources.wit.json b/crates/wit-parser/tests/ui/world-top-level-resources.wit.json index 58d19b03e5..f869fb1a4d 100644 --- a/crates/wit-parser/tests/ui/world-top-level-resources.wit.json +++ b/crates/wit-parser/tests/ui/world-top-level-resources.wit.json @@ -2,9 +2,6 @@ "worlds": [ { "name": "proxy", - "docs": { - "contents": null - }, "imports": { "interface-0": { "interface": 0 @@ -24,18 +21,12 @@ "interfaces": [ { "name": "types", - "docs": { - "contents": null - }, "types": { "request": 0, "response": 1 }, "functions": { "[method]request.foo": { - "docs": { - "contents": null - }, "name": "[method]request.foo", "kind": { "method": 0 @@ -49,9 +40,6 @@ "results": [] }, "[method]request.bar": { - "docs": { - "contents": null - }, "name": "[method]request.bar", "kind": { "method": 0 @@ -69,9 +57,6 @@ "results": [] }, "[method]response.foo": { - "docs": { - "contents": null - }, "name": "[method]response.foo", "kind": { "method": 1 @@ -85,9 +70,6 @@ "results": [] }, "[method]response.bar": { - "docs": { - "contents": null - }, "name": "[method]response.bar", "kind": { "method": 1 @@ -109,18 +91,12 @@ }, { "name": "handler", - "docs": { - "contents": null - }, "types": { "request": 5, "response": 6 }, "functions": { "handle": { - "docs": { - "contents": null - }, "name": "handle", "kind": "freestanding", "params": [ @@ -136,9 +112,6 @@ ] }, "handle-owned": { - "docs": { - "contents": null - }, "name": "handle-owned", "kind": "freestanding", "params": [ @@ -159,9 +132,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": "resource", "name": "request", "owner": { @@ -169,9 +139,6 @@ } }, { - "docs": { - "contents": null - }, "kind": "resource", "name": "response", "owner": { @@ -179,9 +146,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "handle": { "borrow": 0 @@ -191,9 +155,6 @@ "owner": "none" }, { - "docs": { - "contents": null - }, "kind": { "list": "u32" }, @@ -201,9 +162,6 @@ "owner": "none" }, { - "docs": { - "contents": null - }, "kind": { "handle": { "borrow": 1 @@ -213,9 +171,6 @@ "owner": "none" }, { - "docs": { - "contents": null - }, "kind": { "type": 0 }, @@ -225,9 +180,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 1 }, @@ -237,9 +189,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "handle": { "borrow": 5 @@ -249,9 +198,6 @@ "owner": "none" }, { - "docs": { - "contents": null - }, "kind": { "handle": { "borrow": 6 @@ -261,9 +207,6 @@ "owner": "none" }, { - "docs": { - "contents": null - }, "kind": { "handle": { "own": 5 @@ -273,9 +216,6 @@ "owner": "none" }, { - "docs": { - "contents": null - }, "kind": { "handle": { "own": 6 @@ -288,9 +228,6 @@ "packages": [ { "name": "foo:foo", - "docs": { - "contents": null - }, "interfaces": { "types": 0, "handler": 1 diff --git a/crates/wit-parser/tests/ui/worlds-union-dedup.wit.json b/crates/wit-parser/tests/ui/worlds-union-dedup.wit.json index 75e4dba0f2..7fb8ff0ae9 100644 --- a/crates/wit-parser/tests/ui/worlds-union-dedup.wit.json +++ b/crates/wit-parser/tests/ui/worlds-union-dedup.wit.json @@ -2,9 +2,6 @@ "worlds": [ { "name": "my-world-a", - "docs": { - "contents": null - }, "imports": { "interface-0": { "interface": 0 @@ -18,9 +15,6 @@ }, { "name": "my-world-b", - "docs": { - "contents": null - }, "imports": { "interface-0": { "interface": 0 @@ -34,9 +28,6 @@ }, { "name": "union-my-world", - "docs": { - "contents": null - }, "imports": { "interface-0": { "interface": 0 @@ -52,54 +43,36 @@ "interfaces": [ { "name": "a1", - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 0 }, { "name": "a2", - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 0 }, { "name": "b1", - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 0 }, { "name": "b2", - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 0 }, { "name": "c", - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 0 }, { "name": "d", - "docs": { - "contents": null - }, "types": {}, "functions": {}, "package": 0 @@ -109,9 +82,6 @@ "packages": [ { "name": "foo:foo", - "docs": { - "contents": null - }, "interfaces": { "a1": 0, "a2": 1, diff --git a/crates/wit-parser/tests/ui/worlds-with-types.wit.json b/crates/wit-parser/tests/ui/worlds-with-types.wit.json index cb0e0ab70c..d4f85282f8 100644 --- a/crates/wit-parser/tests/ui/worlds-with-types.wit.json +++ b/crates/wit-parser/tests/ui/worlds-with-types.wit.json @@ -2,9 +2,6 @@ "worlds": [ { "name": "foo", - "docs": { - "contents": null - }, "imports": { "a": { "type": 1 @@ -16,9 +13,6 @@ "exports": { "c": { "function": { - "docs": { - "contents": null - }, "name": "c", "kind": "freestanding", "params": [ @@ -39,9 +33,6 @@ }, { "name": "bar", - "docs": { - "contents": null - }, "imports": { "interface-0": { "interface": 0 @@ -53,9 +44,6 @@ "exports": { "foo": { "function": { - "docs": { - "contents": null - }, "name": "foo", "kind": "freestanding", "params": [], @@ -71,9 +59,6 @@ }, { "name": "the-test", - "docs": { - "contents": null - }, "imports": { "a": { "type": 4 @@ -83,9 +68,6 @@ }, "foo": { "function": { - "docs": { - "contents": null - }, "name": "foo", "kind": "freestanding", "params": [ @@ -105,9 +87,6 @@ "exports": { "bar": { "function": { - "docs": { - "contents": null - }, "name": "bar", "kind": "freestanding", "params": [ @@ -130,9 +109,6 @@ "interfaces": [ { "name": "disambiguate", - "docs": { - "contents": null - }, "types": { "t": 0 }, @@ -142,9 +118,6 @@ ], "types": [ { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -154,9 +127,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": "u32" }, @@ -166,9 +136,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 1 }, @@ -178,9 +145,6 @@ } }, { - "docs": { - "contents": null - }, "kind": { "type": 0 }, @@ -190,16 +154,10 @@ } }, { - "docs": { - "contents": null - }, "kind": { "record": { "fields": [ { - "docs": { - "contents": null - }, "name": "x", "type": "u32" } @@ -212,16 +170,10 @@ } }, { - "docs": { - "contents": null - }, "kind": { "variant": { "cases": [ { - "docs": { - "contents": null - }, "name": "c", "type": 4 } @@ -237,9 +189,6 @@ "packages": [ { "name": "foo:foo", - "docs": { - "contents": null - }, "interfaces": { "disambiguate": 0 }, From be17ced3d194c72c22c6b158e66dca52ad0d8e4e Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Thu, 14 Sep 2023 12:09:09 -0700 Subject: [PATCH 38/40] wit-parser: remove SerializableVersion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This doesn’t seem to be necessary? --- crates/wit-component/src/decoding.rs | 4 +- crates/wit-component/src/validation.rs | 2 +- crates/wit-parser/src/ast.rs | 2 +- crates/wit-parser/src/lib.rs | 7 ++-- crates/wit-parser/src/version.rs | 58 -------------------------- 5 files changed, 7 insertions(+), 66 deletions(-) delete mode 100644 crates/wit-parser/src/version.rs diff --git a/crates/wit-component/src/decoding.rs b/crates/wit-component/src/decoding.rs index 32c6472d35..54e4bb53f7 100644 --- a/crates/wit-component/src/decoding.rs +++ b/crates/wit-component/src/decoding.rs @@ -296,7 +296,7 @@ impl WitPackageDecoder<'_> { } if interface.as_str() == "wit" => PackageName { namespace: namespace.to_string(), name: package.to_string(), - version: version.map(|v| v.into()), + version, }, _ => bail!("package name is not a valid id: {name}"), }, @@ -570,7 +570,7 @@ impl WitPackageDecoder<'_> { let package_name = PackageName { name: name.to_string(), namespace: namespace.to_string(), - version: version.map(|v| v.into()), + version, }; // Lazily create a `Package` as necessary, along with the interface. let package = self diff --git a/crates/wit-component/src/validation.rs b/crates/wit-component/src/validation.rs index fae8264863..c7bd5d331a 100644 --- a/crates/wit-component/src/validation.rs +++ b/crates/wit-component/src/validation.rs @@ -543,7 +543,7 @@ fn world_key(resolve: &Resolve, name: &str) -> WorldKey { PackageName { namespace: namespace.as_str().to_string(), name: package.as_str().to_string(), - version: version.map(|v| v.into()), + version, }, interface.as_str(), ), diff --git a/crates/wit-parser/src/ast.rs b/crates/wit-parser/src/ast.rs index c506f7c784..465517718a 100644 --- a/crates/wit-parser/src/ast.rs +++ b/crates/wit-parser/src/ast.rs @@ -170,7 +170,7 @@ impl<'a> PackageName<'a> { crate::PackageName { namespace: self.namespace.name.to_string(), name: self.name.name.to_string(), - version: self.version.as_ref().map(|(_, v)| v.clone().into()), + version: self.version.as_ref().map(|(_, v)| v.clone()), } } } diff --git a/crates/wit-parser/src/lib.rs b/crates/wit-parser/src/lib.rs index 30afeab37e..d39eb0ff81 100644 --- a/crates/wit-parser/src/lib.rs +++ b/crates/wit-parser/src/lib.rs @@ -1,6 +1,7 @@ use anyhow::{Context, Result}; use id_arena::{Arena, Id}; use indexmap::IndexMap; +use semver::Version; use serde::Serialize; use std::borrow::Cow; use std::fmt; @@ -16,11 +17,9 @@ mod resolve; pub use resolve::{Package, PackageId, Remap, Resolve}; mod live; pub use live::LiveTypes; -mod version; -pub use version::SerializableVersion; mod serde_; use serde_::{ - serialize_anon_result, serialize_id, serialize_id_map, serialize_optional_id, serialize_params, + serialize_anon_result, serialize_id, serialize_id_map, serialize_optional_id, serialize_params }; /// Checks if the given string is a legal identifier in wit. @@ -129,7 +128,7 @@ pub struct PackageName { /// The kebab-name of this package, which is always specified. pub name: String, /// Optional major/minor version information. - pub version: Option, + pub version: Option, } impl From for String { diff --git a/crates/wit-parser/src/version.rs b/crates/wit-parser/src/version.rs deleted file mode 100644 index 9def339e39..0000000000 --- a/crates/wit-parser/src/version.rs +++ /dev/null @@ -1,58 +0,0 @@ -use semver::Version; -use serde::{Deserialize, Deserializer, Serialize, Serializer}; - -#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)] -pub struct SerializableVersion(Version); - -impl<'de> Deserialize<'de> for SerializableVersion { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - let s = String::deserialize(deserializer)?; - Version::parse(&s) - .map(SerializableVersion) - .map_err(serde::de::Error::custom) - } -} - -impl Serialize for SerializableVersion { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - // Assuming there's a method to convert Version to a string representation - let s = self.0.to_string(); - serializer.serialize_str(&s) - } -} - -impl From for Version { - fn from(v: SerializableVersion) -> Self { - v.0 - } -} - -impl From for SerializableVersion { - fn from(v: Version) -> Self { - SerializableVersion(v) - } -} - -impl AsRef for SerializableVersion { - fn as_ref(&self) -> &Version { - &self.0 - } -} - -impl AsMut for SerializableVersion { - fn as_mut(&mut self) -> &mut Version { - &mut self.0 - } -} - -impl std::fmt::Display for SerializableVersion { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - self.0.to_string().fmt(f) - } -} From b896b0b89d98bebf85b8b158f74f164b80d8f160 Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Thu, 14 Sep 2023 12:17:25 -0700 Subject: [PATCH 39/40] wit-parser: revert formatting changes PR feedback on wasm-tools#1177 --- Cargo.toml | 27 +++++++++++++++++++++++++-- crates/wit-component/src/decoding.rs | 2 +- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9c214c169b..3a243ede25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -134,7 +134,23 @@ harness = false [features] # By default, all subcommands are built -default = ['shrink', 'smith', 'mutate', 'validate', 'print', 'parse', 'dump', 'objdump', 'strip', 'compose', 'demangle', 'component', 'metadata', 'wit-smith', 'addr2line'] +default = [ + 'shrink', + 'smith', + 'mutate', + 'validate', + 'print', + 'parse', + 'dump', + 'objdump', + 'strip', + 'compose', + 'demangle', + 'component', + 'metadata', + 'wit-smith', + 'addr2line', +] # Each subcommand is gated behind a feature and lists the dependencies it needs validate = ['dep:wasmparser', 'rayon'] @@ -148,7 +164,14 @@ objdump = ['dep:wasmparser'] strip = ['wasm-encoder', 'dep:wasmparser', 'regex'] compose = ['wasm-compose', 'dep:wasmparser'] demangle = ['rustc-demangle', 'cpp_demangle', 'dep:wasmparser', 'wasm-encoder'] -component = ['wit-component', 'wit-parser', 'wast', 'wasm-encoder', 'dep:wasmparser', 'serde_json'] +component = [ + 'wit-component', + 'wit-parser', + 'wast', + 'wasm-encoder', + 'dep:wasmparser', + 'serde_json', +] metadata = ['dep:wasmparser', 'wasm-metadata', 'serde_json'] wit-smith = ['dep:wit-smith', 'arbitrary'] addr2line = ['dep:addr2line', 'dep:gimli', 'dep:wasmparser'] diff --git a/crates/wit-component/src/decoding.rs b/crates/wit-component/src/decoding.rs index 54e4bb53f7..cee84d0bf1 100644 --- a/crates/wit-component/src/decoding.rs +++ b/crates/wit-component/src/decoding.rs @@ -562,8 +562,8 @@ impl WitPackageDecoder<'_> { KebabNameKind::Id { namespace, package, - interface, version, + interface, } => (namespace, package, version, interface), _ => bail!("package name is not a valid id: {name_string}"), }; From c00906b332394d16c8adc3a204598668b7c74d6c Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Thu, 14 Sep 2023 12:45:16 -0700 Subject: [PATCH 40/40] wit-parser: rustfmt --- crates/wit-parser/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/wit-parser/src/lib.rs b/crates/wit-parser/src/lib.rs index d39eb0ff81..b1bb63709d 100644 --- a/crates/wit-parser/src/lib.rs +++ b/crates/wit-parser/src/lib.rs @@ -19,7 +19,7 @@ mod live; pub use live::LiveTypes; mod serde_; use serde_::{ - serialize_anon_result, serialize_id, serialize_id_map, serialize_optional_id, serialize_params + serialize_anon_result, serialize_id, serialize_id_map, serialize_optional_id, serialize_params, }; /// Checks if the given string is a legal identifier in wit.