From b55862f3dafe8276faad9309cebff2cdcaec8ea3 Mon Sep 17 00:00:00 2001 From: Dominik Nakamura Date: Fri, 29 Sep 2023 19:33:01 +0900 Subject: [PATCH] feat: create playground crate and fix issues --- Cargo.lock | 193 +++++++----------- crates/stef-benches/Cargo.toml | 5 +- crates/stef-build/Cargo.toml | 12 +- crates/stef-build/src/decode.rs | 12 +- crates/stef-build/src/definition.rs | 38 ++-- crates/stef-build/src/lib.rs | 23 ++- .../compiler__compile@enum-basic.stef.snap | 16 +- .../compiler__compile@enum-generics.stef.snap | 16 +- .../compiler__compile@enum-many-ws.stef.snap | 16 +- .../compiler__compile@enum-min-ws.stef.snap | 24 +-- .../compiler__compile@module-basic.stef.snap | 4 +- .../compiler__compile@schema-basic.stef.snap | 24 +-- .../compiler__compile@struct-basic.stef.snap | 8 +- ...ompiler__compile@struct-generics.stef.snap | 8 +- ...compiler__compile@struct-many-ws.stef.snap | 8 +- .../compiler__compile@struct-min-ws.stef.snap | 12 +- .../compiler__compile@types-basic.stef.snap | 84 ++++---- .../compiler__compile@types-generic.stef.snap | 16 +- .../compiler__compile@types-nested.stef.snap | 4 +- .../compiler__compile@types-ref.stef.snap | 8 +- crates/stef-cli/Cargo.toml | 5 +- crates/stef-compiler/Cargo.toml | 1 - crates/stef-derive/Cargo.toml | 4 +- crates/stef-parser/Cargo.toml | 5 +- crates/stef-playground/Cargo.toml | 17 ++ crates/stef-playground/build.rs | 3 + crates/stef-playground/src/main.rs | 7 + crates/stef-playground/src/sample.stef | 6 + crates/stef/Cargo.toml | 2 +- crates/stef/src/lib.rs | 2 +- deny.toml | 6 +- vscode-extension/pnpm-lock.yaml | 6 +- 32 files changed, 293 insertions(+), 302 deletions(-) create mode 100644 crates/stef-playground/Cargo.toml create mode 100644 crates/stef-playground/build.rs create mode 100644 crates/stef-playground/src/main.rs create mode 100644 crates/stef-playground/src/sample.stef diff --git a/Cargo.lock b/Cargo.lock index d2d26fe..7be2306 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aho-corasick" -version = "1.0.5" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783" +checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab" dependencies = [ "memchr", ] @@ -34,9 +34,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstream" -version = "0.5.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" +checksum = "f6cd65a4b849ace0b7f6daeebcc1a1d111282227ca745458c61dbf670e52a597" dependencies = [ "anstyle", "anstyle-parse", @@ -48,15 +48,15 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b84bf0a05bbb2a83e5eb6fa36bb6e87baa08193c35ff52bbf6b38d8af2890e46" +checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" [[package]] name = "anstyle-parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" dependencies = [ "utf8parse", ] @@ -72,9 +72,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "2.1.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" +checksum = "0238ca56c96dfa37bdf7c373c8886dd591322500aceeeccdb2216fe06dc2f796" dependencies = [ "anstyle", "windows-sys 0.48.0", @@ -112,12 +112,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.4.0" @@ -136,9 +130,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "bytes" @@ -196,9 +190,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.3" +version = "4.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84ed82781cea27b43c9b106a979fe450a13a31aab0500595fb3fc06616de08e6" +checksum = "d04704f56c2cde07f43e8e2c154b43f216dc5c92fc98ada720177362f953b956" dependencies = [ "clap_builder", "clap_derive", @@ -206,15 +200,15 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.2" +version = "4.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08" +checksum = "0e231faeaca65ebd1ea3c737966bf858971cd38c3849107aa3ea7de90a804e45" dependencies = [ "anstream", "anstyle", "clap_lex", "strsim", - "terminal_size 0.2.6", + "terminal_size 0.3.0", ] [[package]] @@ -302,16 +296,6 @@ dependencies = [ "itertools", ] -[[package]] -name = "crossbeam-channel" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - [[package]] name = "crossbeam-deque" version = "0.8.3" @@ -442,9 +426,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" [[package]] name = "indenter" @@ -454,15 +438,15 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "indoc" -version = "2.0.3" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c785eefb63ebd0e33416dfcb8d6da0bf27ce752843a45632a67bf10d4d4b5c4" +checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" [[package]] name = "insta" -version = "1.31.0" +version = "1.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0770b0a3d4c70567f0d58331f3088b0e4c4f56c9b8d764efe654b4a5d46de3a" +checksum = "1aa511b2e298cd49b1856746f6bb73e17036bcd66b25f5e92cdcdbec9bd75686" dependencies = [ "console", "globset", @@ -473,25 +457,14 @@ dependencies = [ "yaml-rust", ] -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi 0.3.2", - "libc", - "windows-sys 0.48.0", -] - [[package]] name = "is-terminal" version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "hermit-abi 0.3.2", - "rustix 0.38.13", + "hermit-abi 0.3.3", + "rustix", "windows-sys 0.48.0", ] @@ -533,15 +506,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" [[package]] name = "libmimalloc-sys" -version = "0.1.34" +version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25d058a81af0d1c22d7a1c948576bee6d673f7af3c0f35564abd6c81122f513d" +checksum = "3979b5c37ece694f1f5e51e7ecc871fdb0f517ed04ee45f88d15d6d553cb9664" dependencies = [ "cc", "libc", @@ -553,12 +526,6 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" -[[package]] -name = "linux-raw-sys" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" - [[package]] name = "linux-raw-sys" version = "0.4.7" @@ -596,7 +563,7 @@ dependencies = [ "miette-derive", "once_cell", "owo-colors", - "supports-color 2.0.0", + "supports-color 2.1.0", "supports-hyperlinks", "supports-unicode", "terminal_size 0.1.17", @@ -618,9 +585,9 @@ dependencies = [ [[package]] name = "mimalloc" -version = "0.1.38" +version = "0.1.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "972e5f23f6716f62665760b0f4cbf592576a80c7b879ba9beaafc0e558894127" +checksum = "fa01922b5ea280a911e323e4d2fd24b7fe5cc4042e0d2cda3c40775cdc4bdc9c" dependencies = [ "libmimalloc-sys", ] @@ -643,16 +610,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi 0.3.2", - "libc", -] - [[package]] name = "object" version = "0.32.1" @@ -739,9 +696,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" dependencies = [ "unicode-ident", ] @@ -757,9 +714,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" +checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" dependencies = [ "either", "rayon-core", @@ -767,14 +724,12 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" +checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" dependencies = [ - "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "num_cpus", ] [[package]] @@ -814,28 +769,14 @@ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustix" -version = "0.37.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" -dependencies = [ - "bitflags 1.3.2", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys 0.3.8", - "windows-sys 0.48.0", -] - -[[package]] -name = "rustix" -version = "0.38.13" +version = "0.38.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7db8590df6dfcd144d22afd1b83b36c21a18d7cbc1dc4bb5295a8712e9eb662" +checksum = "747c788e9ce8e92b12cd485c49ddf90723550b654b32508f979b71a7b1ecda4f" dependencies = [ - "bitflags 2.4.0", + "bitflags", "errno", "libc", - "linux-raw-sys 0.4.7", + "linux-raw-sys", "windows-sys 0.48.0", ] @@ -882,9 +823,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.106" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cc66a619ed80bf7a0f6b17dd063a84b88f6dea1813737cf469aef1d081142c2" +checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ "itoa", "ryu", @@ -899,9 +840,9 @@ checksum = "420acb44afdae038210c99e69aae24109f32f15500aa708e81d46c9f29d55fcf" [[package]] name = "smawk" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f67ad224767faa3c7d8b6d91985b78e70a1324408abcb1cfcc2be4c06bc06043" +checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" [[package]] name = "stef" @@ -979,6 +920,14 @@ dependencies = [ "winnow", ] +[[package]] +name = "stef-playground" +version = "0.1.0" +dependencies = [ + "stef", + "stef-build", +] + [[package]] name = "strsim" version = "0.10.0" @@ -997,9 +946,9 @@ dependencies = [ [[package]] name = "supports-color" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4950e7174bffabe99455511c39707310e7e9b440364a2fcb1cc21521be57b354" +checksum = "d6398cde53adc3c4557306a96ce67b302968513830a77a95b2b17305d9719a89" dependencies = [ "is-terminal", "is_ci", @@ -1025,9 +974,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.32" +version = "2.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2" +checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" dependencies = [ "proc-macro2", "quote", @@ -1046,11 +995,11 @@ dependencies = [ [[package]] name = "terminal_size" -version = "0.2.6" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e6bf6f19e9f8ed8d4048dc22981458ebcf406d67e94cd422e5ecd73d63b3237" +checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" dependencies = [ - "rustix 0.37.23", + "rustix", "windows-sys 0.48.0", ] @@ -1067,18 +1016,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.48" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7" +checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.48" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" +checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" dependencies = [ "proc-macro2", "quote", @@ -1097,9 +1046,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-linebreak" @@ -1109,9 +1058,9 @@ checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" [[package]] name = "unicode-width" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" [[package]] name = "utf8parse" @@ -1211,9 +1160,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ "winapi", ] diff --git a/crates/stef-benches/Cargo.toml b/crates/stef-benches/Cargo.toml index 74ff601..b557e04 100644 --- a/crates/stef-benches/Cargo.toml +++ b/crates/stef-benches/Cargo.toml @@ -8,7 +8,6 @@ readme.workspace = true homepage.workspace = true repository.workspace = true license.workspace = true -include = ["src/**/*"] publish = false [[bench]] @@ -20,10 +19,10 @@ name = "varint" harness = false [dependencies] -mimalloc = "0.1.38" +mimalloc = "0.1.39" stef-parser = { path = "../stef-parser" } [dev-dependencies] criterion = "0.5.1" -indoc = "2.0.3" +indoc = "2.0.4" serde = "1.0.188" diff --git a/crates/stef-build/Cargo.toml b/crates/stef-build/Cargo.toml index 0558c27..b441b6a 100644 --- a/crates/stef-build/Cargo.toml +++ b/crates/stef-build/Cargo.toml @@ -11,15 +11,15 @@ license.workspace = true [dependencies] miette.workspace = true -proc-macro2 = { version = "1.0.66", default-features = false } +prettyplease = "0.2.15" +proc-macro2 = { version = "1.0.67", default-features = false } quote = { version = "1.0.33", default-features = false } stef-parser = { path = "../stef-parser" } -thiserror = "1.0.48" +syn = "2.0.37" +thiserror = "1.0.49" [dev-dependencies] -indoc = "2.0.3" -insta = { version = "1.31.0", features = ["glob"] } +indoc = "2.0.4" +insta = { version = "1.33.0", features = ["glob"] } pretty_assertions = "1.4.0" -prettyplease = "0.2.15" stef = { path = "../stef" } -syn = "2.0.32" diff --git a/crates/stef-build/src/decode.rs b/crates/stef-build/src/decode.rs index 8ac1238..b45b01a 100644 --- a/crates/stef-build/src/decode.rs +++ b/crates/stef-build/src/decode.rs @@ -23,7 +23,7 @@ pub fn compile_struct( quote! { #field_vars - loop{ + loop { match ::stef::buf::decode_id(r)? { ::stef::buf::END_MARKER => break, #field_matches @@ -90,7 +90,7 @@ fn compile_variant( #id => { #field_vars - loop{ + loop { match ::stef::buf::decode_id(r)? { ::stef::buf::END_MARKER => break, #field_matches @@ -179,10 +179,10 @@ fn compile_field_assigns(fields: &Fields<'_>) -> TokenStream { if matches!(named.ty, DataType::Option(_)) { quote! { #name } } else { - quote! { #name: #name.unwrap_or_else(|| ::stef::buf::Error::MissingField { + quote! { #name: #name.ok_or(::stef::buf::Error::MissingField { id: #id, name: Some(#name_lit), - }) } + })? } } }); @@ -196,10 +196,10 @@ fn compile_field_assigns(fields: &Fields<'_>) -> TokenStream { if matches!(unnamed.ty, DataType::Option(_)) { quote! { #name } } else { - quote! { #name.unwrap_or_else(|| ::stef::buf::Error::MissingField { + quote! { #name.ok_or(::stef::buf::Error::MissingField { id: #id, name: None, - }) } + })? } } }); diff --git a/crates/stef-build/src/definition.rs b/crates/stef-build/src/definition.rs index baa562d..2a8770d 100644 --- a/crates/stef-build/src/definition.rs +++ b/crates/stef-build/src/definition.rs @@ -426,20 +426,20 @@ mod tests { } Ok(Self { field1: field1 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 1, name: Some("field1"), - }), + })?, field2: field2 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 2, name: Some("field2"), - }), + })?, field3: field3 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 3, name: Some("field3"), - }), + })?, }) } } @@ -498,15 +498,7 @@ mod tests { impl ::stef::Decode for Sample { fn decode(r: &mut impl ::stef::Buf) -> ::stef::buf::Result { match ::stef::buf::decode_id(r)? { - 1 => { - loop { - match ::stef::buf::decode_id(r)? { - ::stef::buf::END_MARKER => break, - _ => continue, - } - } - Ok(Self::Variant1) - } + 1 => Ok(Self::Variant1), 2 => { let mut n0: Option = None; let mut n1: Option = None; @@ -521,15 +513,15 @@ mod tests { Ok( Self::Variant2( n0 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 1, name: None, - }), + })?, n1 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 2, name: None, - }), + })?, ), ) } @@ -546,15 +538,15 @@ mod tests { } Ok(Self::Variant3 { field1: field1 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 1, name: Some("field1"), - }), + })?, field2: field2 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 2, name: Some("field2"), - }), + })?, }) } id => Err(Error::UnknownVariant(id)), diff --git a/crates/stef-build/src/lib.rs b/crates/stef-build/src/lib.rs index 1935a1a..22b4328 100644 --- a/crates/stef-build/src/lib.rs +++ b/crates/stef-build/src/lib.rs @@ -22,19 +22,36 @@ pub enum Error { source: std::io::Error, file: PathBuf, }, + #[error("failed parsing schema from {file:?}: {message}")] + Parse { message: String, file: PathBuf }, } pub fn compile(schemas: &[impl AsRef], _includes: &[impl AsRef]) -> Result<()> { + let out_dir = PathBuf::from(std::env::var_os("OUT_DIR").unwrap()); + for schema in schemas { - let input = std::fs::read_to_string(schema).map_err(|e| Error::Read { + let path = schema.as_ref(); + + let input = std::fs::read_to_string(path).map_err(|e| Error::Read { source: e, - file: schema.as_ref().to_owned(), + file: path.to_owned(), })?; - let schema = Schema::parse(&input).unwrap(); + let schema = Schema::parse(&input).map_err(|e| Error::Parse { + message: e.to_string(), + file: path.to_owned(), + })?; let code = definition::compile_schema(&schema); + let code = prettyplease::unparse(&syn::parse2(code).unwrap()); println!("{code}"); + + let out_file = out_dir.join(format!( + "{}.rs", + path.file_stem().unwrap().to_str().unwrap() + )); + + std::fs::write(out_file, code).unwrap(); } Ok(()) diff --git a/crates/stef-build/tests/snapshots/compiler__compile@enum-basic.stef.snap b/crates/stef-build/tests/snapshots/compiler__compile@enum-basic.stef.snap index 6f3a856..5c3f0fd 100644 --- a/crates/stef-build/tests/snapshots/compiler__compile@enum-basic.stef.snap +++ b/crates/stef-build/tests/snapshots/compiler__compile@enum-basic.stef.snap @@ -59,15 +59,15 @@ impl ::stef::Decode for Sample { Ok( Self::Two( n0 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 1, name: None, - }), + })?, n1 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 2, name: None, - }), + })?, ), ) } @@ -84,15 +84,15 @@ impl ::stef::Decode for Sample { } Ok(Self::Three { field1: field1 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 1, name: Some("field1"), - }), + })?, field2: field2 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 2, name: Some("field2"), - }), + })?, }) } id => Err(Error::UnknownVariant(id)), diff --git a/crates/stef-build/tests/snapshots/compiler__compile@enum-generics.stef.snap b/crates/stef-build/tests/snapshots/compiler__compile@enum-generics.stef.snap index cd16e44..0b44265 100644 --- a/crates/stef-build/tests/snapshots/compiler__compile@enum-generics.stef.snap +++ b/crates/stef-build/tests/snapshots/compiler__compile@enum-generics.stef.snap @@ -58,15 +58,15 @@ where Ok( Self::Two( n0 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 1, name: None, - }), + })?, n1 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 2, name: None, - }), + })?, ), ) } @@ -83,15 +83,15 @@ where } Ok(Self::Three { field1: field1 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 1, name: Some("field1"), - }), + })?, field2: field2 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 2, name: Some("field2"), - }), + })?, }) } id => Err(Error::UnknownVariant(id)), diff --git a/crates/stef-build/tests/snapshots/compiler__compile@enum-many-ws.stef.snap b/crates/stef-build/tests/snapshots/compiler__compile@enum-many-ws.stef.snap index f761cee..4a71456 100644 --- a/crates/stef-build/tests/snapshots/compiler__compile@enum-many-ws.stef.snap +++ b/crates/stef-build/tests/snapshots/compiler__compile@enum-many-ws.stef.snap @@ -54,15 +54,15 @@ impl ::stef::Decode for Sample { Ok( Self::Two( n0 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 1, name: None, - }), + })?, n1 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 2, name: None, - }), + })?, ), ) } @@ -79,15 +79,15 @@ impl ::stef::Decode for Sample { } Ok(Self::Three { field1: field1 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 1, name: Some("field1"), - }), + })?, field2: field2 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 2, name: Some("field2"), - }), + })?, }) } id => Err(Error::UnknownVariant(id)), diff --git a/crates/stef-build/tests/snapshots/compiler__compile@enum-min-ws.stef.snap b/crates/stef-build/tests/snapshots/compiler__compile@enum-min-ws.stef.snap index 3abe423..85e4aa5 100644 --- a/crates/stef-build/tests/snapshots/compiler__compile@enum-min-ws.stef.snap +++ b/crates/stef-build/tests/snapshots/compiler__compile@enum-min-ws.stef.snap @@ -63,20 +63,20 @@ where Ok( Self::Two( n0 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 1, name: None, - }), + })?, n1 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 2, name: None, - }), + })?, n2 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 3, name: None, - }), + })?, ), ) } @@ -95,20 +95,20 @@ where } Ok(Self::Three { field1: field1 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 1, name: Some("field1"), - }), + })?, field2: field2 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 2, name: Some("field2"), - }), + })?, field3: field3 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 3, name: Some("field3"), - }), + })?, }) } id => Err(Error::UnknownVariant(id)), diff --git a/crates/stef-build/tests/snapshots/compiler__compile@module-basic.stef.snap b/crates/stef-build/tests/snapshots/compiler__compile@module-basic.stef.snap index 24641fc..80e981b 100644 --- a/crates/stef-build/tests/snapshots/compiler__compile@module-basic.stef.snap +++ b/crates/stef-build/tests/snapshots/compiler__compile@module-basic.stef.snap @@ -51,10 +51,10 @@ pub mod a { } Ok(Self { value: value - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 1, name: Some("value"), - }), + })?, }) } } diff --git a/crates/stef-build/tests/snapshots/compiler__compile@schema-basic.stef.snap b/crates/stef-build/tests/snapshots/compiler__compile@schema-basic.stef.snap index c8e34e8..fd40972 100644 --- a/crates/stef-build/tests/snapshots/compiler__compile@schema-basic.stef.snap +++ b/crates/stef-build/tests/snapshots/compiler__compile@schema-basic.stef.snap @@ -28,15 +28,15 @@ impl ::stef::Decode for Sample { } Ok(Self { a: a - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 1, name: Some("a"), - }), + })?, b: b - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 2, name: Some("b"), - }), + })?, }) } } @@ -91,15 +91,15 @@ impl ::stef::Decode for Sample { Ok( Self::Two( n0 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 1, name: None, - }), + })?, n1 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 2, name: None, - }), + })?, ), ) } @@ -116,15 +116,15 @@ impl ::stef::Decode for Sample { } Ok(Self::Three { field1: field1 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 1, name: Some("field1"), - }), + })?, field2: field2 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 2, name: Some("field2"), - }), + })?, }) } id => Err(Error::UnknownVariant(id)), diff --git a/crates/stef-build/tests/snapshots/compiler__compile@struct-basic.stef.snap b/crates/stef-build/tests/snapshots/compiler__compile@struct-basic.stef.snap index d8f0ab7..f41f79a 100644 --- a/crates/stef-build/tests/snapshots/compiler__compile@struct-basic.stef.snap +++ b/crates/stef-build/tests/snapshots/compiler__compile@struct-basic.stef.snap @@ -29,15 +29,15 @@ impl ::stef::Decode for Sample { } Ok(Self { a: a - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 1, name: Some("a"), - }), + })?, b: b - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 2, name: Some("b"), - }), + })?, }) } } diff --git a/crates/stef-build/tests/snapshots/compiler__compile@struct-generics.stef.snap b/crates/stef-build/tests/snapshots/compiler__compile@struct-generics.stef.snap index 6b75f34..aca994b 100644 --- a/crates/stef-build/tests/snapshots/compiler__compile@struct-generics.stef.snap +++ b/crates/stef-build/tests/snapshots/compiler__compile@struct-generics.stef.snap @@ -36,15 +36,15 @@ where } Ok(Self { key: key - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 1, name: Some("key"), - }), + })?, value: value - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 2, name: Some("value"), - }), + })?, }) } } diff --git a/crates/stef-build/tests/snapshots/compiler__compile@struct-many-ws.stef.snap b/crates/stef-build/tests/snapshots/compiler__compile@struct-many-ws.stef.snap index 34f4e1b..e5410a9 100644 --- a/crates/stef-build/tests/snapshots/compiler__compile@struct-many-ws.stef.snap +++ b/crates/stef-build/tests/snapshots/compiler__compile@struct-many-ws.stef.snap @@ -36,15 +36,15 @@ where } Ok(Self { a: a - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 1, name: Some("a"), - }), + })?, b: b - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 2, name: Some("b"), - }), + })?, }) } } diff --git a/crates/stef-build/tests/snapshots/compiler__compile@struct-min-ws.stef.snap b/crates/stef-build/tests/snapshots/compiler__compile@struct-min-ws.stef.snap index 0f523dd..ee68143 100644 --- a/crates/stef-build/tests/snapshots/compiler__compile@struct-min-ws.stef.snap +++ b/crates/stef-build/tests/snapshots/compiler__compile@struct-min-ws.stef.snap @@ -37,20 +37,20 @@ where } Ok(Self { a: a - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 1, name: Some("a"), - }), + })?, b: b - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 2, name: Some("b"), - }), + })?, c: c - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 3, name: Some("c"), - }), + })?, }) } } diff --git a/crates/stef-build/tests/snapshots/compiler__compile@types-basic.stef.snap b/crates/stef-build/tests/snapshots/compiler__compile@types-basic.stef.snap index ffd3c91..6d668c9 100644 --- a/crates/stef-build/tests/snapshots/compiler__compile@types-basic.stef.snap +++ b/crates/stef-build/tests/snapshots/compiler__compile@types-basic.stef.snap @@ -135,110 +135,110 @@ impl ::stef::Decode for Sample { } Ok(Self { f01: f01 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 1, name: Some("f01"), - }), + })?, f02: f02 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 2, name: Some("f02"), - }), + })?, f03: f03 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 3, name: Some("f03"), - }), + })?, f04: f04 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 4, name: Some("f04"), - }), + })?, f05: f05 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 5, name: Some("f05"), - }), + })?, f06: f06 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 6, name: Some("f06"), - }), + })?, f07: f07 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 7, name: Some("f07"), - }), + })?, f08: f08 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 8, name: Some("f08"), - }), + })?, f09: f09 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 9, name: Some("f09"), - }), + })?, f10: f10 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 10, name: Some("f10"), - }), + })?, f11: f11 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 11, name: Some("f11"), - }), + })?, f12: f12 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 12, name: Some("f12"), - }), + })?, f13: f13 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 13, name: Some("f13"), - }), + })?, f14: f14 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 14, name: Some("f14"), - }), + })?, f15: f15 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 15, name: Some("f15"), - }), + })?, f16: f16 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 16, name: Some("f16"), - }), + })?, f17: f17 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 17, name: Some("f17"), - }), + })?, f18: f18 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 18, name: Some("f18"), - }), + })?, f19: f19 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 19, name: Some("f19"), - }), + })?, f20: f20 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 20, name: Some("f20"), - }), + })?, f21: f21 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 21, name: Some("f21"), - }), + })?, }) } } diff --git a/crates/stef-build/tests/snapshots/compiler__compile@types-generic.stef.snap b/crates/stef-build/tests/snapshots/compiler__compile@types-generic.stef.snap index 25d4fe8..96d12e1 100644 --- a/crates/stef-build/tests/snapshots/compiler__compile@types-generic.stef.snap +++ b/crates/stef-build/tests/snapshots/compiler__compile@types-generic.stef.snap @@ -47,26 +47,26 @@ impl ::stef::Decode for Sample { } Ok(Self { f1: f1 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 1, name: Some("f1"), - }), + })?, f2: f2 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 2, name: Some("f2"), - }), + })?, f3: f3 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 3, name: Some("f3"), - }), + })?, f4, f5: f5 - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 5, name: Some("f5"), - }), + })?, }) } } diff --git a/crates/stef-build/tests/snapshots/compiler__compile@types-nested.stef.snap b/crates/stef-build/tests/snapshots/compiler__compile@types-nested.stef.snap index c1f5e5c..7f65c18 100644 --- a/crates/stef-build/tests/snapshots/compiler__compile@types-nested.stef.snap +++ b/crates/stef-build/tests/snapshots/compiler__compile@types-nested.stef.snap @@ -23,10 +23,10 @@ impl ::stef::Decode for Sample { } Ok(Self { value: value - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 1, name: Some("value"), - }), + })?, }) } } diff --git a/crates/stef-build/tests/snapshots/compiler__compile@types-ref.stef.snap b/crates/stef-build/tests/snapshots/compiler__compile@types-ref.stef.snap index 7732a22..ec347bc 100644 --- a/crates/stef-build/tests/snapshots/compiler__compile@types-ref.stef.snap +++ b/crates/stef-build/tests/snapshots/compiler__compile@types-ref.stef.snap @@ -27,15 +27,15 @@ impl ::stef::Decode for Sample { } Ok(Self { basic: basic - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 1, name: Some("basic"), - }), + })?, with_generics: with_generics - .unwrap_or_else(|| ::stef::buf::Error::MissingField { + .ok_or(::stef::buf::Error::MissingField { id: 2, name: Some("with_generics"), - }), + })?, }) } } diff --git a/crates/stef-cli/Cargo.toml b/crates/stef-cli/Cargo.toml index 1c59460..a71ad0f 100644 --- a/crates/stef-cli/Cargo.toml +++ b/crates/stef-cli/Cargo.toml @@ -8,11 +8,10 @@ readme.workspace = true homepage.workspace = true repository.workspace = true license.workspace = true -include = ["src/**/*"] [dependencies] -clap = { version = "4.4.3", features = ["derive", "wrap_help"] } +clap = { version = "4.4.6", features = ["derive", "wrap_help"] } color-eyre.workspace = true miette = { workspace = true, features = ["fancy-no-backtrace"] } -mimalloc = "0.1.38" +mimalloc = "0.1.39" stef-parser = { path = "../stef-parser" } diff --git a/crates/stef-compiler/Cargo.toml b/crates/stef-compiler/Cargo.toml index 02baf6d..ba3843f 100644 --- a/crates/stef-compiler/Cargo.toml +++ b/crates/stef-compiler/Cargo.toml @@ -8,7 +8,6 @@ readme.workspace = true homepage.workspace = true repository.workspace = true license.workspace = true -include = ["src/**/*"] [dependencies] stef-parser = { path = "../stef-parser" } diff --git a/crates/stef-derive/Cargo.toml b/crates/stef-derive/Cargo.toml index 0ae2188..e37cefb 100644 --- a/crates/stef-derive/Cargo.toml +++ b/crates/stef-derive/Cargo.toml @@ -13,6 +13,6 @@ license.workspace = true proc-macro = true [dependencies] -proc-macro2 = "1.0.66" +proc-macro2 = "1.0.67" quote = "1.0.33" -syn = "2.0.32" +syn = "2.0.37" diff --git a/crates/stef-parser/Cargo.toml b/crates/stef-parser/Cargo.toml index c9ae261..5ea4866 100644 --- a/crates/stef-parser/Cargo.toml +++ b/crates/stef-parser/Cargo.toml @@ -8,7 +8,6 @@ readme.workspace = true homepage.workspace = true repository.workspace = true license.workspace = true -include = ["src/**/*", "tests/**/*.rs"] [package.metadata.docs.rs] rustc-args = ["--cfg", "docsrs"] @@ -20,8 +19,8 @@ stef-derive = { path = "../stef-derive" } winnow = "0.5.15" [dev-dependencies] -indoc = "2.0.3" -insta = { version = "1.31.0", features = ["glob"] } +indoc = "2.0.4" +insta = { version = "1.33.0", features = ["glob"] } miette = { workspace = true, features = ["fancy-no-backtrace"] } [features] diff --git a/crates/stef-playground/Cargo.toml b/crates/stef-playground/Cargo.toml new file mode 100644 index 0000000..0dbc0f6 --- /dev/null +++ b/crates/stef-playground/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "stef-playground" +version.workspace = true +authors.workspace = true +edition.workspace = true +rust-version.workspace = true +readme.workspace = true +homepage.workspace = true +repository.workspace = true +license.workspace = true +publish = false + +[dependencies] +stef = { path = "../stef" } + +[build-dependencies] +stef-build = { path = "../stef-build" } diff --git a/crates/stef-playground/build.rs b/crates/stef-playground/build.rs new file mode 100644 index 0000000..15c1db0 --- /dev/null +++ b/crates/stef-playground/build.rs @@ -0,0 +1,3 @@ +fn main() { + stef_build::compile(&["src/sample.stef"], &["src/"]).unwrap(); +} diff --git a/crates/stef-playground/src/main.rs b/crates/stef-playground/src/main.rs new file mode 100644 index 0000000..e2a802c --- /dev/null +++ b/crates/stef-playground/src/main.rs @@ -0,0 +1,7 @@ +mod sample { + include!(concat!(env!("OUT_DIR"), "/sample.rs")); +} + +fn main() { + println!("Hello, world!"); +} diff --git a/crates/stef-playground/src/sample.stef b/crates/stef-playground/src/sample.stef new file mode 100644 index 0000000..0950419 --- /dev/null +++ b/crates/stef-playground/src/sample.stef @@ -0,0 +1,6 @@ +/// Basic struct. +struct Sample { + a: u32 @1, + /// Second field + b: bool @2, +} diff --git a/crates/stef/Cargo.toml b/crates/stef/Cargo.toml index 2302d84..24d9ef3 100644 --- a/crates/stef/Cargo.toml +++ b/crates/stef/Cargo.toml @@ -12,4 +12,4 @@ license.workspace = true [dependencies] bytes = "1.5.0" paste = "1.0.14" -thiserror = "1.0.48" +thiserror = "1.0.49" diff --git a/crates/stef/src/lib.rs b/crates/stef/src/lib.rs index 420c38d..e8422de 100644 --- a/crates/stef/src/lib.rs +++ b/crates/stef/src/lib.rs @@ -1,4 +1,4 @@ -pub use buf::{Buf, BufMut, Encode}; +pub use buf::{Buf, BufMut, Decode, Encode}; pub mod buf; pub mod varint; diff --git a/deny.toml b/deny.toml index a3e3e5e..8fe5475 100644 --- a/deny.toml +++ b/deny.toml @@ -1,5 +1,8 @@ all-features = true +[advisories] +ignore = ["RUSTSEC-2021-0145"] + [licenses] allow-osi-fsf-free = "both" exceptions = [ @@ -8,9 +11,10 @@ exceptions = [ [bans] skip = [ + { name = "hermit-abi", version = "0.1" }, + { name = "supports-color", version = "1" }, { name = "terminal_size", version = "0.1" }, ] skip-tree = [ - { name = "rustix", version = "0.37", depth = 2 }, { name = "windows-sys", version = "0.45", depth = 3 }, ] diff --git a/vscode-extension/pnpm-lock.yaml b/vscode-extension/pnpm-lock.yaml index 2d424ae..6d6caee 100644 --- a/vscode-extension/pnpm-lock.yaml +++ b/vscode-extension/pnpm-lock.yaml @@ -604,8 +604,8 @@ packages: dev: true optional: true - /sax@1.2.4: - resolution: {integrity: sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==} + /sax@1.3.0: + resolution: {integrity: sha512-0s+oAmw9zLl1V1cS9BtZN7JAd0cW5e0QH4W3LWEK6a4LaLEA2OTpGYWDY+6XasBLtz6wkm3u1xRw95mRuJ59WA==} dev: true /semver@5.7.2: @@ -745,7 +745,7 @@ packages: resolution: {integrity: sha512-drPFnkQJik/O+uPKpqSgr22mpuFHqKdbS835iAQrUC73L2F5WkboIRd63ai/2Yg6I1jzifPFKH2NTK+cfglkIA==} engines: {node: '>=4.0.0'} dependencies: - sax: 1.2.4 + sax: 1.3.0 xmlbuilder: 11.0.1 dev: true