From 62a8a2edf792e81aa1ccaf70713814b5863b8ea1 Mon Sep 17 00:00:00 2001 From: Yan Chen Date: Sun, 16 Aug 2026 15:39:28 -0700 Subject: [PATCH 1/4] add CLI flag --- Cargo.lock | 471 ++++++++++-------- Cargo.toml | 23 +- crates/guest-rust/macro/src/lib.rs | 15 +- crates/rust/tests/codegen.rs | 12 + .../canonical-version/deps/my-dep/root.wit | 9 + .../rust/tests/wit/canonical-version/root.wit | 5 + src/bin/wit-bindgen.rs | 9 + 7 files changed, 337 insertions(+), 207 deletions(-) create mode 100644 crates/rust/tests/wit/canonical-version/deps/my-dep/root.wit create mode 100644 crates/rust/tests/wit/canonical-version/root.wit diff --git a/Cargo.lock b/Cargo.lock index 778453fa6..b40460807 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -22,9 +22,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" dependencies = [ "memchr", ] @@ -87,9 +87,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.102" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" +checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" [[package]] name = "arraydeque" @@ -117,9 +117,15 @@ checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" [[package]] name = "bitflags" -version = "2.13.0" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8" +checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da" [[package]] name = "bumpalo" @@ -129,9 +135,9 @@ checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" [[package]] name = "bytes" -version = "1.11.1" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" [[package]] name = "cfg-if" @@ -141,9 +147,9 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "clap" -version = "4.6.1" +version = "4.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ddb117e43bbf7dacf0a4190fef4d345b9bad68dfc649cb349e7d17d28428e51" +checksum = "473c7e07f409a8d772161724aa8db6a765a2532a70f9667eeb7b49d3d02fbdca" dependencies = [ "clap_builder", "clap_derive", @@ -151,9 +157,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.6.0" +version = "4.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f" +checksum = "7b48fea5a88e9ae728a2dcbedbfc0e730f7d60da42e1cb049a83c9fb8b789889" dependencies = [ "anstream", "anstyle", @@ -164,14 +170,14 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.6.1" +version = "4.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2ce8604710f6733aa641a2b3731eaa1e8b3d9973d5e3565da11800813f997a9" +checksum = "d012d2b9d65aca7f18f4d9878a045bc17899bba951561ba5ec3c2ba1eed9a061" dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 3.0.3", ] [[package]] @@ -203,15 +209,46 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "defmt" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2953bfe4f93bbd20cc71198842756f77d161884c99ebbabc41d80231ded88d1" +dependencies = [ + "bitflags 1.3.2", + "defmt-macros", +] + +[[package]] +name = "defmt-macros" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bad9c72e7ca2137e0dc3813245a0d282fd6daad32fd800af018306a9169b5fe8" +dependencies = [ + "defmt-parser", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "defmt-parser" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10d60334b3b2e7c9d91ef8150abfb6fa4c1c39ebbcf4a81c2e346aad939fee3e" +dependencies = [ + "thiserror 2.0.20", +] + [[package]] name = "displaydoc" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ac70aa55017e108007fbaf5aa0f54b021c98f92ff8af59d42eda9da96e3dd4f" +checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.3", ] [[package]] @@ -225,9 +262,9 @@ dependencies = [ [[package]] name = "env_filter" -version = "1.0.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32e90c2accc4b07a8456ea0debdc2e7587bdd890680d71173a15d4ae604f6eef" +checksum = "900d271a03799a1ee8d1ca9b19893b48ca674a9284fefcfb85f05e74ed314217" dependencies = [ "log", "regex", @@ -235,9 +272,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.11.10" +version = "0.11.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0621c04f2196ac3f488dd583365b9c09be011a4ab8b9f37248ffcc8f6198b56a" +checksum = "de671bd27a75a797dc9ae289ba1e77276e75e2026408aab65185384e2d5cd3f6" dependencies = [ "anstream", "anstyle", @@ -307,9 +344,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.32" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b147ee9d1f6d097cef9ce628cd2ee62288d963e16fb287bd9286455b241382d" +checksum = "9a31d2a3fbaaeb2af2368bbdd904aa8e812d3c04a1ee10d3171f52d556e5d0a3" dependencies = [ "futures-channel", "futures-core", @@ -322,9 +359,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.32" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" +checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" dependencies = [ "futures-core", "futures-sink", @@ -332,15 +369,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.32" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" [[package]] name = "futures-executor" -version = "0.3.32" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf29c38818342a3b26b5b923639e7b1f4a61fc5e76102d4b1981c6dc7a7579d" +checksum = "031b47cf1a3c6cc8bc2fc76cd437f521619387907d469316e7c0bc278f1f5432" dependencies = [ "futures-core", "futures-task", @@ -349,38 +386,38 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.32" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" +checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" [[package]] name = "futures-macro" -version = "0.3.32" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" +checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.3", ] [[package]] name = "futures-sink" -version = "0.3.32" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" +checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d" [[package]] name = "futures-task" -version = "0.3.32" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" [[package]] name = "futures-util" -version = "0.3.32" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" dependencies = [ "futures-channel", "futures-core", @@ -431,9 +468,9 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "icu_collections" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2984d1cd16c883d7935b9e07e44071dca8d917fd52ecc02c04d5fa0b5a3f191c" +checksum = "fa68d21081c4a05d5a901a1c62add574c77048b6a1c67be3b50ce0b60d4ca513" dependencies = [ "displaydoc", "potential_utf", @@ -445,9 +482,9 @@ dependencies = [ [[package]] name = "icu_locale_core" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92219b62b3e2b4d88ac5119f8904c10f8f61bf7e95b640d25ba3075e6cac2c29" +checksum = "d56e28588da92eee5c3201a6eff33fabdd49b62269c8938d4ff050ce4d900deb" dependencies = [ "displaydoc", "litemap", @@ -458,9 +495,9 @@ dependencies = [ [[package]] name = "icu_normalizer" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c56e5ee99d6e3d33bd91c5d85458b6005a22140021cc324cea84dd0e72cff3b4" +checksum = "12f9cf5f235641ed274641dd81c3f28d870e276763d0797aeeab72317b1c646f" dependencies = [ "icu_collections", "icu_normalizer_data", @@ -472,16 +509,17 @@ dependencies = [ [[package]] name = "icu_normalizer_data" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da3be0ae77ea334f4da67c12f149704f19f81d1adf7c51cf482943e84a2bad38" +checksum = "1563da1ed3e0b3bf3d74c9b85917ac9c56464d2f57242270c09c9e752f8021a0" [[package]] name = "icu_properties" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bee3b67d0ea5c2cca5003417989af8996f8604e34fb9ddf96208a033901e70de" +checksum = "7e7ca276ad3145661a65914e6daf131ca5120cd3dcee8f8f3214b8875184a148" dependencies = [ + "displaydoc", "icu_collections", "icu_locale_core", "icu_properties_data", @@ -492,15 +530,15 @@ dependencies = [ [[package]] name = "icu_properties_data" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e2bbb201e0c04f7b4b3e14382af113e17ba4f63e2c9d2ee626b720cbce54a14" +checksum = "e590f038c1464a96894fd6d10127e90a8be4509f56ff7ecef851b15cee0b7caa" [[package]] name = "icu_provider" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "139c4cf31c8b5f33d7e199446eff9c1e02decfc2f0eec2c8d71f65befa45b421" +checksum = "92a7ed671a6aad807a8651a2e1782a6598fda9ce5185dd8158549e95a91c6428" dependencies = [ "displaydoc", "icu_locale_core", @@ -564,10 +602,12 @@ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" [[package]] name = "jiff" -version = "0.2.28" +version = "0.2.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4603d3033e49e2b0e31229fcab20a5d40089c607d975cd9c80551dc69eed9102" +checksum = "668b7183bd07af9a4885f5c35b0cc5c83c4607a913c16b7e17291832910d2dcc" dependencies = [ + "defmt", + "jiff-core", "jiff-static", "log", "portable-atomic", @@ -575,15 +615,25 @@ dependencies = [ "serde_core", ] +[[package]] +name = "jiff-core" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7feca88439efe53da3754500c1851dedf3cb36c524dd5cf8225cc0794de95d09" +dependencies = [ + "defmt", +] + [[package]] name = "jiff-static" -version = "0.2.28" +version = "0.2.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "782d32378dddf207193ac91cefb848ad41abb58195c95168e1291227a0832b47" +checksum = "3a69dcb3a21cfb32ce1cd056169337ca284af0766dd766e7878819b251a49204" dependencies = [ + "jiff-core", "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -600,9 +650,9 @@ checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" [[package]] name = "libc" -version = "0.2.186" +version = "0.2.189" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" +checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2" [[package]] name = "libtest-mimic" @@ -624,15 +674,15 @@ checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" [[package]] name = "litemap" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92daf443525c4cce67b150400bc2316076100ce0b3686209eb8cf3c31612e6f0" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" [[package]] name = "log" -version = "0.4.32" +version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953f07c43838f8e6f9758cab68bf5bed85465e7587ebe0b823f1bcd81978ad3a" +checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad" [[package]] name = "logos" @@ -655,7 +705,7 @@ dependencies = [ "proc-macro2", "quote", "regex-syntax", - "syn", + "syn 2.0.119", ] [[package]] @@ -675,14 +725,14 @@ checksum = "59a9dbbfc75d2688ed057456ce8a3ee3f48d12eec09229f560f3643b9f275653" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] name = "memchr" -version = "2.8.1" +version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b947ae49db0d222b1dbc6b113ce7248a3fc3a6ca21b696717bfc000ba4484d8" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" [[package]] name = "miette" @@ -704,7 +754,7 @@ checksum = "db5b29714e950dbb20d5e6f74f9dcec4edbcc1067bb7f8ed198c097b8c1a818b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -753,9 +803,9 @@ checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" [[package]] name = "portable-atomic" -version = "1.13.1" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" +checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85" [[package]] name = "portable-atomic-util" @@ -768,9 +818,9 @@ dependencies = [ [[package]] name = "potential_utf" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0103b1cef7ec0cf76490e969665504990193874ea05c85ff9bab8b911d0a0564" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" dependencies = [ "zerovec", ] @@ -782,14 +832,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" dependencies = [ "proc-macro2", - "syn", + "syn 2.0.119", ] [[package]] name = "proc-macro2" -version = "1.0.106" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" dependencies = [ "unicode-ident", ] @@ -800,7 +850,7 @@ version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9f068eba8e7071c5f9511831b44f32c740d5adf574e990f946ddb53db2f314e" dependencies = [ - "bitflags", + "bitflags 2.13.1", "memchr", "pulldown-cmark-escape", "unicase", @@ -814,18 +864,18 @@ checksum = "007d8adb5ddab6f8e3f491ac63566a7d5002cc7ed73901f72057943fa71ae1ae" [[package]] name = "quote" -version = "1.0.45" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" dependencies = [ "proc-macro2", ] [[package]] name = "regex" -version = "1.12.3" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" +checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" dependencies = [ "aho-corasick", "memchr", @@ -835,9 +885,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.14" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" +checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" dependencies = [ "aho-corasick", "memchr", @@ -846,9 +896,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" [[package]] name = "rustc-std-workspace-alloc" @@ -868,7 +918,7 @@ version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ - "bitflags", + "bitflags 2.13.1", "errno", "libc", "linux-raw-sys", @@ -887,9 +937,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" dependencies = [ "serde_core", "serde_derive", @@ -897,29 +947,29 @@ dependencies = [ [[package]] name = "serde_core" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.3", ] [[package]] name = "serde_json" -version = "1.0.150" +version = "1.0.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9" +checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14" dependencies = [ "itoa", "memchr", @@ -944,15 +994,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "63a7808e70b0b09116f01a4730d8976bcab457ea4a5e2e638e9b12ed3e01f27c" dependencies = [ "serde", - "thiserror", + "thiserror 1.0.69", "yaml-rust2", ] [[package]] name = "simd-adler32" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214" +checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" [[package]] name = "slab" @@ -962,15 +1012,15 @@ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" [[package]] name = "smallvec" -version = "1.15.1" +version = "1.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" +checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" [[package]] name = "spdx" -version = "0.13.4" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8da593e30beb790fc9424502eb898320b44e5eb30367dbda1c1edde8e2f32d7" +checksum = "081670c233dfbed55690cc0cd38424e0e24ac1b2673d0b408b3f7b684738dfa9" dependencies = [ "smallvec", ] @@ -989,9 +1039,20 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.117" +version = "2.0.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53e9bae58849f64dfa4f5d5ae372c8341f7305f82a3868709269343628b659a3" dependencies = [ "proc-macro2", "quote", @@ -1006,7 +1067,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -1024,7 +1085,7 @@ name = "test-helpers" version = "0.0.0" dependencies = [ "codegen-macro", - "wasm-encoder 0.254.0", + "wasm-encoder 0.256.0", "wit-bindgen-core", "wit-component", "wit-parser", @@ -1036,7 +1097,16 @@ version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec86235f5fcc2a73650310756d2ac5b138a5780bbbdfae3eeccec992c435ba4f" +dependencies = [ + "thiserror-impl 2.0.20", ] [[package]] @@ -1047,14 +1117,25 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc04cd3e1236dd4a98afca4569f2deb3f120e5422a4023be2cb683f8486292af" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.3", ] [[package]] name = "tinystr" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8323304221c2a851516f22236c5722a72eaa19749016521d6dff0824447d96d" +checksum = "b1e27c91459209c2986af3dcf603a5a74a4368754ce37414f59acc971167f643" dependencies = [ "displaydoc", "zerovec", @@ -1062,9 +1143,9 @@ dependencies = [ [[package]] name = "toml" -version = "1.1.2+spec-1.1.0" +version = "1.1.4+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81f3d15e84cbcd896376e6730314d59fb5a87f31e4b038454184435cd57defee" +checksum = "3aace63f4bbcdfc2c965b059de67119c89c4017a70d633be6c104910f67056f5" dependencies = [ "indexmap", "serde_core", @@ -1086,18 +1167,18 @@ dependencies = [ [[package]] name = "toml_parser" -version = "1.1.2+spec-1.1.0" +version = "1.1.3+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2abe9b86193656635d2411dc43050282ca48aa31c2451210f4202550afb7526" +checksum = "1d38ac1cf9b95face32296c0a3ede1fdc270627c9d9c02a7274dd6d960dc4d56" dependencies = [ "winnow", ] [[package]] name = "toml_writer" -version = "1.1.1+spec-1.1.0" +version = "1.1.2+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "756daf9b1013ebe47a8776667b466417e2d4c5679d441c26230efd9ef78692db" +checksum = "7d56353a2a665ad0f41a421187180aab746c8c325620617ad883a99a1cbe66d2" [[package]] name = "topological-sort" @@ -1161,9 +1242,9 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wac-graph" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1294c33de03c933cceedb23457c9317ca87b3df11580250ec35a6fadc8c229da" +checksum = "bdc8c5ffe944e002a24ba9d0fa67f51d4a761c1fc97718a17d1d7379753a6f8e" dependencies = [ "anyhow", "id-arena", @@ -1171,7 +1252,7 @@ dependencies = [ "log", "petgraph", "semver", - "thiserror", + "thiserror 1.0.69", "wac-types", "wasm-encoder 0.247.0", "wasm-metadata 0.247.0", @@ -1180,9 +1261,9 @@ dependencies = [ [[package]] name = "wac-parser" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fc78e70c11d6727b9b4b38f96f12f12f115f2f66a88b405918f8c1b6a1be646" +checksum = "40204c00fd7cb143285f15f70952e8db3c3f68b197a13763bc6ca5cba22a17b3" dependencies = [ "anyhow", "id-arena", @@ -1192,7 +1273,7 @@ dependencies = [ "miette", "semver", "serde", - "thiserror", + "thiserror 1.0.69", "wac-graph", "wasm-encoder 0.247.0", "wasm-metadata 0.247.0", @@ -1201,9 +1282,9 @@ dependencies = [ [[package]] name = "wac-types" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8d2a240ab5ee560f160b161886e53b7eded2d5a9949964c832edfa1636f283b" +checksum = "4b90654c08294d879e85f0b8b2c5a7efc3a7a10df3009dd1578d98902d1ec8a2" dependencies = [ "anyhow", "id-arena", @@ -1215,15 +1296,14 @@ dependencies = [ [[package]] name = "wasi-preview1-component-adapter-provider" -version = "46.0.1" +version = "46.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b6c48003fe59c201c97a7786ff55feabe6b6f83b598aa9ff5bcc4f94d940bf3" +checksum = "ab0702b5f6a92430482eeae78e34c51fb36d97483842220d641b91b38e4ac8c0" [[package]] name = "wasm-compose" -version = "0.254.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fd717357bff09b5f1ea49aea8ed1cd149b0c521823a1cc70bc2ac16b90b651a" +version = "0.256.0" +source = "git+https://github.com/chenyan2002/wasm-tools?branch=canon-ver-2#af97cd6c188022f9f31981f5bd46c7bc4272beb8" dependencies = [ "anyhow", "heck", @@ -1234,8 +1314,8 @@ dependencies = [ "serde_derive", "serde_yaml2", "smallvec", - "wasm-encoder 0.254.0", - "wasmparser 0.254.0", + "wasm-encoder 0.256.0", + "wasmparser 0.256.0", "wat", ] @@ -1251,12 +1331,11 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.254.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09480d646178e5fdd12bb06e812d0af9a3a191dbc9cd697fdc86687beade7393" +version = "0.256.0" +source = "git+https://github.com/chenyan2002/wasm-tools?branch=canon-ver-2#af97cd6c188022f9f31981f5bd46c7bc4272beb8" dependencies = [ "leb128fmt", - "wasmparser 0.254.0", + "wasmparser 0.256.0", ] [[package]] @@ -1280,14 +1359,13 @@ dependencies = [ [[package]] name = "wasm-metadata" -version = "0.254.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b01df5f3b4ca7881e843f3bc0fb8a3905d79c68692250dcb8e33e698705ccdb6" +version = "0.256.0" +source = "git+https://github.com/chenyan2002/wasm-tools?branch=canon-ver-2#af97cd6c188022f9f31981f5bd46c7bc4272beb8" dependencies = [ "anyhow", "indexmap", - "wasm-encoder 0.254.0", - "wasmparser 0.254.0", + "wasm-encoder 0.256.0", + "wasmparser 0.256.0", ] [[package]] @@ -1296,7 +1374,7 @@ version = "0.247.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e6fb4c2bee46c5ea4d40f8cdb5c131725cd976718ec56f1c8e82fbde5fa2a80" dependencies = [ - "bitflags", + "bitflags 2.13.1", "hashbrown 0.17.1", "indexmap", "semver", @@ -1305,11 +1383,10 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.254.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5769a29f799fbab136aaf65b4fe5384cd7d93fe6fc9ba0dcb6c8382a1f16e27" +version = "0.256.0" +source = "git+https://github.com/chenyan2002/wasm-tools?branch=canon-ver-2#af97cd6c188022f9f31981f5bd46c7bc4272beb8" dependencies = [ - "bitflags", + "bitflags 2.13.1", "hashbrown 0.17.1", "indexmap", "semver", @@ -1318,22 +1395,20 @@ dependencies = [ [[package]] name = "wast" -version = "254.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ed4dfc8f6b9fc38b231065e2cdfbf7359af5ab945990abf09658dcc63c3e32" +version = "256.0.0" +source = "git+https://github.com/chenyan2002/wasm-tools?branch=canon-ver-2#af97cd6c188022f9f31981f5bd46c7bc4272beb8" dependencies = [ "bumpalo", "leb128fmt", "memchr", "unicode-width 0.2.2", - "wasm-encoder 0.254.0", + "wasm-encoder 0.256.0", ] [[package]] name = "wat" -version = "1.254.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7127f7f9b8f127c879991cecd35f494e4628bae1b0874c681414d8d8831e952c" +version = "1.256.0" +source = "git+https://github.com/chenyan2002/wasm-tools?branch=canon-ver-2#af97cd6c188022f9f31981f5bd46c7bc4272beb8" dependencies = [ "wast", ] @@ -1355,15 +1430,15 @@ dependencies = [ [[package]] name = "winnow" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0592e1c9d151f854e6fd382574c3a0855250e1d9b2f99d9281c6e6391af352f1" +checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81" [[package]] name = "wit-bindgen" version = "0.60.0" dependencies = [ - "bitflags", + "bitflags 2.13.1", "futures", "rustc-std-workspace-alloc", "rustc-std-workspace-core", @@ -1378,8 +1453,8 @@ dependencies = [ "clap", "heck", "indexmap", - "wasm-encoder 0.254.0", - "wasm-metadata 0.254.0", + "wasm-encoder 0.256.0", + "wasm-metadata 0.256.0", "wit-bindgen-core", "wit-component", ] @@ -1391,7 +1466,7 @@ dependencies = [ "anyhow", "clap", "env_logger", - "wasm-encoder 0.254.0", + "wasm-encoder 0.256.0", "wit-bindgen-c", "wit-bindgen-core", "wit-bindgen-cpp", @@ -1424,8 +1499,8 @@ dependencies = [ "heck", "indexmap", "test-helpers", - "wasm-encoder 0.254.0", - "wasm-metadata 0.254.0", + "wasm-encoder 0.256.0", + "wasm-metadata 0.256.0", "wit-bindgen-c", "wit-bindgen-core", "wit-component", @@ -1441,7 +1516,7 @@ dependencies = [ "heck", "indexmap", "regex", - "wasm-metadata 0.254.0", + "wasm-metadata 0.256.0", "wit-bindgen-core", "wit-component", "wit-parser", @@ -1454,8 +1529,8 @@ dependencies = [ "anyhow", "clap", "heck", - "wasm-encoder 0.254.0", - "wasm-metadata 0.254.0", + "wasm-encoder 0.256.0", + "wasm-metadata 0.256.0", "wit-bindgen-core", "wit-component", ] @@ -1494,9 +1569,9 @@ dependencies = [ "prettyplease", "serde", "serde_json", - "syn", + "syn 2.0.119", "test-helpers", - "wasm-metadata 0.254.0", + "wasm-metadata 0.256.0", "wit-bindgen", "wit-bindgen-core", "wit-component", @@ -1511,7 +1586,7 @@ dependencies = [ "prettyplease", "proc-macro2", "quote", - "syn", + "syn 2.0.119", "wit-bindgen-core", "wit-bindgen-rust", ] @@ -1535,8 +1610,8 @@ dependencies = [ "wac-types", "wasi-preview1-component-adapter-provider", "wasm-compose", - "wasm-encoder 0.254.0", - "wasmparser 0.254.0", + "wasm-encoder 0.256.0", + "wasmparser 0.256.0", "wat", "wit-bindgen-csharp", "wit-component", @@ -1545,29 +1620,27 @@ dependencies = [ [[package]] name = "wit-component" -version = "0.254.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0e65bb94c369b3c4741ce3d1d2704b1fec93db7c540df0e521a097e7ceeb5be" +version = "0.256.0" +source = "git+https://github.com/chenyan2002/wasm-tools?branch=canon-ver-2#af97cd6c188022f9f31981f5bd46c7bc4272beb8" dependencies = [ "anyhow", - "bitflags", + "bitflags 2.13.1", "indexmap", "log", "serde", "serde_derive", "serde_json", - "wasm-encoder 0.254.0", - "wasm-metadata 0.254.0", - "wasmparser 0.254.0", + "wasm-encoder 0.256.0", + "wasm-metadata 0.256.0", + "wasmparser 0.256.0", "wat", "wit-parser", ] [[package]] name = "wit-parser" -version = "0.254.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1655131e4f7d3f0cb141f6eca71315ca40eff0f3d4de7cff0a82bacedd8c89b4" +version = "0.256.0" +source = "git+https://github.com/chenyan2002/wasm-tools?branch=canon-ver-2#af97cd6c188022f9f31981f5bd46c7bc4272beb8" dependencies = [ "anyhow", "hashbrown 0.17.1", @@ -1579,14 +1652,14 @@ dependencies = [ "serde_derive", "serde_json", "unicode-ident", - "wasmparser 0.254.0", + "wasmparser 0.256.0", ] [[package]] name = "writeable" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ffae5123b2d3fc086436f8834ae3ab053a283cfac8fe0a0b8eaae044768a4c4" +checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" [[package]] name = "yaml-rust2" @@ -1618,28 +1691,28 @@ checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", "synstructure", ] [[package]] name = "zerocopy" -version = "0.8.50" +version = "0.8.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b065d4f0e55f82fae73202e189638116a87c55ab6b8e6c2721e13dd9d854ad1" +checksum = "556764e583adb45a9f8d413c2a147fa7e8d821e48e12b14fd560b607998b75eb" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.50" +version = "0.8.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b631b19d36a892ab55420c92dbc83ccd79274f25be714855d3074aa71cab639" +checksum = "f2ab42fc20575779bd240faa45f94a74256f755c0fa9e89f0ede20d91d0cdfc1" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -1659,15 +1732,15 @@ checksum = "11532158c46691caf0f2593ea8358fed6bbf68a0315e80aae9bd41fbade684a1" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", "synstructure", ] [[package]] name = "zerotrie" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f9152d31db0792fa83f70fb2f83148effb5c1f5b8c7686c3459e361d9bc20bf" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" dependencies = [ "displaydoc", "yoke", @@ -1676,9 +1749,9 @@ dependencies = [ [[package]] name = "zerovec" -version = "0.11.6" +version = "0.11.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90f911cbc359ab6af17377d242225f4d75119aec87ea711a880987b18cd7b239" +checksum = "94b5c6b5976d66c1d703c4fd17d3f5e43c8cedaacf604961b171adc7130896d8" dependencies = [ "yoke", "zerofrom", @@ -1687,17 +1760,17 @@ dependencies = [ [[package]] name = "zerovec-derive" -version = "0.11.3" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "625dc425cab0dca6dc3c3319506e6593dcb08a9f387ea3b284dbd52a92c40555" +checksum = "47402523226a02bfe5230160dc3ccc089aa6f6f19e7fcbb4e6f824bbb1b4aa62" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.3", ] [[package]] name = "zmij" -version = "1.0.21" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/Cargo.toml b/Cargo.toml index 092648e32..96c623b5c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,13 +48,13 @@ syn = { version = "2.0.89", features = ["printing"] } futures = "0.3.31" macro-string = "0.2.0" -wat = "1.254.0" -wasmparser = "0.254.0" -wasm-encoder = "0.254.0" -wasm-metadata = { version = "0.254.0", default-features = false } -wit-parser = "0.254.0" -wit-component = "0.254.0" -wasm-compose = "0.254.0" +wat = "1.256.0" +wasmparser = "0.256.0" +wasm-encoder = "0.256.0" +wasm-metadata = { version = "0.256.0", default-features = false } +wit-parser = "0.256.0" +wit-component = "0.256.0" +wasm-compose = "0.256.0" wit-bindgen-core = { path = 'crates/core', version = '0.60.0' } wit-bindgen-c = { path = 'crates/c', version = '0.60.0' } @@ -121,3 +121,12 @@ csharp = ['dep:wit-bindgen-csharp'] csharp-mono = ['csharp'] moonbit = ['dep:wit-bindgen-moonbit'] async = [] + +[patch.crates-io] +wat = { git = "https://github.com/chenyan2002/wasm-tools", branch = "canon-ver-2" } +wasmparser = { git = "https://github.com/chenyan2002/wasm-tools", branch = "canon-ver-2" } +wasm-encoder = { git = "https://github.com/chenyan2002/wasm-tools", branch = "canon-ver-2" } +wasm-metadata = { git = "https://github.com/chenyan2002/wasm-tools", branch = "canon-ver-2" } +wit-parser = { git = "https://github.com/chenyan2002/wasm-tools", branch = "canon-ver-2" } +wit-component = { git = "https://github.com/chenyan2002/wasm-tools", branch = "canon-ver-2" } +wasm-compose = { git = "https://github.com/chenyan2002/wasm-tools", branch = "canon-ver-2" } diff --git a/crates/guest-rust/macro/src/lib.rs b/crates/guest-rust/macro/src/lib.rs index 603222a77..f219fcbe9 100644 --- a/crates/guest-rust/macro/src/lib.rs +++ b/crates/guest-rust/macro/src/lib.rs @@ -67,6 +67,7 @@ impl Parse for Config { let mut features = Vec::new(); let mut async_configured = false; let mut debug = false; + let mut use_canonical_names = false; if input.peek(token::Brace) { let content; @@ -175,6 +176,9 @@ impl Parse for Config { Opt::MergeStructurallyEqualTypes(enable) => { opts.merge_structurally_equal_types = Some(Some(enable.value())) } + Opt::UseCanonicalNames(enable) => { + use_canonical_names = enable.value(); + } } } } else { @@ -186,7 +190,8 @@ impl Parse for Config { } } let (resolve, main_packages, files) = - parse_source(&source, &features).map_err(|err| anyhow_to_syn(call_site, err))?; + parse_source(&source, &features, use_canonical_names) + .map_err(|err| anyhow_to_syn(call_site, err))?; let world = resolve .select_world(&main_packages, world.as_deref()) .map_err(|e| anyhow_to_syn(call_site, e))?; @@ -204,9 +209,11 @@ impl Parse for Config { fn parse_source( source: &Option, features: &[String], + use_canonical_names: bool, ) -> anyhow::Result<(Resolve, Vec, Vec)> { let mut resolve = Resolve::default(); resolve.features.extend(features.iter().cloned()); + resolve.use_canonical_names = use_canonical_names; let mut files = Vec::new(); let mut pkgs = Vec::new(); let root = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap()); @@ -332,6 +339,7 @@ mod kw { syn::custom_keyword!(debug); syn::custom_keyword!(enable_method_chaining); syn::custom_keyword!(merge_structurally_equal_types); + syn::custom_keyword!(use_canonical_names); } #[derive(Clone)] @@ -416,6 +424,7 @@ enum Opt { Debug(syn::LitBool), EnableMethodChaining(syn::LitBool), MergeStructurallyEqualTypes(syn::LitBool), + UseCanonicalNames(syn::LitBool), } impl Parse for Opt { @@ -623,6 +632,10 @@ impl Parse for Opt { input.parse::()?; input.parse::()?; Ok(Opt::MergeStructurallyEqualTypes(input.parse()?)) + } else if l.peek(kw::use_canonical_names) { + input.parse::()?; + input.parse::()?; + Ok(Opt::UseCanonicalNames(input.parse()?)) } else { Err(l.error()) } diff --git a/crates/rust/tests/codegen.rs b/crates/rust/tests/codegen.rs index e8046ceaf..ff7c55b8a 100644 --- a/crates/rust/tests/codegen.rs +++ b/crates/rust/tests/codegen.rs @@ -403,3 +403,15 @@ mod versioned_selectors { assert!(Alpha { x: 1 } < Alpha { x: 2 }); } } + +#[allow(unused, reason = "testing codegen, not functionality")] +mod canonical_version { + // The dep provides my:dep@1.1.0 but the world imports my:dep/api@1.0.0. + // With use_canonical_names, these are on the same compat track (1.x) + // and should resolve successfully. + wit_bindgen::generate!({ + path: "tests/wit/canonical-version", + generate_all, + use_canonical_names: true, + }); +} diff --git a/crates/rust/tests/wit/canonical-version/deps/my-dep/root.wit b/crates/rust/tests/wit/canonical-version/deps/my-dep/root.wit new file mode 100644 index 000000000..f98ffa491 --- /dev/null +++ b/crates/rust/tests/wit/canonical-version/deps/my-dep/root.wit @@ -0,0 +1,9 @@ +package my:dep@1.1.0; + +interface api { + record point { + x: s32, + y: s32, + } + get-origin: func() -> point; +} diff --git a/crates/rust/tests/wit/canonical-version/root.wit b/crates/rust/tests/wit/canonical-version/root.wit new file mode 100644 index 000000000..7fdae8470 --- /dev/null +++ b/crates/rust/tests/wit/canonical-version/root.wit @@ -0,0 +1,5 @@ +package foo:bar; + +world test { + import my:dep/api@1.0.0; +} diff --git a/src/bin/wit-bindgen.rs b/src/bin/wit-bindgen.rs index 04e38f7f0..02fbfed1c 100644 --- a/src/bin/wit-bindgen.rs +++ b/src/bin/wit-bindgen.rs @@ -129,6 +129,14 @@ struct Common { /// This enables using `@unstable` annotations in WIT files. #[clap(long)] all_features: bool, + + /// Use canonical version matching when resolving package dependencies. + /// + /// When enabled, packages with the same semver-compatible version track + /// (e.g., `foo:bar@1.2.0` and `foo:bar@1.3.0`) are treated as the same + /// package during resolution, with the larger version winning. + #[clap(long)] + use_canonical_names: bool, } fn main() -> Result<()> { @@ -217,6 +225,7 @@ fn gen_world( ) -> Result<()> { let mut resolve = Resolve::default(); resolve.all_features = opts.all_features; + resolve.use_canonical_names = opts.use_canonical_names; for features in opts.features.iter() { for feature in features .split(',') From 69a83c39071dfdac5427a123637cde71485356e1 Mon Sep 17 00:00:00 2001 From: Yan Chen Date: Mon, 17 Aug 2026 10:10:46 -0700 Subject: [PATCH 2/4] fix --- src/bin/wit-bindgen.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/wit-bindgen.rs b/src/bin/wit-bindgen.rs index 02fbfed1c..a85e70c81 100644 --- a/src/bin/wit-bindgen.rs +++ b/src/bin/wit-bindgen.rs @@ -132,7 +132,7 @@ struct Common { /// Use canonical version matching when resolving package dependencies. /// - /// When enabled, packages with the same semver-compatible version track + /// When enabled, packages with the same canonical version /// (e.g., `foo:bar@1.2.0` and `foo:bar@1.3.0`) are treated as the same /// package during resolution, with the larger version winning. #[clap(long)] From f9bd0755dc261f72ebc08fe1bce37032f1b8c3df Mon Sep 17 00:00:00 2001 From: Yan Chen Date: Mon, 17 Aug 2026 11:19:55 -0700 Subject: [PATCH 3/4] fmt --- crates/guest-rust/macro/src/lib.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/guest-rust/macro/src/lib.rs b/crates/guest-rust/macro/src/lib.rs index f219fcbe9..099c87d02 100644 --- a/crates/guest-rust/macro/src/lib.rs +++ b/crates/guest-rust/macro/src/lib.rs @@ -189,9 +189,8 @@ impl Parse for Config { )])); } } - let (resolve, main_packages, files) = - parse_source(&source, &features, use_canonical_names) - .map_err(|err| anyhow_to_syn(call_site, err))?; + let (resolve, main_packages, files) = parse_source(&source, &features, use_canonical_names) + .map_err(|err| anyhow_to_syn(call_site, err))?; let world = resolve .select_world(&main_packages, world.as_deref()) .map_err(|e| anyhow_to_syn(call_site, e))?; From aedaf83fdda805bf926fc3a9e87a44a130900db8 Mon Sep 17 00:00:00 2001 From: Yan Chen Date: Mon, 17 Aug 2026 13:07:37 -0700 Subject: [PATCH 4/4] fix --- Cargo.toml | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 96c623b5c..452eb8223 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,13 +48,13 @@ syn = { version = "2.0.89", features = ["printing"] } futures = "0.3.31" macro-string = "0.2.0" -wat = "1.256.0" -wasmparser = "0.256.0" -wasm-encoder = "0.256.0" -wasm-metadata = { version = "0.256.0", default-features = false } -wit-parser = "0.256.0" -wit-component = "0.256.0" -wasm-compose = "0.256.0" +wat = { git = "https://github.com/chenyan2002/wasm-tools", branch = "canon-ver-2" } +wasmparser = { git = "https://github.com/chenyan2002/wasm-tools", branch = "canon-ver-2" } +wasm-encoder = { git = "https://github.com/chenyan2002/wasm-tools", branch = "canon-ver-2" } +wasm-metadata = { git = "https://github.com/chenyan2002/wasm-tools", branch = "canon-ver-2", default-features = false } +wit-parser = { git = "https://github.com/chenyan2002/wasm-tools", branch = "canon-ver-2" } +wit-component = { git = "https://github.com/chenyan2002/wasm-tools", branch = "canon-ver-2" } +wasm-compose = { git = "https://github.com/chenyan2002/wasm-tools", branch = "canon-ver-2" } wit-bindgen-core = { path = 'crates/core', version = '0.60.0' } wit-bindgen-c = { path = 'crates/c', version = '0.60.0' } @@ -121,12 +121,3 @@ csharp = ['dep:wit-bindgen-csharp'] csharp-mono = ['csharp'] moonbit = ['dep:wit-bindgen-moonbit'] async = [] - -[patch.crates-io] -wat = { git = "https://github.com/chenyan2002/wasm-tools", branch = "canon-ver-2" } -wasmparser = { git = "https://github.com/chenyan2002/wasm-tools", branch = "canon-ver-2" } -wasm-encoder = { git = "https://github.com/chenyan2002/wasm-tools", branch = "canon-ver-2" } -wasm-metadata = { git = "https://github.com/chenyan2002/wasm-tools", branch = "canon-ver-2" } -wit-parser = { git = "https://github.com/chenyan2002/wasm-tools", branch = "canon-ver-2" } -wit-component = { git = "https://github.com/chenyan2002/wasm-tools", branch = "canon-ver-2" } -wasm-compose = { git = "https://github.com/chenyan2002/wasm-tools", branch = "canon-ver-2" }