html-to-markdown 2.24.4 → 2.24.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2165) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +6 -6
  3. data/README.md +1 -1
  4. data/ext/html-to-markdown-rb/native/Cargo.lock +254 -47
  5. data/ext/html-to-markdown-rb/native/Cargo.toml +1 -1
  6. data/lib/html_to_markdown/version.rb +1 -1
  7. data/rust-vendor/anyhow/.cargo-checksum.json +1 -0
  8. data/rust-vendor/anyhow/.cargo_vcs_info.json +6 -0
  9. data/rust-vendor/anyhow/.github/FUNDING.yml +1 -0
  10. data/rust-vendor/anyhow/.github/workflows/ci.yml +147 -0
  11. data/rust-vendor/anyhow/Cargo.lock +424 -0
  12. data/rust-vendor/anyhow/Cargo.toml +132 -0
  13. data/rust-vendor/anyhow/Cargo.toml.orig +40 -0
  14. data/rust-vendor/anyhow/LICENSE-APACHE +176 -0
  15. data/rust-vendor/anyhow/LICENSE-MIT +23 -0
  16. data/rust-vendor/anyhow/README.md +179 -0
  17. data/rust-vendor/anyhow/build.rs +207 -0
  18. data/rust-vendor/anyhow/rust-toolchain.toml +2 -0
  19. data/rust-vendor/anyhow/src/backtrace.rs +410 -0
  20. data/rust-vendor/anyhow/src/chain.rs +102 -0
  21. data/rust-vendor/anyhow/src/context.rs +193 -0
  22. data/rust-vendor/anyhow/src/ensure.rs +935 -0
  23. data/rust-vendor/anyhow/src/error.rs +1086 -0
  24. data/rust-vendor/anyhow/src/fmt.rs +158 -0
  25. data/rust-vendor/anyhow/src/kind.rs +121 -0
  26. data/rust-vendor/anyhow/src/lib.rs +728 -0
  27. data/rust-vendor/anyhow/src/macros.rs +245 -0
  28. data/rust-vendor/anyhow/src/nightly.rs +58 -0
  29. data/rust-vendor/anyhow/src/ptr.rs +187 -0
  30. data/rust-vendor/anyhow/src/wrapper.rs +84 -0
  31. data/rust-vendor/anyhow/tests/common/mod.rs +14 -0
  32. data/rust-vendor/anyhow/tests/compiletest.rs +7 -0
  33. data/rust-vendor/anyhow/tests/drop/mod.rs +53 -0
  34. data/rust-vendor/anyhow/tests/test_autotrait.rs +34 -0
  35. data/rust-vendor/anyhow/tests/test_backtrace.rs +15 -0
  36. data/rust-vendor/anyhow/tests/test_boxed.rs +45 -0
  37. data/rust-vendor/anyhow/tests/test_chain.rs +69 -0
  38. data/rust-vendor/anyhow/tests/test_context.rs +172 -0
  39. data/rust-vendor/anyhow/tests/test_convert.rs +46 -0
  40. data/rust-vendor/anyhow/tests/test_downcast.rs +123 -0
  41. data/rust-vendor/anyhow/tests/test_ensure.rs +756 -0
  42. data/rust-vendor/anyhow/tests/test_ffi.rs +19 -0
  43. data/rust-vendor/anyhow/tests/test_fmt.rs +93 -0
  44. data/rust-vendor/anyhow/tests/test_macros.rs +97 -0
  45. data/rust-vendor/anyhow/tests/test_repr.rs +30 -0
  46. data/rust-vendor/anyhow/tests/test_source.rs +62 -0
  47. data/rust-vendor/anyhow/tests/ui/chained-comparison.rs +8 -0
  48. data/rust-vendor/anyhow/tests/ui/chained-comparison.stderr +10 -0
  49. data/rust-vendor/anyhow/tests/ui/empty-ensure.rs +6 -0
  50. data/rust-vendor/anyhow/tests/ui/empty-ensure.stderr +12 -0
  51. data/rust-vendor/anyhow/tests/ui/ensure-nonbool.rs +40 -0
  52. data/rust-vendor/anyhow/tests/ui/ensure-nonbool.stderr +113 -0
  53. data/rust-vendor/anyhow/tests/ui/must-use.rs +11 -0
  54. data/rust-vendor/anyhow/tests/ui/must-use.stderr +15 -0
  55. data/rust-vendor/anyhow/tests/ui/no-impl.rs +8 -0
  56. data/rust-vendor/anyhow/tests/ui/no-impl.stderr +32 -0
  57. data/rust-vendor/anyhow/tests/ui/temporary-value.rs +5 -0
  58. data/rust-vendor/anyhow/tests/ui/temporary-value.stderr +15 -0
  59. data/rust-vendor/anyhow/tests/ui/wrong-interpolation.rs +5 -0
  60. data/rust-vendor/anyhow/tests/ui/wrong-interpolation.stderr +5 -0
  61. data/rust-vendor/bitflags/.cargo-checksum.json +1 -1
  62. data/rust-vendor/bitflags/.cargo_vcs_info.json +1 -1
  63. data/rust-vendor/bitflags/CHANGELOG.md +12 -0
  64. data/rust-vendor/bitflags/Cargo.lock +48 -48
  65. data/rust-vendor/bitflags/Cargo.toml +1 -1
  66. data/rust-vendor/bitflags/Cargo.toml.orig +1 -1
  67. data/rust-vendor/bitflags/README.md +1 -1
  68. data/rust-vendor/bitflags/src/external.rs +1 -1
  69. data/rust-vendor/bitflags/src/lib.rs +1 -1
  70. data/rust-vendor/bitflags/src/tests/known_bits.rs +47 -0
  71. data/rust-vendor/bitflags/src/tests/unknown_bits.rs +53 -0
  72. data/rust-vendor/bitflags/src/tests.rs +2 -0
  73. data/rust-vendor/bitflags/src/traits.rs +11 -1
  74. data/rust-vendor/cc/.cargo-checksum.json +1 -1
  75. data/rust-vendor/cc/.cargo_vcs_info.json +1 -1
  76. data/rust-vendor/cc/CHANGELOG.md +7 -0
  77. data/rust-vendor/cc/Cargo.lock +331 -7
  78. data/rust-vendor/cc/Cargo.toml +1 -1
  79. data/rust-vendor/cc/Cargo.toml.orig +1 -1
  80. data/rust-vendor/cc/src/lib.rs +10 -13
  81. data/rust-vendor/cc/src/target/generated.rs +1 -0
  82. data/rust-vendor/cpp_demangle/.cargo-checksum.json +1 -1
  83. data/rust-vendor/cpp_demangle/.cargo_vcs_info.json +1 -1
  84. data/rust-vendor/cpp_demangle/CHANGELOG.md +55 -0
  85. data/rust-vendor/cpp_demangle/Cargo.lock +5 -5
  86. data/rust-vendor/cpp_demangle/Cargo.toml +2 -2
  87. data/rust-vendor/cpp_demangle/Cargo.toml.orig +2 -2
  88. data/rust-vendor/cpp_demangle/README.md +9 -9
  89. data/rust-vendor/cpp_demangle/build.rs +10 -9
  90. data/rust-vendor/cpp_demangle/examples/cppfilt.rs +1 -1
  91. data/rust-vendor/cpp_demangle/examples/simple.rs +1 -1
  92. data/rust-vendor/cpp_demangle/src/ast.rs +238 -36
  93. data/rust-vendor/cpp_demangle/src/lib.rs +31 -46
  94. data/rust-vendor/cpp_demangle/src/subs.rs +1 -1
  95. data/rust-vendor/flate2/.cargo-checksum.json +1 -1
  96. data/rust-vendor/flate2/.cargo_vcs_info.json +1 -1
  97. data/rust-vendor/flate2/Cargo.lock +3 -3
  98. data/rust-vendor/flate2/Cargo.toml +13 -2
  99. data/rust-vendor/flate2/Cargo.toml.orig +16 -13
  100. data/rust-vendor/flate2/LICENSE-MIT +1 -1
  101. data/rust-vendor/flate2/src/crc.rs +177 -42
  102. data/rust-vendor/flate2/src/gz/mod.rs +159 -0
  103. data/rust-vendor/foldhash-0.1.5/.cargo-checksum.json +1 -0
  104. data/rust-vendor/foldhash-0.1.5/.cargo_vcs_info.json +6 -0
  105. data/rust-vendor/foldhash-0.1.5/Cargo.lock +852 -0
  106. data/rust-vendor/foldhash-0.1.5/Cargo.toml +76 -0
  107. data/rust-vendor/foldhash-0.1.5/Cargo.toml.orig +44 -0
  108. data/rust-vendor/foldhash-0.1.5/LICENSE +19 -0
  109. data/rust-vendor/foldhash-0.1.5/README.md +277 -0
  110. data/rust-vendor/foldhash-0.1.5/src/convenience.rs +73 -0
  111. data/rust-vendor/foldhash-0.1.5/src/fast.rs +270 -0
  112. data/rust-vendor/foldhash-0.1.5/src/lib.rs +284 -0
  113. data/rust-vendor/foldhash-0.1.5/src/quality.rs +174 -0
  114. data/rust-vendor/foldhash-0.1.5/src/seed.rs +267 -0
  115. data/rust-vendor/getrandom/.cargo-checksum.json +1 -1
  116. data/rust-vendor/getrandom/.cargo_vcs_info.json +1 -1
  117. data/rust-vendor/getrandom/CHANGELOG.md +39 -1
  118. data/rust-vendor/getrandom/Cargo.lock +451 -60
  119. data/rust-vendor/getrandom/Cargo.toml +44 -5
  120. data/rust-vendor/getrandom/Cargo.toml.orig +45 -10
  121. data/rust-vendor/getrandom/LICENSE-MIT +1 -1
  122. data/rust-vendor/getrandom/README.md +72 -40
  123. data/rust-vendor/getrandom/benches/buffer.rs +10 -8
  124. data/rust-vendor/getrandom/build.rs +1 -47
  125. data/rust-vendor/getrandom/src/backends/custom.rs +1 -1
  126. data/rust-vendor/getrandom/src/backends/efi_rng.rs +1 -1
  127. data/rust-vendor/getrandom/src/backends/esp_idf.rs +1 -1
  128. data/rust-vendor/getrandom/src/backends/extern_impl.rs +19 -0
  129. data/rust-vendor/getrandom/src/backends/fuchsia.rs +1 -1
  130. data/rust-vendor/getrandom/src/backends/getentropy.rs +4 -3
  131. data/rust-vendor/getrandom/src/backends/getrandom.rs +4 -12
  132. data/rust-vendor/getrandom/src/backends/hermit.rs +1 -1
  133. data/rust-vendor/getrandom/src/backends/linux_android_with_fallback.rs +8 -10
  134. data/rust-vendor/getrandom/src/backends/linux_raw.rs +101 -75
  135. data/rust-vendor/getrandom/src/backends/netbsd.rs +3 -3
  136. data/rust-vendor/getrandom/src/backends/rdrand.rs +26 -13
  137. data/rust-vendor/getrandom/src/backends/rndr.rs +13 -11
  138. data/rust-vendor/getrandom/src/backends/solaris.rs +5 -4
  139. data/rust-vendor/getrandom/src/backends/solid.rs +1 -1
  140. data/rust-vendor/getrandom/src/backends/use_file.rs +17 -28
  141. data/rust-vendor/getrandom/src/backends/vxworks.rs +2 -4
  142. data/rust-vendor/getrandom/src/backends/wasi_p1.rs +1 -1
  143. data/rust-vendor/getrandom/src/backends/wasi_p2_3.rs +61 -0
  144. data/rust-vendor/getrandom/src/backends/wasm_js.rs +1 -1
  145. data/rust-vendor/getrandom/src/backends/windows.rs +7 -11
  146. data/rust-vendor/getrandom/src/backends/windows_legacy.rs +1 -1
  147. data/rust-vendor/getrandom/src/backends.rs +9 -28
  148. data/rust-vendor/getrandom/src/error.rs +39 -6
  149. data/rust-vendor/getrandom/src/error_std_impls.rs +1 -3
  150. data/rust-vendor/getrandom/src/lib.rs +39 -18
  151. data/rust-vendor/getrandom/src/sys_rng.rs +55 -0
  152. data/rust-vendor/getrandom/src/util.rs +3 -15
  153. data/rust-vendor/getrandom/src/utils/get_errno.rs +29 -0
  154. data/rust-vendor/getrandom/src/utils/lazy.rs +64 -0
  155. data/rust-vendor/getrandom/src/utils/sanitizer.rs +28 -0
  156. data/rust-vendor/getrandom/src/utils/sys_fill_exact.rs +41 -0
  157. data/rust-vendor/getrandom/tests/mod.rs +6 -94
  158. data/rust-vendor/getrandom/tests/sys_rng.rs +18 -0
  159. data/rust-vendor/getrandom-0.3.4/.cargo-checksum.json +1 -0
  160. data/rust-vendor/getrandom-0.3.4/.cargo_vcs_info.json +6 -0
  161. data/rust-vendor/getrandom-0.3.4/CHANGELOG.md +673 -0
  162. data/rust-vendor/getrandom-0.3.4/Cargo.lock +292 -0
  163. data/rust-vendor/getrandom-0.3.4/Cargo.toml +133 -0
  164. data/rust-vendor/getrandom-0.3.4/Cargo.toml.orig +100 -0
  165. data/rust-vendor/getrandom-0.3.4/LICENSE-APACHE +201 -0
  166. data/rust-vendor/getrandom-0.3.4/LICENSE-MIT +26 -0
  167. data/rust-vendor/getrandom-0.3.4/README.md +386 -0
  168. data/rust-vendor/getrandom-0.3.4/SECURITY.md +13 -0
  169. data/rust-vendor/getrandom-0.3.4/benches/buffer.rs +121 -0
  170. data/rust-vendor/getrandom-0.3.4/build.rs +57 -0
  171. data/rust-vendor/getrandom-0.3.4/src/backends/apple_other.rs +21 -0
  172. data/rust-vendor/getrandom-0.3.4/src/backends/custom.rs +13 -0
  173. data/rust-vendor/getrandom-0.3.4/src/backends/efi_rng.rs +124 -0
  174. data/rust-vendor/getrandom-0.3.4/src/backends/esp_idf.rs +21 -0
  175. data/rust-vendor/getrandom-0.3.4/src/backends/fuchsia.rs +16 -0
  176. data/rust-vendor/getrandom-0.3.4/src/backends/getentropy.rs +27 -0
  177. data/rust-vendor/getrandom-0.3.4/src/backends/getrandom.rs +39 -0
  178. data/rust-vendor/getrandom-0.3.4/src/backends/hermit.rs +53 -0
  179. data/rust-vendor/getrandom-0.3.4/src/backends/linux_android_with_fallback.rs +103 -0
  180. data/rust-vendor/getrandom-0.3.4/src/backends/linux_raw.rs +143 -0
  181. data/rust-vendor/getrandom-0.3.4/src/backends/netbsd.rs +78 -0
  182. data/rust-vendor/getrandom-0.3.4/src/backends/rdrand.rs +182 -0
  183. data/rust-vendor/getrandom-0.3.4/src/backends/rndr.rs +145 -0
  184. data/rust-vendor/getrandom-0.3.4/src/backends/solaris.rs +42 -0
  185. data/rust-vendor/getrandom-0.3.4/src/backends/solid.rs +19 -0
  186. data/rust-vendor/getrandom-0.3.4/src/backends/unsupported.rs +9 -0
  187. data/rust-vendor/getrandom-0.3.4/src/backends/use_file.rs +234 -0
  188. data/rust-vendor/getrandom-0.3.4/src/backends/vxworks.rs +54 -0
  189. data/rust-vendor/getrandom-0.3.4/src/backends/wasi_p1.rs +32 -0
  190. data/rust-vendor/getrandom-0.3.4/src/backends/wasm_js.rs +72 -0
  191. data/rust-vendor/getrandom-0.3.4/src/backends/windows.rs +61 -0
  192. data/rust-vendor/getrandom-0.3.4/src/backends/windows_legacy.rs +48 -0
  193. data/rust-vendor/getrandom-0.3.4/src/backends.rs +209 -0
  194. data/rust-vendor/getrandom-0.3.4/src/error.rs +212 -0
  195. data/rust-vendor/getrandom-0.3.4/src/error_std_impls.rs +15 -0
  196. data/rust-vendor/getrandom-0.3.4/src/lib.rs +138 -0
  197. data/rust-vendor/getrandom-0.3.4/src/util.rs +84 -0
  198. data/rust-vendor/getrandom-0.3.4/tests/mod.rs +297 -0
  199. data/rust-vendor/hashbrown-0.15.5/.cargo-checksum.json +1 -0
  200. data/rust-vendor/hashbrown-0.15.5/.cargo_vcs_info.json +6 -0
  201. data/rust-vendor/hashbrown-0.15.5/CHANGELOG.md +619 -0
  202. data/rust-vendor/hashbrown-0.15.5/Cargo.lock +306 -0
  203. data/rust-vendor/hashbrown-0.15.5/Cargo.toml +164 -0
  204. data/rust-vendor/hashbrown-0.15.5/Cargo.toml.orig +77 -0
  205. data/rust-vendor/hashbrown-0.15.5/Cross.toml +3 -0
  206. data/rust-vendor/hashbrown-0.15.5/LICENSE-APACHE +201 -0
  207. data/rust-vendor/hashbrown-0.15.5/LICENSE-MIT +25 -0
  208. data/rust-vendor/hashbrown-0.15.5/README.md +80 -0
  209. data/rust-vendor/hashbrown-0.15.5/benches/bench.rs +329 -0
  210. data/rust-vendor/hashbrown-0.15.5/benches/insert_unique_unchecked.rs +34 -0
  211. data/rust-vendor/hashbrown-0.15.5/benches/set_ops.rs +148 -0
  212. data/rust-vendor/hashbrown-0.15.5/clippy.toml +1 -0
  213. data/rust-vendor/hashbrown-0.15.5/src/control/bitmask.rs +117 -0
  214. data/rust-vendor/hashbrown-0.15.5/src/control/group/generic.rs +154 -0
  215. data/rust-vendor/hashbrown-0.15.5/src/control/group/lsx.rs +137 -0
  216. data/rust-vendor/hashbrown-0.15.5/src/control/group/mod.rs +43 -0
  217. data/rust-vendor/hashbrown-0.15.5/src/control/group/neon.rs +121 -0
  218. data/rust-vendor/hashbrown-0.15.5/src/control/group/sse2.rs +146 -0
  219. data/rust-vendor/hashbrown-0.15.5/src/control/mod.rs +10 -0
  220. data/rust-vendor/hashbrown-0.15.5/src/control/tag.rs +83 -0
  221. data/rust-vendor/hashbrown-0.15.5/src/external_trait_impls/mod.rs +4 -0
  222. data/rust-vendor/hashbrown-0.15.5/src/external_trait_impls/rayon/helpers.rs +27 -0
  223. data/rust-vendor/hashbrown-0.15.5/src/external_trait_impls/rayon/map.rs +721 -0
  224. data/rust-vendor/hashbrown-0.15.5/src/external_trait_impls/rayon/mod.rs +5 -0
  225. data/rust-vendor/hashbrown-0.15.5/src/external_trait_impls/rayon/raw.rs +230 -0
  226. data/rust-vendor/hashbrown-0.15.5/src/external_trait_impls/rayon/set.rs +659 -0
  227. data/rust-vendor/hashbrown-0.15.5/src/external_trait_impls/rayon/table.rs +249 -0
  228. data/rust-vendor/hashbrown-0.15.5/src/external_trait_impls/serde.rs +220 -0
  229. data/rust-vendor/hashbrown-0.15.5/src/lib.rs +188 -0
  230. data/rust-vendor/hashbrown-0.15.5/src/macros.rs +70 -0
  231. data/rust-vendor/hashbrown-0.15.5/src/map.rs +6583 -0
  232. data/rust-vendor/hashbrown-0.15.5/src/raw/alloc.rs +92 -0
  233. data/rust-vendor/hashbrown-0.15.5/src/raw/mod.rs +4436 -0
  234. data/rust-vendor/hashbrown-0.15.5/src/raw_entry.rs +1740 -0
  235. data/rust-vendor/hashbrown-0.15.5/src/rustc_entry.rs +567 -0
  236. data/rust-vendor/hashbrown-0.15.5/src/scopeguard.rs +72 -0
  237. data/rust-vendor/hashbrown-0.15.5/src/set.rs +3121 -0
  238. data/rust-vendor/hashbrown-0.15.5/src/table.rs +2380 -0
  239. data/rust-vendor/hashbrown-0.15.5/src/util.rs +38 -0
  240. data/rust-vendor/hashbrown-0.15.5/tests/equivalent_trait.rs +53 -0
  241. data/rust-vendor/hashbrown-0.15.5/tests/hasher.rs +65 -0
  242. data/rust-vendor/hashbrown-0.15.5/tests/rayon.rs +535 -0
  243. data/rust-vendor/hashbrown-0.15.5/tests/serde.rs +65 -0
  244. data/rust-vendor/hashbrown-0.15.5/tests/set.rs +34 -0
  245. data/rust-vendor/heck/.cargo-checksum.json +1 -0
  246. data/rust-vendor/heck/.cargo_vcs_info.json +6 -0
  247. data/rust-vendor/heck/CHANGELOG.md +25 -0
  248. data/rust-vendor/heck/Cargo.toml +34 -0
  249. data/rust-vendor/heck/Cargo.toml.orig +11 -0
  250. data/rust-vendor/heck/LICENSE-APACHE +201 -0
  251. data/rust-vendor/heck/LICENSE-MIT +25 -0
  252. data/rust-vendor/heck/README.md +53 -0
  253. data/rust-vendor/heck/src/kebab.rs +75 -0
  254. data/rust-vendor/heck/src/lib.rs +192 -0
  255. data/rust-vendor/heck/src/lower_camel.rs +88 -0
  256. data/rust-vendor/heck/src/shouty_kebab.rs +73 -0
  257. data/rust-vendor/heck/src/shouty_snake.rs +86 -0
  258. data/rust-vendor/heck/src/snake.rs +100 -0
  259. data/rust-vendor/heck/src/title.rs +75 -0
  260. data/rust-vendor/heck/src/train.rs +87 -0
  261. data/rust-vendor/heck/src/upper_camel.rs +88 -0
  262. data/rust-vendor/html-to-markdown-rs/src/converter/inline/semantic/typography.rs +32 -22
  263. data/rust-vendor/html-to-markdown-rs/tests/integration_test.rs +44 -0
  264. data/rust-vendor/id-arena/.cargo-checksum.json +1 -0
  265. data/rust-vendor/id-arena/.cargo_vcs_info.json +6 -0
  266. data/rust-vendor/id-arena/.travis.yml +22 -0
  267. data/rust-vendor/id-arena/CHANGELOG.md +71 -0
  268. data/rust-vendor/id-arena/Cargo.lock +61 -0
  269. data/rust-vendor/id-arena/Cargo.toml +54 -0
  270. data/rust-vendor/id-arena/Cargo.toml.orig +21 -0
  271. data/rust-vendor/id-arena/LICENSE-APACHE +201 -0
  272. data/rust-vendor/id-arena/LICENSE-MIT +25 -0
  273. data/rust-vendor/id-arena/README.md +101 -0
  274. data/rust-vendor/id-arena/README.tpl +3 -0
  275. data/rust-vendor/id-arena/src/lib.rs +726 -0
  276. data/rust-vendor/id-arena/src/rayon.rs +282 -0
  277. data/rust-vendor/id-arena/tests/readme_up_to_date.rs +22 -0
  278. data/rust-vendor/leb128fmt/.cargo-checksum.json +1 -0
  279. data/rust-vendor/leb128fmt/.cargo_vcs_info.json +6 -0
  280. data/rust-vendor/leb128fmt/CHANGELOG.md +11 -0
  281. data/rust-vendor/leb128fmt/Cargo.toml +55 -0
  282. data/rust-vendor/leb128fmt/Cargo.toml.orig +32 -0
  283. data/rust-vendor/leb128fmt/LICENSE-APACHE +201 -0
  284. data/rust-vendor/leb128fmt/LICENSE-MIT +23 -0
  285. data/rust-vendor/leb128fmt/README.md +162 -0
  286. data/rust-vendor/leb128fmt/src/lib.rs +1650 -0
  287. data/rust-vendor/libc/.cargo-checksum.json +1 -1
  288. data/rust-vendor/libc/.cargo_vcs_info.json +1 -1
  289. data/rust-vendor/libc/CHANGELOG.md +42 -0
  290. data/rust-vendor/libc/Cargo.lock +1 -1
  291. data/rust-vendor/libc/Cargo.toml +75 -51
  292. data/rust-vendor/libc/Cargo.toml.orig +85 -53
  293. data/rust-vendor/libc/LICENSE-MIT +1 -1
  294. data/rust-vendor/libc/src/fuchsia/mod.rs +12 -10
  295. data/rust-vendor/libc/src/macros.rs +63 -71
  296. data/rust-vendor/libc/src/new/linux_uapi/linux/can/error.rs +73 -0
  297. data/rust-vendor/libc/src/new/linux_uapi/linux/can.rs +1 -0
  298. data/rust-vendor/libc/src/new/mod.rs +3 -2
  299. data/rust-vendor/libc/src/new/qurt/dlfcn.rs +26 -0
  300. data/rust-vendor/libc/src/new/qurt/fcntl.rs +4 -1
  301. data/rust-vendor/libc/src/new/qurt/mod.rs +224 -14
  302. data/rust-vendor/libc/src/new/qurt/pthread.rs +1 -22
  303. data/rust-vendor/libc/src/new/qurt/signal.rs +54 -4
  304. data/rust-vendor/libc/src/new/qurt/stdio.rs +0 -5
  305. data/rust-vendor/libc/src/new/qurt/sys/mman.rs +55 -0
  306. data/rust-vendor/libc/src/new/qurt/sys/mod.rs +2 -0
  307. data/rust-vendor/libc/src/new/qurt/sys/sched.rs +24 -0
  308. data/rust-vendor/libc/src/new/qurt/sys/stat.rs +0 -6
  309. data/rust-vendor/libc/src/new/qurt/time.rs +4 -22
  310. data/rust-vendor/libc/src/new/qurt/unistd.rs +210 -20
  311. data/rust-vendor/libc/src/qurt/mod.rs +9 -325
  312. data/rust-vendor/libc/src/types.rs +2 -2
  313. data/rust-vendor/libc/src/unix/aix/mod.rs +11 -20
  314. data/rust-vendor/libc/src/unix/aix/powerpc64.rs +6 -6
  315. data/rust-vendor/libc/src/unix/bsd/apple/mod.rs +15 -0
  316. data/rust-vendor/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs +4 -4
  317. data/rust-vendor/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs +3 -3
  318. data/rust-vendor/libc/src/unix/bsd/freebsdlike/mod.rs +14 -0
  319. data/rust-vendor/libc/src/unix/bsd/mod.rs +0 -14
  320. data/rust-vendor/libc/src/unix/bsd/netbsdlike/mod.rs +6 -0
  321. data/rust-vendor/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs +15 -7
  322. data/rust-vendor/libc/src/unix/bsd/netbsdlike/openbsd/mod.rs +41 -1
  323. data/rust-vendor/libc/src/unix/cygwin/mod.rs +2 -2
  324. data/rust-vendor/libc/src/unix/haiku/mod.rs +1 -1
  325. data/rust-vendor/libc/src/unix/haiku/x86_64.rs +2 -2
  326. data/rust-vendor/libc/src/unix/hurd/mod.rs +6 -6
  327. data/rust-vendor/libc/src/unix/linux_like/android/mod.rs +2 -0
  328. data/rust-vendor/libc/src/unix/linux_like/linux/gnu/mod.rs +3 -0
  329. data/rust-vendor/libc/src/unix/linux_like/linux/musl/b32/arm/mod.rs +16 -13
  330. data/rust-vendor/libc/src/unix/linux_like/linux/musl/b32/hexagon.rs +12 -13
  331. data/rust-vendor/libc/src/unix/linux_like/linux/musl/b32/mips/mod.rs +25 -16
  332. data/rust-vendor/libc/src/unix/linux_like/linux/musl/b32/powerpc.rs +16 -13
  333. data/rust-vendor/libc/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs +12 -15
  334. data/rust-vendor/libc/src/unix/linux_like/linux/musl/b32/x86/mod.rs +10 -13
  335. data/rust-vendor/libc/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +0 -15
  336. data/rust-vendor/libc/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs +0 -15
  337. data/rust-vendor/libc/src/unix/linux_like/linux/musl/b64/mips64.rs +0 -15
  338. data/rust-vendor/libc/src/unix/linux_like/linux/musl/b64/powerpc64.rs +0 -15
  339. data/rust-vendor/libc/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs +0 -15
  340. data/rust-vendor/libc/src/unix/linux_like/linux/musl/b64/s390x.rs +0 -15
  341. data/rust-vendor/libc/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs +0 -15
  342. data/rust-vendor/libc/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs +9 -15
  343. data/rust-vendor/libc/src/unix/mod.rs +87 -11
  344. data/rust-vendor/libc/src/unix/newlib/arm/mod.rs +1 -1
  345. data/rust-vendor/libc/src/unix/newlib/horizon/mod.rs +1 -1
  346. data/rust-vendor/libc/src/unix/newlib/vita/mod.rs +3 -3
  347. data/rust-vendor/libc/src/unix/nto/mod.rs +23 -6
  348. data/rust-vendor/libc/src/unix/redox/mod.rs +45 -3
  349. data/rust-vendor/libc/src/unix/solarish/illumos.rs +2 -0
  350. data/rust-vendor/libc/src/vxworks/mod.rs +7 -7
  351. data/rust-vendor/memchr/.cargo-checksum.json +1 -1
  352. data/rust-vendor/memchr/.cargo_vcs_info.json +1 -1
  353. data/rust-vendor/memchr/Cargo.lock +13 -13
  354. data/rust-vendor/memchr/Cargo.toml +1 -1
  355. data/rust-vendor/memchr/Cargo.toml.orig +1 -1
  356. data/rust-vendor/memchr/src/cow.rs +3 -1
  357. data/rust-vendor/memchr/src/memmem/mod.rs +42 -3
  358. data/rust-vendor/prettyplease/.cargo-checksum.json +1 -0
  359. data/rust-vendor/prettyplease/.cargo_vcs_info.json +6 -0
  360. data/rust-vendor/prettyplease/.github/FUNDING.yml +1 -0
  361. data/rust-vendor/prettyplease/.github/workflows/ci.yml +123 -0
  362. data/rust-vendor/prettyplease/Cargo.lock +54 -0
  363. data/rust-vendor/prettyplease/Cargo.toml +90 -0
  364. data/rust-vendor/prettyplease/Cargo.toml.orig +43 -0
  365. data/rust-vendor/prettyplease/LICENSE-APACHE +176 -0
  366. data/rust-vendor/prettyplease/LICENSE-MIT +23 -0
  367. data/rust-vendor/prettyplease/README.md +312 -0
  368. data/rust-vendor/prettyplease/build.rs +21 -0
  369. data/rust-vendor/prettyplease/examples/.tokeignore +1 -0
  370. data/rust-vendor/prettyplease/examples/input.rs +1 -0
  371. data/rust-vendor/prettyplease/examples/output.prettyplease.rs +593 -0
  372. data/rust-vendor/prettyplease/examples/output.rustc.rs +506 -0
  373. data/rust-vendor/prettyplease/examples/output.rustfmt.rs +552 -0
  374. data/rust-vendor/prettyplease/src/algorithm.rs +386 -0
  375. data/rust-vendor/prettyplease/src/attr.rs +288 -0
  376. data/rust-vendor/prettyplease/src/classify.rs +324 -0
  377. data/rust-vendor/prettyplease/src/convenience.rs +98 -0
  378. data/rust-vendor/prettyplease/src/data.rs +79 -0
  379. data/rust-vendor/prettyplease/src/expr.rs +1533 -0
  380. data/rust-vendor/prettyplease/src/file.rs +17 -0
  381. data/rust-vendor/prettyplease/src/fixup.rs +676 -0
  382. data/rust-vendor/prettyplease/src/generics.rs +426 -0
  383. data/rust-vendor/prettyplease/src/item.rs +1813 -0
  384. data/rust-vendor/prettyplease/src/iter.rs +46 -0
  385. data/rust-vendor/prettyplease/src/lib.rs +385 -0
  386. data/rust-vendor/prettyplease/src/lifetime.rs +9 -0
  387. data/rust-vendor/prettyplease/src/lit.rs +57 -0
  388. data/rust-vendor/prettyplease/src/mac.rs +706 -0
  389. data/rust-vendor/prettyplease/src/pat.rs +254 -0
  390. data/rust-vendor/prettyplease/src/path.rs +194 -0
  391. data/rust-vendor/prettyplease/src/precedence.rs +148 -0
  392. data/rust-vendor/prettyplease/src/ring.rs +81 -0
  393. data/rust-vendor/prettyplease/src/stmt.rs +221 -0
  394. data/rust-vendor/prettyplease/src/token.rs +80 -0
  395. data/rust-vendor/prettyplease/src/ty.rs +326 -0
  396. data/rust-vendor/prettyplease/tests/test.rs +51 -0
  397. data/rust-vendor/prettyplease/tests/test_precedence.rs +900 -0
  398. data/rust-vendor/regex/.cargo-checksum.json +1 -1
  399. data/rust-vendor/regex/.cargo_vcs_info.json +1 -1
  400. data/rust-vendor/regex/CHANGELOG.md +13 -0
  401. data/rust-vendor/regex/Cargo.lock +5 -5
  402. data/rust-vendor/regex/Cargo.toml +15 -7
  403. data/rust-vendor/regex/Cargo.toml.orig +19 -2
  404. data/rust-vendor/regex-automata/.cargo-checksum.json +1 -1
  405. data/rust-vendor/regex-automata/.cargo_vcs_info.json +1 -1
  406. data/rust-vendor/regex-automata/Cargo.lock +3 -3
  407. data/rust-vendor/regex-automata/Cargo.toml +16 -1
  408. data/rust-vendor/regex-automata/Cargo.toml.orig +2 -1
  409. data/rust-vendor/regex-automata/src/dfa/onepass.rs +21 -5
  410. data/rust-vendor/regex-automata/tests/dfa/onepass/mod.rs +1 -0
  411. data/rust-vendor/regex-automata/tests/dfa/onepass/regression.rs +61 -0
  412. data/rust-vendor/regex-automata/tests/nfa/thompson/backtrack/mod.rs +1 -0
  413. data/rust-vendor/regex-automata/tests/nfa/thompson/backtrack/regression.rs +20 -0
  414. data/rust-vendor/regex-automata/tests/nfa/thompson/pikevm/mod.rs +1 -0
  415. data/rust-vendor/regex-automata/tests/nfa/thompson/pikevm/regression.rs +20 -0
  416. data/rust-vendor/regex-syntax/.cargo-checksum.json +1 -1
  417. data/rust-vendor/regex-syntax/.cargo_vcs_info.json +1 -1
  418. data/rust-vendor/regex-syntax/Cargo.lock +1 -1
  419. data/rust-vendor/regex-syntax/Cargo.toml +16 -5
  420. data/rust-vendor/regex-syntax/Cargo.toml.orig +2 -1
  421. data/rust-vendor/semver/.cargo-checksum.json +1 -0
  422. data/rust-vendor/semver/.cargo_vcs_info.json +6 -0
  423. data/rust-vendor/semver/.github/FUNDING.yml +1 -0
  424. data/rust-vendor/semver/.github/workflows/ci.yml +140 -0
  425. data/rust-vendor/semver/Cargo.lock +75 -0
  426. data/rust-vendor/semver/Cargo.toml +86 -0
  427. data/rust-vendor/semver/Cargo.toml.orig +36 -0
  428. data/rust-vendor/semver/LICENSE-APACHE +176 -0
  429. data/rust-vendor/semver/LICENSE-MIT +23 -0
  430. data/rust-vendor/semver/README.md +84 -0
  431. data/rust-vendor/semver/benches/parse.rs +24 -0
  432. data/rust-vendor/semver/src/display.rs +163 -0
  433. data/rust-vendor/semver/src/error.rs +126 -0
  434. data/rust-vendor/semver/src/eval.rs +179 -0
  435. data/rust-vendor/semver/src/identifier.rs +412 -0
  436. data/rust-vendor/semver/src/impls.rs +163 -0
  437. data/rust-vendor/semver/src/lib.rs +570 -0
  438. data/rust-vendor/semver/src/parse.rs +404 -0
  439. data/rust-vendor/semver/src/serde.rs +109 -0
  440. data/rust-vendor/semver/tests/node/mod.rs +43 -0
  441. data/rust-vendor/semver/tests/test_autotrait.rs +14 -0
  442. data/rust-vendor/semver/tests/test_identifier.rs +51 -0
  443. data/rust-vendor/semver/tests/test_version.rs +251 -0
  444. data/rust-vendor/semver/tests/test_version_req.rs +480 -0
  445. data/rust-vendor/semver/tests/util/mod.rs +54 -0
  446. data/rust-vendor/symbolic-common/.cargo-checksum.json +1 -1
  447. data/rust-vendor/symbolic-common/Cargo.lock +74 -3
  448. data/rust-vendor/symbolic-common/Cargo.toml +2 -2
  449. data/rust-vendor/symbolic-common/Cargo.toml.orig +1 -1
  450. data/rust-vendor/symbolic-demangle/.cargo-checksum.json +1 -1
  451. data/rust-vendor/symbolic-demangle/Cargo.lock +87 -9
  452. data/rust-vendor/symbolic-demangle/Cargo.toml +5 -5
  453. data/rust-vendor/symbolic-demangle/Cargo.toml.orig +2 -2
  454. data/rust-vendor/syn/.cargo-checksum.json +1 -1
  455. data/rust-vendor/syn/.cargo_vcs_info.json +1 -1
  456. data/rust-vendor/syn/Cargo.lock +322 -109
  457. data/rust-vendor/syn/Cargo.toml +2 -2
  458. data/rust-vendor/syn/Cargo.toml.orig +2 -2
  459. data/rust-vendor/syn/benches/rust.rs +1 -2
  460. data/rust-vendor/syn/src/lib.rs +1 -1
  461. data/rust-vendor/syn/src/parse.rs +2 -2
  462. data/rust-vendor/syn/src/path.rs +1 -5
  463. data/rust-vendor/syn/tests/common/eq.rs +28 -17
  464. data/rust-vendor/syn/tests/common/parse.rs +1 -2
  465. data/rust-vendor/syn/tests/repo/progress.rs +1 -1
  466. data/rust-vendor/syn/tests/test_round_trip.rs +5 -36
  467. data/rust-vendor/tempfile/.cargo-checksum.json +1 -1
  468. data/rust-vendor/tempfile/.cargo_vcs_info.json +1 -1
  469. data/rust-vendor/tempfile/CHANGELOG.md +4 -0
  470. data/rust-vendor/tempfile/Cargo.lock +333 -21
  471. data/rust-vendor/tempfile/Cargo.toml +2 -2
  472. data/rust-vendor/tempfile/Cargo.toml.orig +2 -2
  473. data/rust-vendor/unicode-ident/.cargo-checksum.json +1 -1
  474. data/rust-vendor/unicode-ident/.cargo_vcs_info.json +1 -1
  475. data/rust-vendor/unicode-ident/.github/workflows/ci.yml +10 -10
  476. data/rust-vendor/unicode-ident/Cargo.lock +468 -186
  477. data/rust-vendor/unicode-ident/Cargo.toml +8 -8
  478. data/rust-vendor/unicode-ident/Cargo.toml.orig +7 -5
  479. data/rust-vendor/unicode-ident/src/lib.rs +1 -1
  480. data/rust-vendor/unicode-xid/.cargo-checksum.json +1 -0
  481. data/rust-vendor/unicode-xid/.cargo_vcs_info.json +6 -0
  482. data/rust-vendor/unicode-xid/COPYRIGHT +7 -0
  483. data/rust-vendor/unicode-xid/Cargo.toml +65 -0
  484. data/rust-vendor/unicode-xid/Cargo.toml.orig +34 -0
  485. data/rust-vendor/unicode-xid/LICENSE-APACHE +201 -0
  486. data/rust-vendor/unicode-xid/LICENSE-MIT +25 -0
  487. data/rust-vendor/unicode-xid/README.md +61 -0
  488. data/rust-vendor/unicode-xid/benches/xid.rs +60 -0
  489. data/rust-vendor/unicode-xid/src/lib.rs +90 -0
  490. data/rust-vendor/unicode-xid/src/tables.rs +1537 -0
  491. data/rust-vendor/unicode-xid/src/tests.rs +95 -0
  492. data/rust-vendor/unicode-xid/tests/exhaustive_tests.rs +25 -0
  493. data/rust-vendor/uuid/.cargo-checksum.json +1 -1
  494. data/rust-vendor/uuid/.cargo_vcs_info.json +1 -1
  495. data/rust-vendor/uuid/Cargo.lock +298 -44
  496. data/rust-vendor/uuid/Cargo.toml +5 -5
  497. data/rust-vendor/uuid/Cargo.toml.orig +5 -5
  498. data/rust-vendor/uuid/README.md +3 -3
  499. data/rust-vendor/uuid/src/error.rs +1 -7
  500. data/rust-vendor/uuid/src/lib.rs +4 -4
  501. data/rust-vendor/wasip3/.cargo-checksum.json +1 -0
  502. data/rust-vendor/wasip3/.cargo_vcs_info.json +6 -0
  503. data/rust-vendor/wasip3/Cargo.lock +483 -0
  504. data/rust-vendor/wasip3/Cargo.toml +96 -0
  505. data/rust-vendor/wasip3/Cargo.toml.orig +49 -0
  506. data/rust-vendor/wasip3/README.md +56 -0
  507. data/rust-vendor/wasip3/examples/cli-command.rs +19 -0
  508. data/rust-vendor/wasip3/examples/http-proxy-compat.rs +20 -0
  509. data/rust-vendor/wasip3/examples/http-proxy.rs +22 -0
  510. data/rust-vendor/wasip3/src/command.rs +513 -0
  511. data/rust-vendor/wasip3/src/http_compat/body_writer.rs +145 -0
  512. data/rust-vendor/wasip3/src/http_compat/conversions.rs +307 -0
  513. data/rust-vendor/wasip3/src/http_compat/mod.rs +314 -0
  514. data/rust-vendor/wasip3/src/imports.rs +10543 -0
  515. data/rust-vendor/wasip3/src/lib.rs +280 -0
  516. data/rust-vendor/wasip3/src/service.rs +7274 -0
  517. data/rust-vendor/wasip3/wit/deps/cli.wit +256 -0
  518. data/rust-vendor/wasip3/wit/deps/clocks.wit +161 -0
  519. data/rust-vendor/wasip3/wit/deps/filesystem.wit +553 -0
  520. data/rust-vendor/wasip3/wit/deps/http.wit +457 -0
  521. data/rust-vendor/wasip3/wit/deps/random.wit +92 -0
  522. data/rust-vendor/wasip3/wit/deps/sockets.wit +752 -0
  523. data/rust-vendor/wasip3/wit/wasi-crate.wit +1 -0
  524. data/rust-vendor/wasm-encoder/.cargo-checksum.json +1 -0
  525. data/rust-vendor/wasm-encoder/.cargo_vcs_info.json +6 -0
  526. data/rust-vendor/wasm-encoder/Cargo.lock +348 -0
  527. data/rust-vendor/wasm-encoder/Cargo.toml +104 -0
  528. data/rust-vendor/wasm-encoder/Cargo.toml.orig +43 -0
  529. data/rust-vendor/wasm-encoder/README.md +81 -0
  530. data/rust-vendor/wasm-encoder/src/component/aliases.rs +161 -0
  531. data/rust-vendor/wasm-encoder/src/component/builder.rs +826 -0
  532. data/rust-vendor/wasm-encoder/src/component/canonicals.rs +584 -0
  533. data/rust-vendor/wasm-encoder/src/component/components.rs +30 -0
  534. data/rust-vendor/wasm-encoder/src/component/exports.rs +130 -0
  535. data/rust-vendor/wasm-encoder/src/component/imports.rs +170 -0
  536. data/rust-vendor/wasm-encoder/src/component/instances.rs +200 -0
  537. data/rust-vendor/wasm-encoder/src/component/modules.rs +30 -0
  538. data/rust-vendor/wasm-encoder/src/component/names.rs +162 -0
  539. data/rust-vendor/wasm-encoder/src/component/start.rs +53 -0
  540. data/rust-vendor/wasm-encoder/src/component/types.rs +816 -0
  541. data/rust-vendor/wasm-encoder/src/component.rs +169 -0
  542. data/rust-vendor/wasm-encoder/src/core/branch_hints.rs +127 -0
  543. data/rust-vendor/wasm-encoder/src/core/code.rs +2464 -0
  544. data/rust-vendor/wasm-encoder/src/core/custom.rs +74 -0
  545. data/rust-vendor/wasm-encoder/src/core/data.rs +187 -0
  546. data/rust-vendor/wasm-encoder/src/core/dump.rs +629 -0
  547. data/rust-vendor/wasm-encoder/src/core/elements.rs +225 -0
  548. data/rust-vendor/wasm-encoder/src/core/exports.rs +86 -0
  549. data/rust-vendor/wasm-encoder/src/core/functions.rs +64 -0
  550. data/rust-vendor/wasm-encoder/src/core/globals.rs +101 -0
  551. data/rust-vendor/wasm-encoder/src/core/imports.rs +230 -0
  552. data/rust-vendor/wasm-encoder/src/core/instructions.rs +4686 -0
  553. data/rust-vendor/wasm-encoder/src/core/linking.rs +264 -0
  554. data/rust-vendor/wasm-encoder/src/core/memories.rs +116 -0
  555. data/rust-vendor/wasm-encoder/src/core/names.rs +305 -0
  556. data/rust-vendor/wasm-encoder/src/core/producers.rs +181 -0
  557. data/rust-vendor/wasm-encoder/src/core/start.rs +40 -0
  558. data/rust-vendor/wasm-encoder/src/core/tables.rs +130 -0
  559. data/rust-vendor/wasm-encoder/src/core/tags.rs +86 -0
  560. data/rust-vendor/wasm-encoder/src/core/types.rs +753 -0
  561. data/rust-vendor/wasm-encoder/src/core.rs +179 -0
  562. data/rust-vendor/wasm-encoder/src/lib.rs +224 -0
  563. data/rust-vendor/wasm-encoder/src/raw.rs +32 -0
  564. data/rust-vendor/wasm-encoder/src/reencode/component.rs +1548 -0
  565. data/rust-vendor/wasm-encoder/src/reencode.rs +2134 -0
  566. data/rust-vendor/wasm-metadata/.cargo-checksum.json +1 -0
  567. data/rust-vendor/wasm-metadata/.cargo_vcs_info.json +6 -0
  568. data/rust-vendor/wasm-metadata/Cargo.lock +769 -0
  569. data/rust-vendor/wasm-metadata/Cargo.toml +152 -0
  570. data/rust-vendor/wasm-metadata/Cargo.toml.orig +38 -0
  571. data/rust-vendor/wasm-metadata/README.md +27 -0
  572. data/rust-vendor/wasm-metadata/src/add_metadata.rs +91 -0
  573. data/rust-vendor/wasm-metadata/src/clap.rs +169 -0
  574. data/rust-vendor/wasm-metadata/src/dependencies.rs +142 -0
  575. data/rust-vendor/wasm-metadata/src/lib.rs +83 -0
  576. data/rust-vendor/wasm-metadata/src/metadata.rs +34 -0
  577. data/rust-vendor/wasm-metadata/src/names/component.rs +107 -0
  578. data/rust-vendor/wasm-metadata/src/names/mod.rs +5 -0
  579. data/rust-vendor/wasm-metadata/src/names/module.rs +101 -0
  580. data/rust-vendor/wasm-metadata/src/oci_annotations/authors.rs +111 -0
  581. data/rust-vendor/wasm-metadata/src/oci_annotations/description.rs +110 -0
  582. data/rust-vendor/wasm-metadata/src/oci_annotations/homepage.rs +118 -0
  583. data/rust-vendor/wasm-metadata/src/oci_annotations/licenses.rs +122 -0
  584. data/rust-vendor/wasm-metadata/src/oci_annotations/mod.rs +32 -0
  585. data/rust-vendor/wasm-metadata/src/oci_annotations/revision.rs +113 -0
  586. data/rust-vendor/wasm-metadata/src/oci_annotations/source.rs +117 -0
  587. data/rust-vendor/wasm-metadata/src/oci_annotations/version.rs +110 -0
  588. data/rust-vendor/wasm-metadata/src/payload.rs +215 -0
  589. data/rust-vendor/wasm-metadata/src/producers.rs +254 -0
  590. data/rust-vendor/wasm-metadata/src/rewrite.rs +224 -0
  591. data/rust-vendor/wasm-metadata/src/utils.rs +21 -0
  592. data/rust-vendor/wasm-metadata/tests/component.rs +310 -0
  593. data/rust-vendor/wasm-metadata/tests/module.rs +86 -0
  594. data/rust-vendor/wasmparser/.cargo-checksum.json +1 -0
  595. data/rust-vendor/wasmparser/.cargo_vcs_info.json +6 -0
  596. data/rust-vendor/wasmparser/Cargo.lock +687 -0
  597. data/rust-vendor/wasmparser/Cargo.toml +161 -0
  598. data/rust-vendor/wasmparser/Cargo.toml.orig +89 -0
  599. data/rust-vendor/wasmparser/README.md +28 -0
  600. data/rust-vendor/wasmparser/benches/.gitignore +1 -0
  601. data/rust-vendor/wasmparser/benches/benchmark.rs +395 -0
  602. data/rust-vendor/wasmparser/examples/simple.rs +37 -0
  603. data/rust-vendor/wasmparser/src/arity.rs +318 -0
  604. data/rust-vendor/wasmparser/src/binary_reader.rs +2109 -0
  605. data/rust-vendor/wasmparser/src/collections/hash.rs +120 -0
  606. data/rust-vendor/wasmparser/src/collections/index_map/detail.rs +1100 -0
  607. data/rust-vendor/wasmparser/src/collections/index_map/tests.rs +183 -0
  608. data/rust-vendor/wasmparser/src/collections/index_map.rs +653 -0
  609. data/rust-vendor/wasmparser/src/collections/index_set.rs +316 -0
  610. data/rust-vendor/wasmparser/src/collections/map.rs +852 -0
  611. data/rust-vendor/wasmparser/src/collections/mod.rs +34 -0
  612. data/rust-vendor/wasmparser/src/collections/set.rs +672 -0
  613. data/rust-vendor/wasmparser/src/features.rs +442 -0
  614. data/rust-vendor/wasmparser/src/lib.rs +1340 -0
  615. data/rust-vendor/wasmparser/src/limits.rs +90 -0
  616. data/rust-vendor/wasmparser/src/parser.rs +1925 -0
  617. data/rust-vendor/wasmparser/src/readers/component/aliases.rs +119 -0
  618. data/rust-vendor/wasmparser/src/readers/component/canonicals.rs +458 -0
  619. data/rust-vendor/wasmparser/src/readers/component/exports.rs +135 -0
  620. data/rust-vendor/wasmparser/src/readers/component/imports.rs +145 -0
  621. data/rust-vendor/wasmparser/src/readers/component/instances.rs +166 -0
  622. data/rust-vendor/wasmparser/src/readers/component/names.rs +101 -0
  623. data/rust-vendor/wasmparser/src/readers/component/start.rs +31 -0
  624. data/rust-vendor/wasmparser/src/readers/component/types.rs +537 -0
  625. data/rust-vendor/wasmparser/src/readers/component.rs +17 -0
  626. data/rust-vendor/wasmparser/src/readers/core/branch_hinting.rs +59 -0
  627. data/rust-vendor/wasmparser/src/readers/core/code.rs +177 -0
  628. data/rust-vendor/wasmparser/src/readers/core/coredumps.rs +274 -0
  629. data/rust-vendor/wasmparser/src/readers/core/custom.rs +134 -0
  630. data/rust-vendor/wasmparser/src/readers/core/data.rs +94 -0
  631. data/rust-vendor/wasmparser/src/readers/core/dylink0.rs +117 -0
  632. data/rust-vendor/wasmparser/src/readers/core/elements.rs +153 -0
  633. data/rust-vendor/wasmparser/src/readers/core/exports.rs +75 -0
  634. data/rust-vendor/wasmparser/src/readers/core/functions.rs +17 -0
  635. data/rust-vendor/wasmparser/src/readers/core/globals.rs +51 -0
  636. data/rust-vendor/wasmparser/src/readers/core/imports.rs +307 -0
  637. data/rust-vendor/wasmparser/src/readers/core/init.rs +70 -0
  638. data/rust-vendor/wasmparser/src/readers/core/linking.rs +457 -0
  639. data/rust-vendor/wasmparser/src/readers/core/memories.rs +61 -0
  640. data/rust-vendor/wasmparser/src/readers/core/names.rs +162 -0
  641. data/rust-vendor/wasmparser/src/readers/core/operators.rs +1105 -0
  642. data/rust-vendor/wasmparser/src/readers/core/producers.rs +84 -0
  643. data/rust-vendor/wasmparser/src/readers/core/reloc.rs +300 -0
  644. data/rust-vendor/wasmparser/src/readers/core/tables.rs +96 -0
  645. data/rust-vendor/wasmparser/src/readers/core/tags.rs +32 -0
  646. data/rust-vendor/wasmparser/src/readers/core/types/matches.rs +321 -0
  647. data/rust-vendor/wasmparser/src/readers/core/types.rs +2249 -0
  648. data/rust-vendor/wasmparser/src/readers/core.rs +43 -0
  649. data/rust-vendor/wasmparser/src/readers.rs +330 -0
  650. data/rust-vendor/wasmparser/src/resources.rs +265 -0
  651. data/rust-vendor/wasmparser/src/validator/component.rs +4765 -0
  652. data/rust-vendor/wasmparser/src/validator/component_types.rs +4036 -0
  653. data/rust-vendor/wasmparser/src/validator/core/canonical.rs +552 -0
  654. data/rust-vendor/wasmparser/src/validator/core.rs +1313 -0
  655. data/rust-vendor/wasmparser/src/validator/func.rs +613 -0
  656. data/rust-vendor/wasmparser/src/validator/names.rs +1017 -0
  657. data/rust-vendor/wasmparser/src/validator/operators/simd.rs +971 -0
  658. data/rust-vendor/wasmparser/src/validator/operators.rs +4696 -0
  659. data/rust-vendor/wasmparser/src/validator/types.rs +1327 -0
  660. data/rust-vendor/wasmparser/src/validator.rs +1645 -0
  661. data/rust-vendor/wasmparser/tests/big-module.rs +62 -0
  662. data/rust-vendor/wit-bindgen/.cargo-checksum.json +1 -1
  663. data/rust-vendor/wit-bindgen/.cargo_vcs_info.json +1 -1
  664. data/rust-vendor/wit-bindgen/Cargo.lock +76 -66
  665. data/rust-vendor/wit-bindgen/Cargo.toml +25 -11
  666. data/rust-vendor/wit-bindgen/Cargo.toml.orig +11 -3
  667. data/rust-vendor/wit-bindgen/src/lib.rs +21 -15
  668. data/rust-vendor/wit-bindgen/src/rt/async_support/abi_buffer.rs +35 -32
  669. data/rust-vendor/wit-bindgen/src/rt/async_support/cabi.rs +15 -20
  670. data/rust-vendor/wit-bindgen/src/rt/async_support/error_context.rs +11 -22
  671. data/rust-vendor/wit-bindgen/src/rt/async_support/future_support.rs +406 -146
  672. data/rust-vendor/wit-bindgen/src/rt/async_support/inter_task_wakeup.rs +98 -0
  673. data/rust-vendor/wit-bindgen/src/rt/async_support/inter_task_wakeup_disabled.rs +45 -0
  674. data/rust-vendor/wit-bindgen/src/rt/async_support/spawn.rs +82 -0
  675. data/rust-vendor/wit-bindgen/src/rt/async_support/spawn_disabled.rs +30 -0
  676. data/rust-vendor/wit-bindgen/src/rt/async_support/stream_support.rs +262 -122
  677. data/rust-vendor/wit-bindgen/src/rt/async_support/subtask.rs +49 -54
  678. data/rust-vendor/wit-bindgen/src/rt/async_support/unit_stream.rs +81 -0
  679. data/rust-vendor/wit-bindgen/src/rt/async_support/waitable.rs +47 -31
  680. data/rust-vendor/wit-bindgen/src/rt/async_support/waitable_set.rs +17 -35
  681. data/rust-vendor/wit-bindgen/src/rt/async_support.rs +262 -188
  682. data/rust-vendor/wit-bindgen/src/rt/mod.rs +14 -12
  683. data/rust-vendor/wit-bindgen/src/rt/wit_bindgen_cabi_realloc.c +2 -2
  684. data/rust-vendor/wit-bindgen/src/rt/wit_bindgen_cabi_realloc.o +0 -0
  685. data/rust-vendor/wit-bindgen/src/rt/wit_bindgen_cabi_realloc.rs +2 -2
  686. data/rust-vendor/wit-bindgen/src/rt/wit_bindgen_cabi_wasip3.o +0 -0
  687. data/rust-vendor/wit-bindgen-0.46.0/.cargo-checksum.json +1 -0
  688. data/rust-vendor/wit-bindgen-0.46.0/.cargo_vcs_info.json +6 -0
  689. data/rust-vendor/wit-bindgen-0.46.0/Cargo.lock +428 -0
  690. data/rust-vendor/wit-bindgen-0.46.0/Cargo.toml +88 -0
  691. data/rust-vendor/wit-bindgen-0.46.0/Cargo.toml.orig +37 -0
  692. data/rust-vendor/wit-bindgen-0.46.0/LICENSE-APACHE +201 -0
  693. data/rust-vendor/wit-bindgen-0.46.0/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
  694. data/rust-vendor/wit-bindgen-0.46.0/LICENSE-MIT +23 -0
  695. data/rust-vendor/wit-bindgen-0.46.0/README.md +45 -0
  696. data/rust-vendor/wit-bindgen-0.46.0/build.rs +32 -0
  697. data/rust-vendor/wit-bindgen-0.46.0/src/examples/_0_world_imports.rs +17 -0
  698. data/rust-vendor/wit-bindgen-0.46.0/src/examples/_1_interface_imports.rs +32 -0
  699. data/rust-vendor/wit-bindgen-0.46.0/src/examples/_2_imported_resources.rs +22 -0
  700. data/rust-vendor/wit-bindgen-0.46.0/src/examples/_3_world_exports.rs +47 -0
  701. data/rust-vendor/wit-bindgen-0.46.0/src/examples/_4_exported_resources.rs +26 -0
  702. data/rust-vendor/wit-bindgen-0.46.0/src/examples.rs +55 -0
  703. data/rust-vendor/wit-bindgen-0.46.0/src/lib.rs +881 -0
  704. data/rust-vendor/wit-bindgen-0.46.0/src/rt/async_support/abi_buffer.rs +417 -0
  705. data/rust-vendor/wit-bindgen-0.46.0/src/rt/async_support/cabi.rs +112 -0
  706. data/rust-vendor/wit-bindgen-0.46.0/src/rt/async_support/error_context.rs +94 -0
  707. data/rust-vendor/wit-bindgen-0.46.0/src/rt/async_support/future_support.rs +734 -0
  708. data/rust-vendor/wit-bindgen-0.46.0/src/rt/async_support/stream_support.rs +604 -0
  709. data/rust-vendor/wit-bindgen-0.46.0/src/rt/async_support/subtask.rs +289 -0
  710. data/rust-vendor/wit-bindgen-0.46.0/src/rt/async_support/waitable.rs +466 -0
  711. data/rust-vendor/wit-bindgen-0.46.0/src/rt/async_support/waitable_set.rs +100 -0
  712. data/rust-vendor/wit-bindgen-0.46.0/src/rt/async_support.rs +634 -0
  713. data/rust-vendor/wit-bindgen-0.46.0/src/rt/mod.rs +230 -0
  714. data/rust-vendor/wit-bindgen-0.46.0/src/rt/wit_bindgen_cabi_realloc.c +10 -0
  715. data/rust-vendor/wit-bindgen-0.46.0/src/rt/wit_bindgen_cabi_realloc.o +0 -0
  716. data/rust-vendor/wit-bindgen-0.46.0/src/rt/wit_bindgen_cabi_realloc.rs +11 -0
  717. data/rust-vendor/wit-bindgen-0.46.0/src/rt/wit_bindgen_cabi_wasip3.c +12 -0
  718. data/rust-vendor/wit-bindgen-0.46.0/src/rt/wit_bindgen_cabi_wasip3.o +0 -0
  719. data/rust-vendor/wit-bindgen-0.46.0/wasi-cli@0.2.0.wasm +0 -0
  720. data/rust-vendor/wit-bindgen-core/.cargo-checksum.json +1 -0
  721. data/rust-vendor/wit-bindgen-core/.cargo_vcs_info.json +6 -0
  722. data/rust-vendor/wit-bindgen-core/Cargo.lock +340 -0
  723. data/rust-vendor/wit-bindgen-core/Cargo.toml +75 -0
  724. data/rust-vendor/wit-bindgen-core/Cargo.toml.orig +30 -0
  725. data/rust-vendor/wit-bindgen-core/LICENSE-APACHE +201 -0
  726. data/rust-vendor/wit-bindgen-core/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
  727. data/rust-vendor/wit-bindgen-core/LICENSE-MIT +23 -0
  728. data/rust-vendor/wit-bindgen-core/src/abi.rs +2526 -0
  729. data/rust-vendor/wit-bindgen-core/src/async_.rs +200 -0
  730. data/rust-vendor/wit-bindgen-core/src/lib.rs +239 -0
  731. data/rust-vendor/wit-bindgen-core/src/ns.rs +27 -0
  732. data/rust-vendor/wit-bindgen-core/src/path.rs +47 -0
  733. data/rust-vendor/wit-bindgen-core/src/source.rs +222 -0
  734. data/rust-vendor/wit-bindgen-core/src/types.rs +232 -0
  735. data/rust-vendor/wit-bindgen-rust/.cargo-checksum.json +1 -0
  736. data/rust-vendor/wit-bindgen-rust/.cargo_vcs_info.json +6 -0
  737. data/rust-vendor/wit-bindgen-rust/Cargo.lock +547 -0
  738. data/rust-vendor/wit-bindgen-rust/Cargo.toml +112 -0
  739. data/rust-vendor/wit-bindgen-rust/Cargo.toml.orig +44 -0
  740. data/rust-vendor/wit-bindgen-rust/LICENSE-APACHE +201 -0
  741. data/rust-vendor/wit-bindgen-rust/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
  742. data/rust-vendor/wit-bindgen-rust/LICENSE-MIT +23 -0
  743. data/rust-vendor/wit-bindgen-rust/build.rs +4 -0
  744. data/rust-vendor/wit-bindgen-rust/src/bindgen.rs +1215 -0
  745. data/rust-vendor/wit-bindgen-rust/src/interface.rs +3020 -0
  746. data/rust-vendor/wit-bindgen-rust/src/lib.rs +1880 -0
  747. data/rust-vendor/wit-bindgen-rust/tests/codegen.rs +174 -0
  748. data/rust-vendor/wit-bindgen-rust/tests/wit/path1/world.wit +3 -0
  749. data/rust-vendor/wit-bindgen-rust/tests/wit/path2/world.wit +3 -0
  750. data/rust-vendor/wit-bindgen-rust/tests/wit/path3/package.wit +3 -0
  751. data/rust-vendor/wit-bindgen-rust-macro/.cargo-checksum.json +1 -0
  752. data/rust-vendor/wit-bindgen-rust-macro/.cargo_vcs_info.json +6 -0
  753. data/rust-vendor/wit-bindgen-rust-macro/Cargo.lock +306 -0
  754. data/rust-vendor/wit-bindgen-rust-macro/Cargo.toml +62 -0
  755. data/rust-vendor/wit-bindgen-rust-macro/Cargo.toml.orig +28 -0
  756. data/rust-vendor/wit-bindgen-rust-macro/LICENSE-APACHE +201 -0
  757. data/rust-vendor/wit-bindgen-rust-macro/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
  758. data/rust-vendor/wit-bindgen-rust-macro/LICENSE-MIT +23 -0
  759. data/rust-vendor/wit-bindgen-rust-macro/build.rs +5 -0
  760. data/rust-vendor/wit-bindgen-rust-macro/src/lib.rs +606 -0
  761. data/rust-vendor/wit-component/.cargo-checksum.json +1 -0
  762. data/rust-vendor/wit-component/.cargo_vcs_info.json +6 -0
  763. data/rust-vendor/wit-component/Cargo.lock +1823 -0
  764. data/rust-vendor/wit-component/Cargo.toml +217 -0
  765. data/rust-vendor/wit-component/Cargo.toml.orig +61 -0
  766. data/rust-vendor/wit-component/README.md +251 -0
  767. data/rust-vendor/wit-component/src/dummy.rs +395 -0
  768. data/rust-vendor/wit-component/src/encoding/dedupe.rs +164 -0
  769. data/rust-vendor/wit-component/src/encoding/types.rs +510 -0
  770. data/rust-vendor/wit-component/src/encoding/wit.rs +393 -0
  771. data/rust-vendor/wit-component/src/encoding/world.rs +525 -0
  772. data/rust-vendor/wit-component/src/encoding.rs +3231 -0
  773. data/rust-vendor/wit-component/src/gc.rs +1134 -0
  774. data/rust-vendor/wit-component/src/lib.rs +178 -0
  775. data/rust-vendor/wit-component/src/linking/metadata.rs +515 -0
  776. data/rust-vendor/wit-component/src/linking.rs +1727 -0
  777. data/rust-vendor/wit-component/src/metadata.rs +447 -0
  778. data/rust-vendor/wit-component/src/printing.rs +1485 -0
  779. data/rust-vendor/wit-component/src/semver_check.rs +113 -0
  780. data/rust-vendor/wit-component/src/targets.rs +44 -0
  781. data/rust-vendor/wit-component/src/validation.rs +2679 -0
  782. data/rust-vendor/wit-component/tests/.gitignore +2 -0
  783. data/rust-vendor/wit-component/tests/components/adapt-empty-interface/adapt-old.wat +3 -0
  784. data/rust-vendor/wit-component/tests/components/adapt-empty-interface/adapt-old.wit +5 -0
  785. data/rust-vendor/wit-component/tests/components/adapt-empty-interface/component.wat +60 -0
  786. data/rust-vendor/wit-component/tests/components/adapt-empty-interface/component.wit.print +4 -0
  787. data/rust-vendor/wit-component/tests/components/adapt-empty-interface/module.wat +3 -0
  788. data/rust-vendor/wit-component/tests/components/adapt-empty-interface/module.wit +2 -0
  789. data/rust-vendor/wit-component/tests/components/adapt-export-default/adapt-old.wat +4 -0
  790. data/rust-vendor/wit-component/tests/components/adapt-export-default/adapt-old.wit +3 -0
  791. data/rust-vendor/wit-component/tests/components/adapt-export-default/component.wat +32 -0
  792. data/rust-vendor/wit-component/tests/components/adapt-export-default/component.wit.print +5 -0
  793. data/rust-vendor/wit-component/tests/components/adapt-export-default/module.wat +3 -0
  794. data/rust-vendor/wit-component/tests/components/adapt-export-default/module.wit +2 -0
  795. data/rust-vendor/wit-component/tests/components/adapt-export-namespaced/adapt-old.wat +4 -0
  796. data/rust-vendor/wit-component/tests/components/adapt-export-namespaced/adapt-old.wit +7 -0
  797. data/rust-vendor/wit-component/tests/components/adapt-export-namespaced/component.wat +42 -0
  798. data/rust-vendor/wit-component/tests/components/adapt-export-namespaced/component.wit.print +5 -0
  799. data/rust-vendor/wit-component/tests/components/adapt-export-namespaced/module.wat +3 -0
  800. data/rust-vendor/wit-component/tests/components/adapt-export-namespaced/module.wit +3 -0
  801. data/rust-vendor/wit-component/tests/components/adapt-export-reallocs/adapt-old.wat +47 -0
  802. data/rust-vendor/wit-component/tests/components/adapt-export-reallocs/adapt-old.wit +6 -0
  803. data/rust-vendor/wit-component/tests/components/adapt-export-reallocs/component.wat +131 -0
  804. data/rust-vendor/wit-component/tests/components/adapt-export-reallocs/component.wit.print +9 -0
  805. data/rust-vendor/wit-component/tests/components/adapt-export-reallocs/module.wat +8 -0
  806. data/rust-vendor/wit-component/tests/components/adapt-export-reallocs/module.wit +3 -0
  807. data/rust-vendor/wit-component/tests/components/adapt-export-save-args/adapt-old.wat +13 -0
  808. data/rust-vendor/wit-component/tests/components/adapt-export-save-args/adapt-old.wit +3 -0
  809. data/rust-vendor/wit-component/tests/components/adapt-export-save-args/component.wat +86 -0
  810. data/rust-vendor/wit-component/tests/components/adapt-export-save-args/component.wit.print +5 -0
  811. data/rust-vendor/wit-component/tests/components/adapt-export-save-args/module.wat +4 -0
  812. data/rust-vendor/wit-component/tests/components/adapt-export-save-args/module.wit +2 -0
  813. data/rust-vendor/wit-component/tests/components/adapt-export-with-post-return/adapt-old.wat +33 -0
  814. data/rust-vendor/wit-component/tests/components/adapt-export-with-post-return/adapt-old.wit +7 -0
  815. data/rust-vendor/wit-component/tests/components/adapt-export-with-post-return/component.wat +101 -0
  816. data/rust-vendor/wit-component/tests/components/adapt-export-with-post-return/component.wit.print +5 -0
  817. data/rust-vendor/wit-component/tests/components/adapt-export-with-post-return/module.wat +9 -0
  818. data/rust-vendor/wit-component/tests/components/adapt-export-with-post-return/module.wit +3 -0
  819. data/rust-vendor/wit-component/tests/components/adapt-import-only-used-in-adapter/adapt-unused.wat +7 -0
  820. data/rust-vendor/wit-component/tests/components/adapt-import-only-used-in-adapter/adapt-unused.wit +9 -0
  821. data/rust-vendor/wit-component/tests/components/adapt-import-only-used-in-adapter/component.wat +115 -0
  822. data/rust-vendor/wit-component/tests/components/adapt-import-only-used-in-adapter/component.wit.print +9 -0
  823. data/rust-vendor/wit-component/tests/components/adapt-import-only-used-in-adapter/module.wat +5 -0
  824. data/rust-vendor/wit-component/tests/components/adapt-import-only-used-in-adapter/module.wit +6 -0
  825. data/rust-vendor/wit-component/tests/components/adapt-inject-stack/adapt-old.wat +54 -0
  826. data/rust-vendor/wit-component/tests/components/adapt-inject-stack/adapt-old.wit +5 -0
  827. data/rust-vendor/wit-component/tests/components/adapt-inject-stack/component.wat +163 -0
  828. data/rust-vendor/wit-component/tests/components/adapt-inject-stack/component.wit.print +7 -0
  829. data/rust-vendor/wit-component/tests/components/adapt-inject-stack/module.wat +4 -0
  830. data/rust-vendor/wit-component/tests/components/adapt-inject-stack/module.wit +2 -0
  831. data/rust-vendor/wit-component/tests/components/adapt-inject-stack-with-adapt-realloc/adapt-old.wat +76 -0
  832. data/rust-vendor/wit-component/tests/components/adapt-inject-stack-with-adapt-realloc/adapt-old.wit +5 -0
  833. data/rust-vendor/wit-component/tests/components/adapt-inject-stack-with-adapt-realloc/component.wat +174 -0
  834. data/rust-vendor/wit-component/tests/components/adapt-inject-stack-with-adapt-realloc/component.wit.print +7 -0
  835. data/rust-vendor/wit-component/tests/components/adapt-inject-stack-with-adapt-realloc/module.wat +12 -0
  836. data/rust-vendor/wit-component/tests/components/adapt-inject-stack-with-adapt-realloc/module.wit +2 -0
  837. data/rust-vendor/wit-component/tests/components/adapt-inject-stack-with-realloc/adapt-old.wat +76 -0
  838. data/rust-vendor/wit-component/tests/components/adapt-inject-stack-with-realloc/adapt-old.wit +5 -0
  839. data/rust-vendor/wit-component/tests/components/adapt-inject-stack-with-realloc/component.wat +199 -0
  840. data/rust-vendor/wit-component/tests/components/adapt-inject-stack-with-realloc/component.wit.print +7 -0
  841. data/rust-vendor/wit-component/tests/components/adapt-inject-stack-with-realloc/module.wat +38 -0
  842. data/rust-vendor/wit-component/tests/components/adapt-inject-stack-with-realloc/module.wit +3 -0
  843. data/rust-vendor/wit-component/tests/components/adapt-inject-stack-with-realloc-no-state/adapt-old.wat +68 -0
  844. data/rust-vendor/wit-component/tests/components/adapt-inject-stack-with-realloc-no-state/adapt-old.wit +5 -0
  845. data/rust-vendor/wit-component/tests/components/adapt-inject-stack-with-realloc-no-state/component.wat +216 -0
  846. data/rust-vendor/wit-component/tests/components/adapt-inject-stack-with-realloc-no-state/component.wit.print +7 -0
  847. data/rust-vendor/wit-component/tests/components/adapt-inject-stack-with-realloc-no-state/module.wat +38 -0
  848. data/rust-vendor/wit-component/tests/components/adapt-inject-stack-with-realloc-no-state/module.wit +3 -0
  849. data/rust-vendor/wit-component/tests/components/adapt-inject-stack-with-reallocing-adapter/adapt-old.wat +62 -0
  850. data/rust-vendor/wit-component/tests/components/adapt-inject-stack-with-reallocing-adapter/adapt-old.wit +5 -0
  851. data/rust-vendor/wit-component/tests/components/adapt-inject-stack-with-reallocing-adapter/component.wat +187 -0
  852. data/rust-vendor/wit-component/tests/components/adapt-inject-stack-with-reallocing-adapter/component.wit.print +7 -0
  853. data/rust-vendor/wit-component/tests/components/adapt-inject-stack-with-reallocing-adapter/module.wat +38 -0
  854. data/rust-vendor/wit-component/tests/components/adapt-inject-stack-with-reallocing-adapter/module.wit +2 -0
  855. data/rust-vendor/wit-component/tests/components/adapt-list-return/adapt-old.wat +14 -0
  856. data/rust-vendor/wit-component/tests/components/adapt-list-return/adapt-old.wit +5 -0
  857. data/rust-vendor/wit-component/tests/components/adapt-list-return/component.wat +104 -0
  858. data/rust-vendor/wit-component/tests/components/adapt-list-return/component.wit.print +7 -0
  859. data/rust-vendor/wit-component/tests/components/adapt-list-return/module.wat +4 -0
  860. data/rust-vendor/wit-component/tests/components/adapt-list-return/module.wit +3 -0
  861. data/rust-vendor/wit-component/tests/components/adapt-memory-simple/adapt-old.wat +4 -0
  862. data/rust-vendor/wit-component/tests/components/adapt-memory-simple/adapt-old.wit +5 -0
  863. data/rust-vendor/wit-component/tests/components/adapt-memory-simple/component.wat +92 -0
  864. data/rust-vendor/wit-component/tests/components/adapt-memory-simple/component.wit.print +7 -0
  865. data/rust-vendor/wit-component/tests/components/adapt-memory-simple/module.wat +4 -0
  866. data/rust-vendor/wit-component/tests/components/adapt-memory-simple/module.wit +2 -0
  867. data/rust-vendor/wit-component/tests/components/adapt-multiple/adapt-foo.wat +10 -0
  868. data/rust-vendor/wit-component/tests/components/adapt-multiple/adapt-foo.wit +8 -0
  869. data/rust-vendor/wit-component/tests/components/adapt-multiple/component.wat +107 -0
  870. data/rust-vendor/wit-component/tests/components/adapt-multiple/component.wit.print +10 -0
  871. data/rust-vendor/wit-component/tests/components/adapt-multiple/module.wat +4 -0
  872. data/rust-vendor/wit-component/tests/components/adapt-multiple/module.wit +2 -0
  873. data/rust-vendor/wit-component/tests/components/adapt-preview1/adapt-wasi-snapshot-preview1.wat +13 -0
  874. data/rust-vendor/wit-component/tests/components/adapt-preview1/adapt-wasi-snapshot-preview1.wit +12 -0
  875. data/rust-vendor/wit-component/tests/components/adapt-preview1/component.wat +119 -0
  876. data/rust-vendor/wit-component/tests/components/adapt-preview1/component.wit.print +8 -0
  877. data/rust-vendor/wit-component/tests/components/adapt-preview1/module.wat +11 -0
  878. data/rust-vendor/wit-component/tests/components/adapt-preview1/module.wit +7 -0
  879. data/rust-vendor/wit-component/tests/components/adapt-stub-wasip2/adapt-wasip2.wat +8 -0
  880. data/rust-vendor/wit-component/tests/components/adapt-stub-wasip2/adapt-wasip2.wit +1 -0
  881. data/rust-vendor/wit-component/tests/components/adapt-stub-wasip2/component.wat +74 -0
  882. data/rust-vendor/wit-component/tests/components/adapt-stub-wasip2/component.wit.print +4 -0
  883. data/rust-vendor/wit-component/tests/components/adapt-stub-wasip2/deps/cli/environment.wit +5 -0
  884. data/rust-vendor/wit-component/tests/components/adapt-stub-wasip2/module.wat +11 -0
  885. data/rust-vendor/wit-component/tests/components/adapt-stub-wasip2/module.wit +5 -0
  886. data/rust-vendor/wit-component/tests/components/adapt-unused/adapt-old.wat +4 -0
  887. data/rust-vendor/wit-component/tests/components/adapt-unused/adapt-old.wit +5 -0
  888. data/rust-vendor/wit-component/tests/components/adapt-unused/component.wat +12 -0
  889. data/rust-vendor/wit-component/tests/components/adapt-unused/component.wit.print +4 -0
  890. data/rust-vendor/wit-component/tests/components/adapt-unused/module.wat +1 -0
  891. data/rust-vendor/wit-component/tests/components/adapt-unused/module.wit +2 -0
  892. data/rust-vendor/wit-component/tests/components/async-builtins/component.wat +259 -0
  893. data/rust-vendor/wit-component/tests/components/async-builtins/component.wit.print +6 -0
  894. data/rust-vendor/wit-component/tests/components/async-builtins/module.wat +28 -0
  895. data/rust-vendor/wit-component/tests/components/async-builtins/module.wit +10 -0
  896. data/rust-vendor/wit-component/tests/components/async-export/component.wat +91 -0
  897. data/rust-vendor/wit-component/tests/components/async-export/component.wit.print +6 -0
  898. data/rust-vendor/wit-component/tests/components/async-export/module.wat +8 -0
  899. data/rust-vendor/wit-component/tests/components/async-export/module.wit +30 -0
  900. data/rust-vendor/wit-component/tests/components/async-export-with-callback/component.wat +59 -0
  901. data/rust-vendor/wit-component/tests/components/async-export-with-callback/component.wit.print +6 -0
  902. data/rust-vendor/wit-component/tests/components/async-export-with-callback/module.wat +8 -0
  903. data/rust-vendor/wit-component/tests/components/async-export-with-callback/module.wit +10 -0
  904. data/rust-vendor/wit-component/tests/components/async-import/component.wat +125 -0
  905. data/rust-vendor/wit-component/tests/components/async-import/component.wit.print +6 -0
  906. data/rust-vendor/wit-component/tests/components/async-import/module.wat +8 -0
  907. data/rust-vendor/wit-component/tests/components/async-import/module.wit +10 -0
  908. data/rust-vendor/wit-component/tests/components/async-import-only-intrinsic/component.wat +34 -0
  909. data/rust-vendor/wit-component/tests/components/async-import-only-intrinsic/component.wit.print +5 -0
  910. data/rust-vendor/wit-component/tests/components/async-import-only-intrinsic/module.wat +4 -0
  911. data/rust-vendor/wit-component/tests/components/async-import-only-intrinsic/module.wit +17 -0
  912. data/rust-vendor/wit-component/tests/components/async-import-tricky/component.wat +39 -0
  913. data/rust-vendor/wit-component/tests/components/async-import-tricky/component.wit.print +5 -0
  914. data/rust-vendor/wit-component/tests/components/async-import-tricky/module.wat +6 -0
  915. data/rust-vendor/wit-component/tests/components/async-import-tricky/module.wit +17 -0
  916. data/rust-vendor/wit-component/tests/components/async-streams-and-futures/component.wat +649 -0
  917. data/rust-vendor/wit-component/tests/components/async-streams-and-futures/component.wit.print +9 -0
  918. data/rust-vendor/wit-component/tests/components/async-streams-and-futures/module.wat +92 -0
  919. data/rust-vendor/wit-component/tests/components/async-streams-and-futures/module.wit +12 -0
  920. data/rust-vendor/wit-component/tests/components/async-unit-builtins/component.wat +138 -0
  921. data/rust-vendor/wit-component/tests/components/async-unit-builtins/component.wit.print +4 -0
  922. data/rust-vendor/wit-component/tests/components/async-unit-builtins/module.wat +18 -0
  923. data/rust-vendor/wit-component/tests/components/async-unit-builtins/module.wit +4 -0
  924. data/rust-vendor/wit-component/tests/components/bare-funcs/component.wat +93 -0
  925. data/rust-vendor/wit-component/tests/components/bare-funcs/component.wit.print +9 -0
  926. data/rust-vendor/wit-component/tests/components/bare-funcs/module.wat +13 -0
  927. data/rust-vendor/wit-component/tests/components/bare-funcs/module.wit +7 -0
  928. data/rust-vendor/wit-component/tests/components/cm32-names/component.wat +366 -0
  929. data/rust-vendor/wit-component/tests/components/cm32-names/component.wit.print +25 -0
  930. data/rust-vendor/wit-component/tests/components/cm32-names/module.wat +32 -0
  931. data/rust-vendor/wit-component/tests/components/cm32-names/module.wit +30 -0
  932. data/rust-vendor/wit-component/tests/components/custom-page-sizes/component.wat +23 -0
  933. data/rust-vendor/wit-component/tests/components/custom-page-sizes/component.wit.print +4 -0
  934. data/rust-vendor/wit-component/tests/components/custom-page-sizes/module.wat +12 -0
  935. data/rust-vendor/wit-component/tests/components/custom-page-sizes/module.wit +3 -0
  936. data/rust-vendor/wit-component/tests/components/deduplicate-imports/adapt-wasi-snapshot-preview1.wat +10 -0
  937. data/rust-vendor/wit-component/tests/components/deduplicate-imports/adapt-wasi-snapshot-preview1.wit +10 -0
  938. data/rust-vendor/wit-component/tests/components/deduplicate-imports/component.wat +132 -0
  939. data/rust-vendor/wit-component/tests/components/deduplicate-imports/component.wit.print +9 -0
  940. data/rust-vendor/wit-component/tests/components/deduplicate-imports/module.wat +40 -0
  941. data/rust-vendor/wit-component/tests/components/deduplicate-imports/module.wit +9 -0
  942. data/rust-vendor/wit-component/tests/components/empty/component.wat +12 -0
  943. data/rust-vendor/wit-component/tests/components/empty/component.wit.print +4 -0
  944. data/rust-vendor/wit-component/tests/components/empty/module.wat +1 -0
  945. data/rust-vendor/wit-component/tests/components/empty/module.wit +2 -0
  946. data/rust-vendor/wit-component/tests/components/ensure-default-type-exports/component.wat +50 -0
  947. data/rust-vendor/wit-component/tests/components/ensure-default-type-exports/component.wit.print +7 -0
  948. data/rust-vendor/wit-component/tests/components/ensure-default-type-exports/module.wat +6 -0
  949. data/rust-vendor/wit-component/tests/components/ensure-default-type-exports/module.wit +17 -0
  950. data/rust-vendor/wit-component/tests/components/error-adapt-missing-memory/adapt-old.wat +4 -0
  951. data/rust-vendor/wit-component/tests/components/error-adapt-missing-memory/adapt-old.wit +5 -0
  952. data/rust-vendor/wit-component/tests/components/error-adapt-missing-memory/error.txt +1 -0
  953. data/rust-vendor/wit-component/tests/components/error-adapt-missing-memory/module.wat +3 -0
  954. data/rust-vendor/wit-component/tests/components/error-adapt-missing-memory/module.wit +2 -0
  955. data/rust-vendor/wit-component/tests/components/error-async-export-missing-callback/error.txt +1 -0
  956. data/rust-vendor/wit-component/tests/components/error-async-export-missing-callback/module.wat +6 -0
  957. data/rust-vendor/wit-component/tests/components/error-async-export-missing-callback/module.wit +10 -0
  958. data/rust-vendor/wit-component/tests/components/error-default-export-sig-mismatch/error.txt +1 -0
  959. data/rust-vendor/wit-component/tests/components/error-default-export-sig-mismatch/module.wat +3 -0
  960. data/rust-vendor/wit-component/tests/components/error-default-export-sig-mismatch/module.wit +5 -0
  961. data/rust-vendor/wit-component/tests/components/error-empty-module-import/error.txt +1 -0
  962. data/rust-vendor/wit-component/tests/components/error-empty-module-import/module.wat +3 -0
  963. data/rust-vendor/wit-component/tests/components/error-empty-module-import/module.wit +2 -0
  964. data/rust-vendor/wit-component/tests/components/error-export-sig-mismatch/error.txt +1 -0
  965. data/rust-vendor/wit-component/tests/components/error-export-sig-mismatch/module.wat +3 -0
  966. data/rust-vendor/wit-component/tests/components/error-export-sig-mismatch/module.wit +7 -0
  967. data/rust-vendor/wit-component/tests/components/error-import-resource-rep/error.txt +1 -0
  968. data/rust-vendor/wit-component/tests/components/error-import-resource-rep/module.wat +3 -0
  969. data/rust-vendor/wit-component/tests/components/error-import-resource-rep/module.wit +5 -0
  970. data/rust-vendor/wit-component/tests/components/error-import-resource-wrong-signature/error.txt +1 -0
  971. data/rust-vendor/wit-component/tests/components/error-import-resource-wrong-signature/module.wat +3 -0
  972. data/rust-vendor/wit-component/tests/components/error-import-resource-wrong-signature/module.wit +5 -0
  973. data/rust-vendor/wit-component/tests/components/error-import-sig-mismatch/error.txt +1 -0
  974. data/rust-vendor/wit-component/tests/components/error-import-sig-mismatch/module.wat +3 -0
  975. data/rust-vendor/wit-component/tests/components/error-import-sig-mismatch/module.wit +7 -0
  976. data/rust-vendor/wit-component/tests/components/error-invalid-module-import/error.txt +1 -0
  977. data/rust-vendor/wit-component/tests/components/error-invalid-module-import/module.wat +3 -0
  978. data/rust-vendor/wit-component/tests/components/error-invalid-module-import/module.wit +2 -0
  979. data/rust-vendor/wit-component/tests/components/error-link-duplicate-initializers/error.txt +1 -0
  980. data/rust-vendor/wit-component/tests/components/error-link-duplicate-initializers/lib-bar.wat +12 -0
  981. data/rust-vendor/wit-component/tests/components/error-link-duplicate-initializers/lib-bar.wit +3 -0
  982. data/rust-vendor/wit-component/tests/components/error-link-duplicate-initializers/lib-foo.wat +21 -0
  983. data/rust-vendor/wit-component/tests/components/error-link-duplicate-initializers/lib-foo.wit +10 -0
  984. data/rust-vendor/wit-component/tests/components/error-link-missing-needed/error.txt +2 -0
  985. data/rust-vendor/wit-component/tests/components/error-link-missing-needed/lib-foo.wat +15 -0
  986. data/rust-vendor/wit-component/tests/components/error-link-missing-needed/lib-foo.wit +10 -0
  987. data/rust-vendor/wit-component/tests/components/error-link-missing-symbols/error.txt +3 -0
  988. data/rust-vendor/wit-component/tests/components/error-link-missing-symbols/lib-foo.wat +13 -0
  989. data/rust-vendor/wit-component/tests/components/error-link-missing-symbols/lib-foo.wit +10 -0
  990. data/rust-vendor/wit-component/tests/components/error-missing-default-export/error.txt +1 -0
  991. data/rust-vendor/wit-component/tests/components/error-missing-default-export/module.wat +1 -0
  992. data/rust-vendor/wit-component/tests/components/error-missing-default-export/module.wit +4 -0
  993. data/rust-vendor/wit-component/tests/components/error-missing-export/error.txt +1 -0
  994. data/rust-vendor/wit-component/tests/components/error-missing-export/module.wat +1 -0
  995. data/rust-vendor/wit-component/tests/components/error-missing-export/module.wit +7 -0
  996. data/rust-vendor/wit-component/tests/components/error-missing-import/error.txt +1 -0
  997. data/rust-vendor/wit-component/tests/components/error-missing-import/module.wat +3 -0
  998. data/rust-vendor/wit-component/tests/components/error-missing-import/module.wit +2 -0
  999. data/rust-vendor/wit-component/tests/components/error-missing-import-func/error.txt +1 -0
  1000. data/rust-vendor/wit-component/tests/components/error-missing-import-func/module.wat +3 -0
  1001. data/rust-vendor/wit-component/tests/components/error-missing-import-func/module.wit +9 -0
  1002. data/rust-vendor/wit-component/tests/components/error-missing-module-metadata/adapt-old.wat +4 -0
  1003. data/rust-vendor/wit-component/tests/components/error-missing-module-metadata/adapt-old.wit +5 -0
  1004. data/rust-vendor/wit-component/tests/components/error-missing-module-metadata/error.txt +1 -0
  1005. data/rust-vendor/wit-component/tests/components/error-missing-module-metadata/module.wat +4 -0
  1006. data/rust-vendor/wit-component/tests/components/error-missing-module-metadata/module.wit +4 -0
  1007. data/rust-vendor/wit-component/tests/components/export-interface-using-import/component.wat +37 -0
  1008. data/rust-vendor/wit-component/tests/components/export-interface-using-import/component.wit.print +9 -0
  1009. data/rust-vendor/wit-component/tests/components/export-interface-using-import/module.wat +1 -0
  1010. data/rust-vendor/wit-component/tests/components/export-interface-using-import/module.wit +17 -0
  1011. data/rust-vendor/wit-component/tests/components/export-name-shuffling/component.wat +43 -0
  1012. data/rust-vendor/wit-component/tests/components/export-name-shuffling/component.wit.print +10 -0
  1013. data/rust-vendor/wit-component/tests/components/export-name-shuffling/module.wat +3 -0
  1014. data/rust-vendor/wit-component/tests/components/export-name-shuffling/module.wit +17 -0
  1015. data/rust-vendor/wit-component/tests/components/export-resource/component.wat +102 -0
  1016. data/rust-vendor/wit-component/tests/components/export-resource/component.wit.print +10 -0
  1017. data/rust-vendor/wit-component/tests/components/export-resource/module.wat +15 -0
  1018. data/rust-vendor/wit-component/tests/components/export-resource/module.wit +11 -0
  1019. data/rust-vendor/wit-component/tests/components/export-type-name-conflict/component.wat +46 -0
  1020. data/rust-vendor/wit-component/tests/components/export-type-name-conflict/component.wit.print +11 -0
  1021. data/rust-vendor/wit-component/tests/components/export-type-name-conflict/module.wat +5 -0
  1022. data/rust-vendor/wit-component/tests/components/export-type-name-conflict/module.wit +15 -0
  1023. data/rust-vendor/wit-component/tests/components/export-with-type-alias/component.wat +40 -0
  1024. data/rust-vendor/wit-component/tests/components/export-with-type-alias/component.wit.print +5 -0
  1025. data/rust-vendor/wit-component/tests/components/export-with-type-alias/module.wat +3 -0
  1026. data/rust-vendor/wit-component/tests/components/export-with-type-alias/module.wit +11 -0
  1027. data/rust-vendor/wit-component/tests/components/exports/component.wat +139 -0
  1028. data/rust-vendor/wit-component/tests/components/exports/component.wit.print +29 -0
  1029. data/rust-vendor/wit-component/tests/components/exports/module.wat +14 -0
  1030. data/rust-vendor/wit-component/tests/components/exports/module.wit +29 -0
  1031. data/rust-vendor/wit-component/tests/components/fallible-constructor/component.wat +73 -0
  1032. data/rust-vendor/wit-component/tests/components/fallible-constructor/component.wit.print +9 -0
  1033. data/rust-vendor/wit-component/tests/components/fallible-constructor/module.wat +5 -0
  1034. data/rust-vendor/wit-component/tests/components/fallible-constructor/module.wit +9 -0
  1035. data/rust-vendor/wit-component/tests/components/import-and-export-resource/component.wat +53 -0
  1036. data/rust-vendor/wit-component/tests/components/import-and-export-resource/component.wit.print +8 -0
  1037. data/rust-vendor/wit-component/tests/components/import-and-export-resource/module.wat +6 -0
  1038. data/rust-vendor/wit-component/tests/components/import-and-export-resource/module.wit +12 -0
  1039. data/rust-vendor/wit-component/tests/components/import-conflict/component.wat +118 -0
  1040. data/rust-vendor/wit-component/tests/components/import-conflict/component.wit.print +7 -0
  1041. data/rust-vendor/wit-component/tests/components/import-conflict/module.wat +7 -0
  1042. data/rust-vendor/wit-component/tests/components/import-conflict/module.wit +19 -0
  1043. data/rust-vendor/wit-component/tests/components/import-empty-interface/component.wat +12 -0
  1044. data/rust-vendor/wit-component/tests/components/import-empty-interface/component.wit.print +4 -0
  1045. data/rust-vendor/wit-component/tests/components/import-empty-interface/module.wat +1 -0
  1046. data/rust-vendor/wit-component/tests/components/import-empty-interface/module.wit +5 -0
  1047. data/rust-vendor/wit-component/tests/components/import-export/component.wat +124 -0
  1048. data/rust-vendor/wit-component/tests/components/import-export/component.wit.print +14 -0
  1049. data/rust-vendor/wit-component/tests/components/import-export/module.wat +10 -0
  1050. data/rust-vendor/wit-component/tests/components/import-export/module.wit +14 -0
  1051. data/rust-vendor/wit-component/tests/components/import-export-same-iface-name/component.wat +59 -0
  1052. data/rust-vendor/wit-component/tests/components/import-export-same-iface-name/component.wit.print +8 -0
  1053. data/rust-vendor/wit-component/tests/components/import-export-same-iface-name/deps/dep/foo.wit +5 -0
  1054. data/rust-vendor/wit-component/tests/components/import-export-same-iface-name/module.wat +5 -0
  1055. data/rust-vendor/wit-component/tests/components/import-export-same-iface-name/module.wit +11 -0
  1056. data/rust-vendor/wit-component/tests/components/import-in-adapter-and-main-module/adapt-old.wat +23 -0
  1057. data/rust-vendor/wit-component/tests/components/import-in-adapter-and-main-module/adapt-old.wit +9 -0
  1058. data/rust-vendor/wit-component/tests/components/import-in-adapter-and-main-module/component.wat +220 -0
  1059. data/rust-vendor/wit-component/tests/components/import-in-adapter-and-main-module/component.wit.print +16 -0
  1060. data/rust-vendor/wit-component/tests/components/import-in-adapter-and-main-module/deps/shared-dependency/doc.wit +13 -0
  1061. data/rust-vendor/wit-component/tests/components/import-in-adapter-and-main-module/deps/shared-dependency/types.wit +3 -0
  1062. data/rust-vendor/wit-component/tests/components/import-in-adapter-and-main-module/module.wat +15 -0
  1063. data/rust-vendor/wit-component/tests/components/import-in-adapter-and-main-module/module.wit +11 -0
  1064. data/rust-vendor/wit-component/tests/components/import-only-resource-static-function/component.wat +30 -0
  1065. data/rust-vendor/wit-component/tests/components/import-only-resource-static-function/component.wit.print +5 -0
  1066. data/rust-vendor/wit-component/tests/components/import-only-resource-static-function/module.wat +3 -0
  1067. data/rust-vendor/wit-component/tests/components/import-only-resource-static-function/module.wit +11 -0
  1068. data/rust-vendor/wit-component/tests/components/import-partial-export-full/component.wat +34 -0
  1069. data/rust-vendor/wit-component/tests/components/import-partial-export-full/component.wit.print +8 -0
  1070. data/rust-vendor/wit-component/tests/components/import-partial-export-full/module.wat +1 -0
  1071. data/rust-vendor/wit-component/tests/components/import-partial-export-full/module.wit +19 -0
  1072. data/rust-vendor/wit-component/tests/components/import-resource-in-interface/component.wat +41 -0
  1073. data/rust-vendor/wit-component/tests/components/import-resource-in-interface/component.wit.print +10 -0
  1074. data/rust-vendor/wit-component/tests/components/import-resource-in-interface/module.wat +5 -0
  1075. data/rust-vendor/wit-component/tests/components/import-resource-in-interface/module.wit +11 -0
  1076. data/rust-vendor/wit-component/tests/components/import-resource-simple/component.wat +33 -0
  1077. data/rust-vendor/wit-component/tests/components/import-resource-simple/component.wit.print +8 -0
  1078. data/rust-vendor/wit-component/tests/components/import-resource-simple/module.wat +5 -0
  1079. data/rust-vendor/wit-component/tests/components/import-resource-simple/module.wit +9 -0
  1080. data/rust-vendor/wit-component/tests/components/imports/component.wat +149 -0
  1081. data/rust-vendor/wit-component/tests/components/imports/component.wit.print +29 -0
  1082. data/rust-vendor/wit-component/tests/components/imports/module.wat +12 -0
  1083. data/rust-vendor/wit-component/tests/components/imports/module.wit +33 -0
  1084. data/rust-vendor/wit-component/tests/components/initialize/component.wat +38 -0
  1085. data/rust-vendor/wit-component/tests/components/initialize/component.wit.print +5 -0
  1086. data/rust-vendor/wit-component/tests/components/initialize/module.wat +6 -0
  1087. data/rust-vendor/wit-component/tests/components/initialize/module.wit +5 -0
  1088. data/rust-vendor/wit-component/tests/components/lift-options/component.wat +286 -0
  1089. data/rust-vendor/wit-component/tests/components/lift-options/component.wit.print +5 -0
  1090. data/rust-vendor/wit-component/tests/components/lift-options/module.wat +24 -0
  1091. data/rust-vendor/wit-component/tests/components/lift-options/module.wit +40 -0
  1092. data/rust-vendor/wit-component/tests/components/link/component.wat +271 -0
  1093. data/rust-vendor/wit-component/tests/components/link/component.wit.print +7 -0
  1094. data/rust-vendor/wit-component/tests/components/link/lib-bar.wat +29 -0
  1095. data/rust-vendor/wit-component/tests/components/link/lib-bar.wit +10 -0
  1096. data/rust-vendor/wit-component/tests/components/link/lib-c.wat +27 -0
  1097. data/rust-vendor/wit-component/tests/components/link/lib-c.wit +3 -0
  1098. data/rust-vendor/wit-component/tests/components/link/lib-foo.wat +55 -0
  1099. data/rust-vendor/wit-component/tests/components/link/lib-foo.wit +3 -0
  1100. data/rust-vendor/wit-component/tests/components/link/lib-unused.wat +55 -0
  1101. data/rust-vendor/wit-component/tests/components/link/lib-unused.wit +3 -0
  1102. data/rust-vendor/wit-component/tests/components/link-asyncify/component.wat +267 -0
  1103. data/rust-vendor/wit-component/tests/components/link-asyncify/component.wit.print +5 -0
  1104. data/rust-vendor/wit-component/tests/components/link-asyncify/lib-bar.wat +81 -0
  1105. data/rust-vendor/wit-component/tests/components/link-asyncify/lib-bar.wit +9 -0
  1106. data/rust-vendor/wit-component/tests/components/link-asyncify/lib-foo.wat +78 -0
  1107. data/rust-vendor/wit-component/tests/components/link-asyncify/lib-foo.wit +3 -0
  1108. data/rust-vendor/wit-component/tests/components/link-bare-funcs/component.wat +212 -0
  1109. data/rust-vendor/wit-component/tests/components/link-bare-funcs/component.wit.print +9 -0
  1110. data/rust-vendor/wit-component/tests/components/link-bare-funcs/lib-c.wat +27 -0
  1111. data/rust-vendor/wit-component/tests/components/link-bare-funcs/lib-c.wit +3 -0
  1112. data/rust-vendor/wit-component/tests/components/link-bare-funcs/lib-foo.wat +18 -0
  1113. data/rust-vendor/wit-component/tests/components/link-bare-funcs/lib-foo.wit +7 -0
  1114. data/rust-vendor/wit-component/tests/components/link-circular/component.wat +133 -0
  1115. data/rust-vendor/wit-component/tests/components/link-circular/component.wit.print +7 -0
  1116. data/rust-vendor/wit-component/tests/components/link-circular/lib-bar.wat +12 -0
  1117. data/rust-vendor/wit-component/tests/components/link-circular/lib-bar.wit +3 -0
  1118. data/rust-vendor/wit-component/tests/components/link-circular/lib-foo.wat +15 -0
  1119. data/rust-vendor/wit-component/tests/components/link-circular/lib-foo.wit +10 -0
  1120. data/rust-vendor/wit-component/tests/components/link-dl-openable/component.wat +108 -0
  1121. data/rust-vendor/wit-component/tests/components/link-dl-openable/component.wit.print +7 -0
  1122. data/rust-vendor/wit-component/tests/components/link-dl-openable/dlopen-lib-foo.wat +15 -0
  1123. data/rust-vendor/wit-component/tests/components/link-dl-openable/dlopen-lib-foo.wit +10 -0
  1124. data/rust-vendor/wit-component/tests/components/link-dl-openable-builtin-libdl/component.wat +657 -0
  1125. data/rust-vendor/wit-component/tests/components/link-dl-openable-builtin-libdl/component.wit.print +7 -0
  1126. data/rust-vendor/wit-component/tests/components/link-dl-openable-builtin-libdl/dlopen-lib-foo.wat +17 -0
  1127. data/rust-vendor/wit-component/tests/components/link-dl-openable-builtin-libdl/dlopen-lib-foo.wit +10 -0
  1128. data/rust-vendor/wit-component/tests/components/link-dl-openable-builtin-libdl/lib-c.wat +30 -0
  1129. data/rust-vendor/wit-component/tests/components/link-dl-openable-builtin-libdl/lib-c.wit +3 -0
  1130. data/rust-vendor/wit-component/tests/components/link-dl-openable-builtin-libdl/stub-missing-functions +0 -0
  1131. data/rust-vendor/wit-component/tests/components/link-dl-openable-builtin-libdl/use-built-in-libdl +0 -0
  1132. data/rust-vendor/wit-component/tests/components/link-dl-openable-builtin-libdl-with-unused/component.wat +654 -0
  1133. data/rust-vendor/wit-component/tests/components/link-dl-openable-builtin-libdl-with-unused/component.wit.print +7 -0
  1134. data/rust-vendor/wit-component/tests/components/link-dl-openable-builtin-libdl-with-unused/dlopen-lib-foo.wat +19 -0
  1135. data/rust-vendor/wit-component/tests/components/link-dl-openable-builtin-libdl-with-unused/dlopen-lib-foo.wit +10 -0
  1136. data/rust-vendor/wit-component/tests/components/link-dl-openable-builtin-libdl-with-unused/lib-c.wat +39 -0
  1137. data/rust-vendor/wit-component/tests/components/link-dl-openable-builtin-libdl-with-unused/lib-c.wit +3 -0
  1138. data/rust-vendor/wit-component/tests/components/link-dl-openable-builtin-libdl-with-unused/lib-unused.wat +55 -0
  1139. data/rust-vendor/wit-component/tests/components/link-dl-openable-builtin-libdl-with-unused/lib-unused.wit +3 -0
  1140. data/rust-vendor/wit-component/tests/components/link-dl-openable-builtin-libdl-with-unused/use-built-in-libdl +0 -0
  1141. data/rust-vendor/wit-component/tests/components/link-duplicate-symbols/component.wat +135 -0
  1142. data/rust-vendor/wit-component/tests/components/link-duplicate-symbols/component.wit.print +7 -0
  1143. data/rust-vendor/wit-component/tests/components/link-duplicate-symbols/lib-bar.wat +13 -0
  1144. data/rust-vendor/wit-component/tests/components/link-duplicate-symbols/lib-bar.wit +3 -0
  1145. data/rust-vendor/wit-component/tests/components/link-duplicate-symbols/lib-foo.wat +15 -0
  1146. data/rust-vendor/wit-component/tests/components/link-duplicate-symbols/lib-foo.wit +10 -0
  1147. data/rust-vendor/wit-component/tests/components/link-got-func/component.wat +125 -0
  1148. data/rust-vendor/wit-component/tests/components/link-got-func/component.wit.print +7 -0
  1149. data/rust-vendor/wit-component/tests/components/link-got-func/lib-bar.wat +10 -0
  1150. data/rust-vendor/wit-component/tests/components/link-got-func/lib-bar.wit +3 -0
  1151. data/rust-vendor/wit-component/tests/components/link-got-func/lib-foo.wat +10 -0
  1152. data/rust-vendor/wit-component/tests/components/link-got-func/lib-foo.wit +10 -0
  1153. data/rust-vendor/wit-component/tests/components/link-initialize/component.wat +271 -0
  1154. data/rust-vendor/wit-component/tests/components/link-initialize/component.wit.print +7 -0
  1155. data/rust-vendor/wit-component/tests/components/link-initialize/lib-bar.wat +29 -0
  1156. data/rust-vendor/wit-component/tests/components/link-initialize/lib-bar.wit +10 -0
  1157. data/rust-vendor/wit-component/tests/components/link-initialize/lib-c.wat +27 -0
  1158. data/rust-vendor/wit-component/tests/components/link-initialize/lib-c.wit +3 -0
  1159. data/rust-vendor/wit-component/tests/components/link-initialize/lib-foo.wat +55 -0
  1160. data/rust-vendor/wit-component/tests/components/link-initialize/lib-foo.wit +3 -0
  1161. data/rust-vendor/wit-component/tests/components/link-lib-with-async-export/component.wat +148 -0
  1162. data/rust-vendor/wit-component/tests/components/link-lib-with-async-export/component.wit.print +19 -0
  1163. data/rust-vendor/wit-component/tests/components/link-lib-with-async-export/lib-c.wat +4 -0
  1164. data/rust-vendor/wit-component/tests/components/link-lib-with-async-export/lib-c.wit +3 -0
  1165. data/rust-vendor/wit-component/tests/components/link-lib-with-async-export/lib-foo.wat +12 -0
  1166. data/rust-vendor/wit-component/tests/components/link-lib-with-async-export/lib-foo.wit +16 -0
  1167. data/rust-vendor/wit-component/tests/components/link-resources/component.wat +150 -0
  1168. data/rust-vendor/wit-component/tests/components/link-resources/component.wit.print +6 -0
  1169. data/rust-vendor/wit-component/tests/components/link-resources/lib-bar.wat +15 -0
  1170. data/rust-vendor/wit-component/tests/components/link-resources/lib-bar.wit +13 -0
  1171. data/rust-vendor/wit-component/tests/components/link-resources/lib-foo.wat +17 -0
  1172. data/rust-vendor/wit-component/tests/components/link-resources/lib-foo.wit +13 -0
  1173. data/rust-vendor/wit-component/tests/components/link-stack-high-and-low/component.wat +146 -0
  1174. data/rust-vendor/wit-component/tests/components/link-stack-high-and-low/component.wit.print +5 -0
  1175. data/rust-vendor/wit-component/tests/components/link-stack-high-and-low/lib-bar.wat +19 -0
  1176. data/rust-vendor/wit-component/tests/components/link-stack-high-and-low/lib-bar.wit +9 -0
  1177. data/rust-vendor/wit-component/tests/components/link-stack-high-and-low/lib-foo.wat +17 -0
  1178. data/rust-vendor/wit-component/tests/components/link-stack-high-and-low/lib-foo.wit +3 -0
  1179. data/rust-vendor/wit-component/tests/components/link-stub-wasip2/adapt-wasip2.wat +8 -0
  1180. data/rust-vendor/wit-component/tests/components/link-stub-wasip2/adapt-wasip2.wit +1 -0
  1181. data/rust-vendor/wit-component/tests/components/link-stub-wasip2/component.wat +330 -0
  1182. data/rust-vendor/wit-component/tests/components/link-stub-wasip2/component.wit.print +7 -0
  1183. data/rust-vendor/wit-component/tests/components/link-stub-wasip2/deps/cli/environment.wit +5 -0
  1184. data/rust-vendor/wit-component/tests/components/link-stub-wasip2/lib-bar.wat +29 -0
  1185. data/rust-vendor/wit-component/tests/components/link-stub-wasip2/lib-bar.wit +10 -0
  1186. data/rust-vendor/wit-component/tests/components/link-stub-wasip2/lib-c.wat +29 -0
  1187. data/rust-vendor/wit-component/tests/components/link-stub-wasip2/lib-c.wit +5 -0
  1188. data/rust-vendor/wit-component/tests/components/link-stub-wasip2/lib-foo.wat +55 -0
  1189. data/rust-vendor/wit-component/tests/components/link-stub-wasip2/lib-foo.wit +3 -0
  1190. data/rust-vendor/wit-component/tests/components/link-stub-wasip2/lib-unused.wat +55 -0
  1191. data/rust-vendor/wit-component/tests/components/link-stub-wasip2/lib-unused.wit +3 -0
  1192. data/rust-vendor/wit-component/tests/components/link-stubs/component.wat +118 -0
  1193. data/rust-vendor/wit-component/tests/components/link-stubs/component.wit.print +7 -0
  1194. data/rust-vendor/wit-component/tests/components/link-stubs/lib-foo.wat +13 -0
  1195. data/rust-vendor/wit-component/tests/components/link-stubs/lib-foo.wit +10 -0
  1196. data/rust-vendor/wit-component/tests/components/link-stubs/stub-missing-functions +0 -0
  1197. data/rust-vendor/wit-component/tests/components/link-tag/component.wat +123 -0
  1198. data/rust-vendor/wit-component/tests/components/link-tag/component.wit.print +5 -0
  1199. data/rust-vendor/wit-component/tests/components/link-tag/lib-bar.wat +6 -0
  1200. data/rust-vendor/wit-component/tests/components/link-tag/lib-bar.wit +3 -0
  1201. data/rust-vendor/wit-component/tests/components/link-tag/lib-foo.wat +7 -0
  1202. data/rust-vendor/wit-component/tests/components/link-tag/lib-foo.wit +5 -0
  1203. data/rust-vendor/wit-component/tests/components/link-weak-cabi-realloc/component.wat +99 -0
  1204. data/rust-vendor/wit-component/tests/components/link-weak-cabi-realloc/component.wit.print +5 -0
  1205. data/rust-vendor/wit-component/tests/components/link-weak-cabi-realloc/lib-foo.wat +14 -0
  1206. data/rust-vendor/wit-component/tests/components/link-weak-cabi-realloc/lib-foo.wit +9 -0
  1207. data/rust-vendor/wit-component/tests/components/link-weak-import/component.wat +120 -0
  1208. data/rust-vendor/wit-component/tests/components/link-weak-import/component.wit.print +7 -0
  1209. data/rust-vendor/wit-component/tests/components/link-weak-import/lib-foo.wat +15 -0
  1210. data/rust-vendor/wit-component/tests/components/link-weak-import/lib-foo.wit +10 -0
  1211. data/rust-vendor/wit-component/tests/components/live-exports-dead-imports/component.wat +38 -0
  1212. data/rust-vendor/wit-component/tests/components/live-exports-dead-imports/component.wit.print +5 -0
  1213. data/rust-vendor/wit-component/tests/components/live-exports-dead-imports/module.wat +4 -0
  1214. data/rust-vendor/wit-component/tests/components/live-exports-dead-imports/module.wit +12 -0
  1215. data/rust-vendor/wit-component/tests/components/lower-options/component.wat +281 -0
  1216. data/rust-vendor/wit-component/tests/components/lower-options/component.wit.print +5 -0
  1217. data/rust-vendor/wit-component/tests/components/lower-options/module.wat +20 -0
  1218. data/rust-vendor/wit-component/tests/components/lower-options/module.wit +40 -0
  1219. data/rust-vendor/wit-component/tests/components/many-same-names/component.wat +48 -0
  1220. data/rust-vendor/wit-component/tests/components/many-same-names/component.wit.print +10 -0
  1221. data/rust-vendor/wit-component/tests/components/many-same-names/module.wat +3 -0
  1222. data/rust-vendor/wit-component/tests/components/many-same-names/module.wit +21 -0
  1223. data/rust-vendor/wit-component/tests/components/merge-import-versions/component.wat +125 -0
  1224. data/rust-vendor/wit-component/tests/components/merge-import-versions/component.wit.print +5 -0
  1225. data/rust-vendor/wit-component/tests/components/merge-import-versions/module.wat +15 -0
  1226. data/rust-vendor/wit-component/tests/components/merge-import-versions/module.wit +30 -0
  1227. data/rust-vendor/wit-component/tests/components/merge-import-versions-with-adapter/adapt-old.wat +10 -0
  1228. data/rust-vendor/wit-component/tests/components/merge-import-versions-with-adapter/adapt-old.wit +19 -0
  1229. data/rust-vendor/wit-component/tests/components/merge-import-versions-with-adapter/component.wat +104 -0
  1230. data/rust-vendor/wit-component/tests/components/merge-import-versions-with-adapter/component.wit.print +5 -0
  1231. data/rust-vendor/wit-component/tests/components/merge-import-versions-with-adapter/module.wat +9 -0
  1232. data/rust-vendor/wit-component/tests/components/merge-import-versions-with-adapter/module.wit +14 -0
  1233. data/rust-vendor/wit-component/tests/components/multi-package/baz/qux/component.wat +90 -0
  1234. data/rust-vendor/wit-component/tests/components/multi-package/baz/qux/component.wit.print +13 -0
  1235. data/rust-vendor/wit-component/tests/components/multi-package/baz/qux/module.wat +7 -0
  1236. data/rust-vendor/wit-component/tests/components/multi-package/component.wat +44 -0
  1237. data/rust-vendor/wit-component/tests/components/multi-package/component.wit.print +4 -0
  1238. data/rust-vendor/wit-component/tests/components/multi-package/foo/bar/component.wat +82 -0
  1239. data/rust-vendor/wit-component/tests/components/multi-package/foo/bar/component.wit.print +13 -0
  1240. data/rust-vendor/wit-component/tests/components/multi-package/foo/bar/module.wat +6 -0
  1241. data/rust-vendor/wit-component/tests/components/multi-package/module.wit +25 -0
  1242. data/rust-vendor/wit-component/tests/components/no-realloc-required/component.wat +67 -0
  1243. data/rust-vendor/wit-component/tests/components/no-realloc-required/component.wit.print +7 -0
  1244. data/rust-vendor/wit-component/tests/components/no-realloc-required/module.wat +4 -0
  1245. data/rust-vendor/wit-component/tests/components/no-realloc-required/module.wit +7 -0
  1246. data/rust-vendor/wit-component/tests/components/post-return/component.wat +36 -0
  1247. data/rust-vendor/wit-component/tests/components/post-return/component.wit.print +5 -0
  1248. data/rust-vendor/wit-component/tests/components/post-return/module.wat +6 -0
  1249. data/rust-vendor/wit-component/tests/components/post-return/module.wit +5 -0
  1250. data/rust-vendor/wit-component/tests/components/rename-import-interface/component.wat +29 -0
  1251. data/rust-vendor/wit-component/tests/components/rename-import-interface/component.wit.print +5 -0
  1252. data/rust-vendor/wit-component/tests/components/rename-import-interface/module.wat +3 -0
  1253. data/rust-vendor/wit-component/tests/components/rename-import-interface/module.wit +9 -0
  1254. data/rust-vendor/wit-component/tests/components/rename-interface/component.wat +39 -0
  1255. data/rust-vendor/wit-component/tests/components/rename-interface/component.wit.print +10 -0
  1256. data/rust-vendor/wit-component/tests/components/rename-interface/module.wat +3 -0
  1257. data/rust-vendor/wit-component/tests/components/rename-interface/module.wit +18 -0
  1258. data/rust-vendor/wit-component/tests/components/resource-intrinsics-with-just-import/component.wat +28 -0
  1259. data/rust-vendor/wit-component/tests/components/resource-intrinsics-with-just-import/component.wit.print +7 -0
  1260. data/rust-vendor/wit-component/tests/components/resource-intrinsics-with-just-import/module.wat +3 -0
  1261. data/rust-vendor/wit-component/tests/components/resource-intrinsics-with-just-import/module.wit +7 -0
  1262. data/rust-vendor/wit-component/tests/components/resource-used-through-import/component.wat +57 -0
  1263. data/rust-vendor/wit-component/tests/components/resource-used-through-import/component.wit.print +11 -0
  1264. data/rust-vendor/wit-component/tests/components/resource-used-through-import/module.wat +6 -0
  1265. data/rust-vendor/wit-component/tests/components/resource-used-through-import/module.wit +13 -0
  1266. data/rust-vendor/wit-component/tests/components/resource-using-export/component.wat +64 -0
  1267. data/rust-vendor/wit-component/tests/components/resource-using-export/component.wit.print +10 -0
  1268. data/rust-vendor/wit-component/tests/components/resource-using-export/module.wat +6 -0
  1269. data/rust-vendor/wit-component/tests/components/resource-using-export/module.wit +16 -0
  1270. data/rust-vendor/wit-component/tests/components/simple/component.wat +64 -0
  1271. data/rust-vendor/wit-component/tests/components/simple/component.wit.print +7 -0
  1272. data/rust-vendor/wit-component/tests/components/simple/module.wat +10 -0
  1273. data/rust-vendor/wit-component/tests/components/simple/module.wit +7 -0
  1274. data/rust-vendor/wit-component/tests/components/threading/component.wat +163 -0
  1275. data/rust-vendor/wit-component/tests/components/threading/component.wit.print +6 -0
  1276. data/rust-vendor/wit-component/tests/components/threading/module.wat +22 -0
  1277. data/rust-vendor/wit-component/tests/components/threading/module.wit +10 -0
  1278. data/rust-vendor/wit-component/tests/components/tricky-order/component.wat +44 -0
  1279. data/rust-vendor/wit-component/tests/components/tricky-order/component.wit.print +11 -0
  1280. data/rust-vendor/wit-component/tests/components/tricky-order/module.wat +1 -0
  1281. data/rust-vendor/wit-component/tests/components/tricky-order/module.wit +20 -0
  1282. data/rust-vendor/wit-component/tests/components/tricky-resources/component.wat +75 -0
  1283. data/rust-vendor/wit-component/tests/components/tricky-resources/component.wit.print +11 -0
  1284. data/rust-vendor/wit-component/tests/components/tricky-resources/module.wat +7 -0
  1285. data/rust-vendor/wit-component/tests/components/tricky-resources/module.wit +19 -0
  1286. data/rust-vendor/wit-component/tests/components/tricky-resources2/component.wat +50 -0
  1287. data/rust-vendor/wit-component/tests/components/tricky-resources2/component.wit.print +10 -0
  1288. data/rust-vendor/wit-component/tests/components/tricky-resources2/module.wat +4 -0
  1289. data/rust-vendor/wit-component/tests/components/tricky-resources2/module.wit +14 -0
  1290. data/rust-vendor/wit-component/tests/components/tricky-resources3/component.wat +44 -0
  1291. data/rust-vendor/wit-component/tests/components/tricky-resources3/component.wit.print +9 -0
  1292. data/rust-vendor/wit-component/tests/components/tricky-resources3/module.wat +1 -0
  1293. data/rust-vendor/wit-component/tests/components/tricky-resources3/module.wit +17 -0
  1294. data/rust-vendor/wit-component/tests/components/tricky-resources4/component.wat +64 -0
  1295. data/rust-vendor/wit-component/tests/components/tricky-resources4/component.wit.print +8 -0
  1296. data/rust-vendor/wit-component/tests/components/tricky-resources4/module.wat +6 -0
  1297. data/rust-vendor/wit-component/tests/components/tricky-resources4/module.wit +16 -0
  1298. data/rust-vendor/wit-component/tests/components/unused-import/component.wat +29 -0
  1299. data/rust-vendor/wit-component/tests/components/unused-import/component.wit.print +5 -0
  1300. data/rust-vendor/wit-component/tests/components/unused-import/module.wat +3 -0
  1301. data/rust-vendor/wit-component/tests/components/unused-import/module.wit +12 -0
  1302. data/rust-vendor/wit-component/tests/components/worlds-with-type-renamings/component.wat +67 -0
  1303. data/rust-vendor/wit-component/tests/components/worlds-with-type-renamings/component.wit.print +8 -0
  1304. data/rust-vendor/wit-component/tests/components/worlds-with-type-renamings/module.wat +12 -0
  1305. data/rust-vendor/wit-component/tests/components/worlds-with-type-renamings/module.wit +17 -0
  1306. data/rust-vendor/wit-component/tests/components/worlds-with-types/component.wat +25 -0
  1307. data/rust-vendor/wit-component/tests/components/worlds-with-types/component.wit.print +11 -0
  1308. data/rust-vendor/wit-component/tests/components/worlds-with-types/module.wat +3 -0
  1309. data/rust-vendor/wit-component/tests/components/worlds-with-types/module.wit +10 -0
  1310. data/rust-vendor/wit-component/tests/components.rs +291 -0
  1311. data/rust-vendor/wit-component/tests/interfaces/console.wat +18 -0
  1312. data/rust-vendor/wit-component/tests/interfaces/console.wit +5 -0
  1313. data/rust-vendor/wit-component/tests/interfaces/console.wit.print +6 -0
  1314. data/rust-vendor/wit-component/tests/interfaces/diamond-disambiguate/foo.wit.print +20 -0
  1315. data/rust-vendor/wit-component/tests/interfaces/diamond-disambiguate/join.wit +10 -0
  1316. data/rust-vendor/wit-component/tests/interfaces/diamond-disambiguate/shared1.wit +3 -0
  1317. data/rust-vendor/wit-component/tests/interfaces/diamond-disambiguate/shared2.wit +3 -0
  1318. data/rust-vendor/wit-component/tests/interfaces/diamond-disambiguate.wat +70 -0
  1319. data/rust-vendor/wit-component/tests/interfaces/diamond.wat +107 -0
  1320. data/rust-vendor/wit-component/tests/interfaces/diamond.wit +31 -0
  1321. data/rust-vendor/wit-component/tests/interfaces/diamond.wit.print +34 -0
  1322. data/rust-vendor/wit-component/tests/interfaces/doc-comments/foo.wit +79 -0
  1323. data/rust-vendor/wit-component/tests/interfaces/doc-comments/foo.wit.print +78 -0
  1324. data/rust-vendor/wit-component/tests/interfaces/doc-comments.wat +73 -0
  1325. data/rust-vendor/wit-component/tests/interfaces/empty.wat +50 -0
  1326. data/rust-vendor/wit-component/tests/interfaces/empty.wit +12 -0
  1327. data/rust-vendor/wit-component/tests/interfaces/empty.wit.print +16 -0
  1328. data/rust-vendor/wit-component/tests/interfaces/export-other-packages-interface/deps/the-dep/the-doc.wit +9 -0
  1329. data/rust-vendor/wit-component/tests/interfaces/export-other-packages-interface/foo.wit +5 -0
  1330. data/rust-vendor/wit-component/tests/interfaces/export-other-packages-interface/foo.wit.print +5 -0
  1331. data/rust-vendor/wit-component/tests/interfaces/export-other-packages-interface.wat +23 -0
  1332. data/rust-vendor/wit-component/tests/interfaces/exports.wat +39 -0
  1333. data/rust-vendor/wit-component/tests/interfaces/exports.wit +13 -0
  1334. data/rust-vendor/wit-component/tests/interfaces/exports.wit.print +13 -0
  1335. data/rust-vendor/wit-component/tests/interfaces/flags.wat +79 -0
  1336. data/rust-vendor/wit-component/tests/interfaces/flags.wit +100 -0
  1337. data/rust-vendor/wit-component/tests/interfaces/flags.wit.print +100 -0
  1338. data/rust-vendor/wit-component/tests/interfaces/floats.wat +47 -0
  1339. data/rust-vendor/wit-component/tests/interfaces/floats.wit +12 -0
  1340. data/rust-vendor/wit-component/tests/interfaces/floats.wit.print +15 -0
  1341. data/rust-vendor/wit-component/tests/interfaces/foreign-use-chain/deps/bar/bar.wit +9 -0
  1342. data/rust-vendor/wit-component/tests/interfaces/foreign-use-chain/foo.wit +5 -0
  1343. data/rust-vendor/wit-component/tests/interfaces/foreign-use-chain/foo.wit.print +6 -0
  1344. data/rust-vendor/wit-component/tests/interfaces/foreign-use-chain.wat +31 -0
  1345. data/rust-vendor/wit-component/tests/interfaces/import-and-export.wat +54 -0
  1346. data/rust-vendor/wit-component/tests/interfaces/import-and-export.wit +14 -0
  1347. data/rust-vendor/wit-component/tests/interfaces/import-and-export.wit.print +15 -0
  1348. data/rust-vendor/wit-component/tests/interfaces/integers.wat +107 -0
  1349. data/rust-vendor/wit-component/tests/interfaces/integers.wit +27 -0
  1350. data/rust-vendor/wit-component/tests/interfaces/integers.wit.print +45 -0
  1351. data/rust-vendor/wit-component/tests/interfaces/lists.wat +211 -0
  1352. data/rust-vendor/wit-component/tests/interfaces/lists.wit +96 -0
  1353. data/rust-vendor/wit-component/tests/interfaces/lists.wit.print +96 -0
  1354. data/rust-vendor/wit-component/tests/interfaces/maps.wat +186 -0
  1355. data/rust-vendor/wit-component/tests/interfaces/maps.wit +38 -0
  1356. data/rust-vendor/wit-component/tests/interfaces/maps.wit.print +57 -0
  1357. data/rust-vendor/wit-component/tests/interfaces/multi-doc/a.wit +9 -0
  1358. data/rust-vendor/wit-component/tests/interfaces/multi-doc/b.wit +9 -0
  1359. data/rust-vendor/wit-component/tests/interfaces/multi-doc/foo.wit.print +20 -0
  1360. data/rust-vendor/wit-component/tests/interfaces/multi-doc.wat +78 -0
  1361. data/rust-vendor/wit-component/tests/interfaces/multiple-use.wat +67 -0
  1362. data/rust-vendor/wit-component/tests/interfaces/multiple-use.wit +16 -0
  1363. data/rust-vendor/wit-component/tests/interfaces/multiple-use.wit.print +18 -0
  1364. data/rust-vendor/wit-component/tests/interfaces/pkg-use-chain/chain.wit.print +18 -0
  1365. data/rust-vendor/wit-component/tests/interfaces/pkg-use-chain/def.wit +13 -0
  1366. data/rust-vendor/wit-component/tests/interfaces/pkg-use-chain/the-use.wit +5 -0
  1367. data/rust-vendor/wit-component/tests/interfaces/pkg-use-chain.wat +70 -0
  1368. data/rust-vendor/wit-component/tests/interfaces/pkg-use-chain2/bar.wit +13 -0
  1369. data/rust-vendor/wit-component/tests/interfaces/pkg-use-chain2/foo.wit +5 -0
  1370. data/rust-vendor/wit-component/tests/interfaces/pkg-use-chain2/foo.wit.print +20 -0
  1371. data/rust-vendor/wit-component/tests/interfaces/pkg-use-chain2.wat +70 -0
  1372. data/rust-vendor/wit-component/tests/interfaces/preserve-dep-type-order/deps/dep/foo.wit +11 -0
  1373. data/rust-vendor/wit-component/tests/interfaces/preserve-dep-type-order/foo.wit +9 -0
  1374. data/rust-vendor/wit-component/tests/interfaces/preserve-dep-type-order/foo.wit.print +9 -0
  1375. data/rust-vendor/wit-component/tests/interfaces/preserve-dep-type-order.wat +47 -0
  1376. data/rust-vendor/wit-component/tests/interfaces/preserve-foreign-reexport/deps/my-dep/my-doc.wit +8 -0
  1377. data/rust-vendor/wit-component/tests/interfaces/preserve-foreign-reexport/foo.wit +5 -0
  1378. data/rust-vendor/wit-component/tests/interfaces/preserve-foreign-reexport/foo.wit.print +5 -0
  1379. data/rust-vendor/wit-component/tests/interfaces/preserve-foreign-reexport.wat +24 -0
  1380. data/rust-vendor/wit-component/tests/interfaces/print-keyword.wat +21 -0
  1381. data/rust-vendor/wit-component/tests/interfaces/print-keyword.wit +10 -0
  1382. data/rust-vendor/wit-component/tests/interfaces/print-keyword.wit.print +12 -0
  1383. data/rust-vendor/wit-component/tests/interfaces/records.wat +141 -0
  1384. data/rust-vendor/wit-component/tests/interfaces/records.wit +63 -0
  1385. data/rust-vendor/wit-component/tests/interfaces/records.wit.print +64 -0
  1386. data/rust-vendor/wit-component/tests/interfaces/reference-out-of-order.wat +63 -0
  1387. data/rust-vendor/wit-component/tests/interfaces/reference-out-of-order.wit +28 -0
  1388. data/rust-vendor/wit-component/tests/interfaces/reference-out-of-order.wit.print +31 -0
  1389. data/rust-vendor/wit-component/tests/interfaces/resources.wat +192 -0
  1390. data/rust-vendor/wit-component/tests/interfaces/resources.wit +80 -0
  1391. data/rust-vendor/wit-component/tests/interfaces/resources.wit.print +81 -0
  1392. data/rust-vendor/wit-component/tests/interfaces/simple-deps/deps/some-dep/types.wit +5 -0
  1393. data/rust-vendor/wit-component/tests/interfaces/simple-deps/foo.wit +4 -0
  1394. data/rust-vendor/wit-component/tests/interfaces/simple-deps/foo.wit.print +6 -0
  1395. data/rust-vendor/wit-component/tests/interfaces/simple-deps.wat +26 -0
  1396. data/rust-vendor/wit-component/tests/interfaces/simple-multi/bar.wit +1 -0
  1397. data/rust-vendor/wit-component/tests/interfaces/simple-multi/foo.wit +3 -0
  1398. data/rust-vendor/wit-component/tests/interfaces/simple-multi/foo.wit.print +8 -0
  1399. data/rust-vendor/wit-component/tests/interfaces/simple-multi.wat +24 -0
  1400. data/rust-vendor/wit-component/tests/interfaces/simple-use.wat +40 -0
  1401. data/rust-vendor/wit-component/tests/interfaces/simple-use.wit +13 -0
  1402. data/rust-vendor/wit-component/tests/interfaces/simple-use.wit.print +15 -0
  1403. data/rust-vendor/wit-component/tests/interfaces/simple-world.wat +35 -0
  1404. data/rust-vendor/wit-component/tests/interfaces/simple-world.wit +9 -0
  1405. data/rust-vendor/wit-component/tests/interfaces/simple-world.wit.print +9 -0
  1406. data/rust-vendor/wit-component/tests/interfaces/single-named-result.wat +18 -0
  1407. data/rust-vendor/wit-component/tests/interfaces/type-alias.wat +51 -0
  1408. data/rust-vendor/wit-component/tests/interfaces/type-alias.wit +13 -0
  1409. data/rust-vendor/wit-component/tests/interfaces/type-alias.wit.print +15 -0
  1410. data/rust-vendor/wit-component/tests/interfaces/type-alias2.wat +41 -0
  1411. data/rust-vendor/wit-component/tests/interfaces/type-alias2.wit +15 -0
  1412. data/rust-vendor/wit-component/tests/interfaces/type-alias2.wit.print +15 -0
  1413. data/rust-vendor/wit-component/tests/interfaces/upstream-deps-same-name/deps/a/the-name.wit +4 -0
  1414. data/rust-vendor/wit-component/tests/interfaces/upstream-deps-same-name/deps/b/the-name.wit +4 -0
  1415. data/rust-vendor/wit-component/tests/interfaces/upstream-deps-same-name/foo.wit +6 -0
  1416. data/rust-vendor/wit-component/tests/interfaces/upstream-deps-same-name/foo.wit.print +7 -0
  1417. data/rust-vendor/wit-component/tests/interfaces/upstream-deps-same-name.wat +36 -0
  1418. data/rust-vendor/wit-component/tests/interfaces/use-chain.wat +72 -0
  1419. data/rust-vendor/wit-component/tests/interfaces/use-chain.wit +15 -0
  1420. data/rust-vendor/wit-component/tests/interfaces/use-chain.wit.print +18 -0
  1421. data/rust-vendor/wit-component/tests/interfaces/use-for-type.wat +49 -0
  1422. data/rust-vendor/wit-component/tests/interfaces/use-for-type.wit +16 -0
  1423. data/rust-vendor/wit-component/tests/interfaces/use-for-type.wit.print +17 -0
  1424. data/rust-vendor/wit-component/tests/interfaces/variants.wat +197 -0
  1425. data/rust-vendor/wit-component/tests/interfaces/variants.wit +78 -0
  1426. data/rust-vendor/wit-component/tests/interfaces/variants.wit.print +95 -0
  1427. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/cli/command.wit +7 -0
  1428. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/cli/environment.wit +18 -0
  1429. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/cli/exit.wit +4 -0
  1430. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/cli/imports.wit +20 -0
  1431. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/cli/run.wit +4 -0
  1432. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/cli/stdio.wit +17 -0
  1433. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/cli/terminal.wit +47 -0
  1434. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/clocks/monotonic-clock.wit +45 -0
  1435. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/clocks/wall-clock.wit +42 -0
  1436. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/clocks/world.wit +6 -0
  1437. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/filesystem/preopens.wit +8 -0
  1438. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/filesystem/types.wit +634 -0
  1439. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/filesystem/world.wit +6 -0
  1440. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/io/error.wit +34 -0
  1441. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/io/poll.wit +41 -0
  1442. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/io/streams.wit +251 -0
  1443. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/io/world.wit +6 -0
  1444. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/random/insecure-seed.wit +25 -0
  1445. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/random/insecure.wit +22 -0
  1446. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/random/random.wit +26 -0
  1447. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/random/world.wit +7 -0
  1448. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/sockets/instance-network.wit +9 -0
  1449. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/sockets/ip-name-lookup.wit +51 -0
  1450. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/sockets/network.wit +147 -0
  1451. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/sockets/tcp-create-socket.wit +26 -0
  1452. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/sockets/tcp.wit +321 -0
  1453. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/sockets/udp-create-socket.wit +26 -0
  1454. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/sockets/udp.wit +277 -0
  1455. data/rust-vendor/wit-component/tests/interfaces/wasi-http/deps/sockets/world.wit +11 -0
  1456. data/rust-vendor/wit-component/tests/interfaces/wasi-http/handler.wit +43 -0
  1457. data/rust-vendor/wit-component/tests/interfaces/wasi-http/http.wit.print +571 -0
  1458. data/rust-vendor/wit-component/tests/interfaces/wasi-http/proxy.wit +32 -0
  1459. data/rust-vendor/wit-component/tests/interfaces/wasi-http/types.wit +570 -0
  1460. data/rust-vendor/wit-component/tests/interfaces/wasi-http.wat +881 -0
  1461. data/rust-vendor/wit-component/tests/interfaces/world-inline-interface.wat +24 -0
  1462. data/rust-vendor/wit-component/tests/interfaces/world-inline-interface.wit +6 -0
  1463. data/rust-vendor/wit-component/tests/interfaces/world-inline-interface.wit.print +9 -0
  1464. data/rust-vendor/wit-component/tests/interfaces/world-pkg-conflict/bar.wit +3 -0
  1465. data/rust-vendor/wit-component/tests/interfaces/world-pkg-conflict/foo.wit +9 -0
  1466. data/rust-vendor/wit-component/tests/interfaces/world-pkg-conflict/foo.wit.print +12 -0
  1467. data/rust-vendor/wit-component/tests/interfaces/world-pkg-conflict.wat +47 -0
  1468. data/rust-vendor/wit-component/tests/interfaces/world-top-level.wat +55 -0
  1469. data/rust-vendor/wit-component/tests/interfaces/world-top-level.wit +20 -0
  1470. data/rust-vendor/wit-component/tests/interfaces/world-top-level.wit.print +19 -0
  1471. data/rust-vendor/wit-component/tests/interfaces/worlds-with-types.wat +56 -0
  1472. data/rust-vendor/wit-component/tests/interfaces/worlds-with-types.wit +23 -0
  1473. data/rust-vendor/wit-component/tests/interfaces/worlds-with-types.wit.print +23 -0
  1474. data/rust-vendor/wit-component/tests/interfaces.rs +123 -0
  1475. data/rust-vendor/wit-component/tests/linking.rs +299 -0
  1476. data/rust-vendor/wit-component/tests/merge/bad-interface1/error.txt +1 -0
  1477. data/rust-vendor/wit-component/tests/merge/bad-interface1/from/a.wit +5 -0
  1478. data/rust-vendor/wit-component/tests/merge/bad-interface1/from/deps/foo/a.wit +5 -0
  1479. data/rust-vendor/wit-component/tests/merge/bad-interface1/into/a.wit +5 -0
  1480. data/rust-vendor/wit-component/tests/merge/bad-interface1/into/deps/foo/a.wit +5 -0
  1481. data/rust-vendor/wit-component/tests/merge/bad-interface2/error.txt +1 -0
  1482. data/rust-vendor/wit-component/tests/merge/bad-interface2/from/a.wit +5 -0
  1483. data/rust-vendor/wit-component/tests/merge/bad-interface2/from/deps/foo/a.wit +7 -0
  1484. data/rust-vendor/wit-component/tests/merge/bad-interface2/into/a.wit +5 -0
  1485. data/rust-vendor/wit-component/tests/merge/bad-interface2/into/deps/foo/a.wit +7 -0
  1486. data/rust-vendor/wit-component/tests/merge/bad-world1/error.txt +1 -0
  1487. data/rust-vendor/wit-component/tests/merge/bad-world1/from/a.wit +4 -0
  1488. data/rust-vendor/wit-component/tests/merge/bad-world1/from/deps/foo/a.wit +11 -0
  1489. data/rust-vendor/wit-component/tests/merge/bad-world1/into/a.wit +4 -0
  1490. data/rust-vendor/wit-component/tests/merge/bad-world1/into/deps/foo/a.wit +9 -0
  1491. data/rust-vendor/wit-component/tests/merge/bad-world2/error.txt +1 -0
  1492. data/rust-vendor/wit-component/tests/merge/bad-world2/from/a.wit +5 -0
  1493. data/rust-vendor/wit-component/tests/merge/bad-world2/from/deps/foo/a.wit +8 -0
  1494. data/rust-vendor/wit-component/tests/merge/bad-world2/into/a.wit +5 -0
  1495. data/rust-vendor/wit-component/tests/merge/bad-world2/into/deps/foo/a.wit +9 -0
  1496. data/rust-vendor/wit-component/tests/merge/bad-world3/error.txt +1 -0
  1497. data/rust-vendor/wit-component/tests/merge/bad-world3/from/a.wit +5 -0
  1498. data/rust-vendor/wit-component/tests/merge/bad-world3/from/deps/foo/a.wit +8 -0
  1499. data/rust-vendor/wit-component/tests/merge/bad-world3/into/a.wit +5 -0
  1500. data/rust-vendor/wit-component/tests/merge/bad-world3/into/deps/foo/a.wit +9 -0
  1501. data/rust-vendor/wit-component/tests/merge/bad-world4/error.txt +1 -0
  1502. data/rust-vendor/wit-component/tests/merge/bad-world4/from/a.wit +5 -0
  1503. data/rust-vendor/wit-component/tests/merge/bad-world4/from/deps/foo/a.wit +11 -0
  1504. data/rust-vendor/wit-component/tests/merge/bad-world4/into/a.wit +5 -0
  1505. data/rust-vendor/wit-component/tests/merge/bad-world4/into/deps/foo/a.wit +9 -0
  1506. data/rust-vendor/wit-component/tests/merge/bad-world5/error.txt +1 -0
  1507. data/rust-vendor/wit-component/tests/merge/bad-world5/from/a.wit +5 -0
  1508. data/rust-vendor/wit-component/tests/merge/bad-world5/from/deps/foo/a.wit +11 -0
  1509. data/rust-vendor/wit-component/tests/merge/bad-world5/into/a.wit +5 -0
  1510. data/rust-vendor/wit-component/tests/merge/bad-world5/into/deps/foo/a.wit +9 -0
  1511. data/rust-vendor/wit-component/tests/merge/success/from/a.wit +7 -0
  1512. data/rust-vendor/wit-component/tests/merge/success/from/deps/foo/only-from.wit +5 -0
  1513. data/rust-vendor/wit-component/tests/merge/success/from/deps/foo/shared.wit +46 -0
  1514. data/rust-vendor/wit-component/tests/merge/success/from/deps/only-from-dep/a.wit +5 -0
  1515. data/rust-vendor/wit-component/tests/merge/success/into/b.wit +7 -0
  1516. data/rust-vendor/wit-component/tests/merge/success/into/deps/foo/only-into.wit +5 -0
  1517. data/rust-vendor/wit-component/tests/merge/success/into/deps/foo/shared.wit +44 -0
  1518. data/rust-vendor/wit-component/tests/merge/success/merge/foo.wit +77 -0
  1519. data/rust-vendor/wit-component/tests/merge/success/merge/from.wit +8 -0
  1520. data/rust-vendor/wit-component/tests/merge/success/merge/into.wit +8 -0
  1521. data/rust-vendor/wit-component/tests/merge/success/merge/only-from-dep.wit +6 -0
  1522. data/rust-vendor/wit-component/tests/merge.rs +80 -0
  1523. data/rust-vendor/wit-component/tests/targets/error-missing-export/error.txt +2 -0
  1524. data/rust-vendor/wit-component/tests/targets/error-missing-export/test.wat +39 -0
  1525. data/rust-vendor/wit-component/tests/targets/error-missing-export/test.wit +18 -0
  1526. data/rust-vendor/wit-component/tests/targets/error-missing-import/error.txt +2 -0
  1527. data/rust-vendor/wit-component/tests/targets/error-missing-import/test.wat +37 -0
  1528. data/rust-vendor/wit-component/tests/targets/error-missing-import/test.wit +13 -0
  1529. data/rust-vendor/wit-component/tests/targets/success/test.wat +56 -0
  1530. data/rust-vendor/wit-component/tests/targets/success/test.wit +14 -0
  1531. data/rust-vendor/wit-component/tests/targets/success-empty/test.wat +1 -0
  1532. data/rust-vendor/wit-component/tests/targets/success-empty/test.wit +9 -0
  1533. data/rust-vendor/wit-component/tests/targets.rs +89 -0
  1534. data/rust-vendor/wit-component/tests/wit/parse-dir/wit/deps/bar/bar.wit +9 -0
  1535. data/rust-vendor/wit-component/tests/wit/parse-dir/wit/world.wit +5 -0
  1536. data/rust-vendor/wit-component/tests/wit.rs +49 -0
  1537. data/rust-vendor/wit-parser/.cargo-checksum.json +1 -0
  1538. data/rust-vendor/wit-parser/.cargo_vcs_info.json +6 -0
  1539. data/rust-vendor/wit-parser/Cargo.lock +576 -0
  1540. data/rust-vendor/wit-parser/Cargo.toml +157 -0
  1541. data/rust-vendor/wit-parser/Cargo.toml.orig +56 -0
  1542. data/rust-vendor/wit-parser/README.md +13 -0
  1543. data/rust-vendor/wit-parser/src/abi.rs +410 -0
  1544. data/rust-vendor/wit-parser/src/ast/lex.rs +751 -0
  1545. data/rust-vendor/wit-parser/src/ast/resolve.rs +1813 -0
  1546. data/rust-vendor/wit-parser/src/ast/toposort.rs +249 -0
  1547. data/rust-vendor/wit-parser/src/ast.rs +1958 -0
  1548. data/rust-vendor/wit-parser/src/decoding.rs +1864 -0
  1549. data/rust-vendor/wit-parser/src/lib.rs +1413 -0
  1550. data/rust-vendor/wit-parser/src/live.rs +264 -0
  1551. data/rust-vendor/wit-parser/src/metadata.rs +772 -0
  1552. data/rust-vendor/wit-parser/src/resolve/clone.rs +227 -0
  1553. data/rust-vendor/wit-parser/src/resolve.rs +4636 -0
  1554. data/rust-vendor/wit-parser/src/serde_.rs +140 -0
  1555. data/rust-vendor/wit-parser/src/sizealign.rs +626 -0
  1556. data/rust-vendor/wit-parser/tests/.gitignore +2 -0
  1557. data/rust-vendor/wit-parser/tests/all.rs +153 -0
  1558. data/rust-vendor/wit-parser/tests/ui/async.wit +24 -0
  1559. data/rust-vendor/wit-parser/tests/ui/async.wit.json +151 -0
  1560. data/rust-vendor/wit-parser/tests/ui/comments.wit +25 -0
  1561. data/rust-vendor/wit-parser/tests/ui/comments.wit.json +46 -0
  1562. data/rust-vendor/wit-parser/tests/ui/complex-include/deps/bar/root.wit +9 -0
  1563. data/rust-vendor/wit-parser/tests/ui/complex-include/deps/baz/root.wit +9 -0
  1564. data/rust-vendor/wit-parser/tests/ui/complex-include/root.wit +26 -0
  1565. data/rust-vendor/wit-parser/tests/ui/complex-include.wit.json +200 -0
  1566. data/rust-vendor/wit-parser/tests/ui/cross-package-resource/deps/foo/foo.wit +5 -0
  1567. data/rust-vendor/wit-parser/tests/ui/cross-package-resource/foo.wit +7 -0
  1568. data/rust-vendor/wit-parser/tests/ui/cross-package-resource.wit.json +67 -0
  1569. data/rust-vendor/wit-parser/tests/ui/diamond1/deps/dep1/types.wit +2 -0
  1570. data/rust-vendor/wit-parser/tests/ui/diamond1/deps/dep2/types.wit +2 -0
  1571. data/rust-vendor/wit-parser/tests/ui/diamond1/join.wit +6 -0
  1572. data/rust-vendor/wit-parser/tests/ui/diamond1.wit.json +59 -0
  1573. data/rust-vendor/wit-parser/tests/ui/disambiguate-diamond/shared1.wit +3 -0
  1574. data/rust-vendor/wit-parser/tests/ui/disambiguate-diamond/shared2.wit +3 -0
  1575. data/rust-vendor/wit-parser/tests/ui/disambiguate-diamond/world.wit +13 -0
  1576. data/rust-vendor/wit-parser/tests/ui/disambiguate-diamond.wit.json +115 -0
  1577. data/rust-vendor/wit-parser/tests/ui/empty.wit +1 -0
  1578. data/rust-vendor/wit-parser/tests/ui/empty.wit.json +12 -0
  1579. data/rust-vendor/wit-parser/tests/ui/error-context.wit +7 -0
  1580. data/rust-vendor/wit-parser/tests/ui/error-context.wit.json +59 -0
  1581. data/rust-vendor/wit-parser/tests/ui/feature-gates.wit +118 -0
  1582. data/rust-vendor/wit-parser/tests/ui/feature-gates.wit.json +301 -0
  1583. data/rust-vendor/wit-parser/tests/ui/feature-types.wit +13 -0
  1584. data/rust-vendor/wit-parser/tests/ui/feature-types.wit.json +66 -0
  1585. data/rust-vendor/wit-parser/tests/ui/foreign-deps/deps/another-pkg/other-doc.wit +3 -0
  1586. data/rust-vendor/wit-parser/tests/ui/foreign-deps/deps/corp/saas.wit +4 -0
  1587. data/rust-vendor/wit-parser/tests/ui/foreign-deps/deps/different-pkg/the-doc.wit +2 -0
  1588. data/rust-vendor/wit-parser/tests/ui/foreign-deps/deps/foreign-pkg/the-doc.wit +5 -0
  1589. data/rust-vendor/wit-parser/tests/ui/foreign-deps/deps/some-pkg/some-doc.wit +13 -0
  1590. data/rust-vendor/wit-parser/tests/ui/foreign-deps/deps/wasi/clocks.wit +5 -0
  1591. data/rust-vendor/wit-parser/tests/ui/foreign-deps/deps/wasi/filesystem.wit +7 -0
  1592. data/rust-vendor/wit-parser/tests/ui/foreign-deps/root.wit +44 -0
  1593. data/rust-vendor/wit-parser/tests/ui/foreign-deps-union/deps/another-pkg/other-doc.wit +3 -0
  1594. data/rust-vendor/wit-parser/tests/ui/foreign-deps-union/deps/corp/saas.wit +4 -0
  1595. data/rust-vendor/wit-parser/tests/ui/foreign-deps-union/deps/different-pkg/the-doc.wit +2 -0
  1596. data/rust-vendor/wit-parser/tests/ui/foreign-deps-union/deps/foreign-pkg/the-doc.wit +5 -0
  1597. data/rust-vendor/wit-parser/tests/ui/foreign-deps-union/deps/some-pkg/some-doc.wit +13 -0
  1598. data/rust-vendor/wit-parser/tests/ui/foreign-deps-union/deps/wasi/clocks.wit +5 -0
  1599. data/rust-vendor/wit-parser/tests/ui/foreign-deps-union/deps/wasi/filesystem.wit +7 -0
  1600. data/rust-vendor/wit-parser/tests/ui/foreign-deps-union/deps/wasi/wasi.wit +6 -0
  1601. data/rust-vendor/wit-parser/tests/ui/foreign-deps-union/root.wit +50 -0
  1602. data/rust-vendor/wit-parser/tests/ui/foreign-deps-union.wit.json +410 -0
  1603. data/rust-vendor/wit-parser/tests/ui/foreign-deps.wit.json +362 -0
  1604. data/rust-vendor/wit-parser/tests/ui/foreign-interface-dep-gated.wit +17 -0
  1605. data/rust-vendor/wit-parser/tests/ui/foreign-interface-dep-gated.wit.json +39 -0
  1606. data/rust-vendor/wit-parser/tests/ui/foreign-world-dep-gated.wit +17 -0
  1607. data/rust-vendor/wit-parser/tests/ui/foreign-world-dep-gated.wit.json +39 -0
  1608. data/rust-vendor/wit-parser/tests/ui/functions.wit +11 -0
  1609. data/rust-vendor/wit-parser/tests/ui/functions.wit.json +115 -0
  1610. data/rust-vendor/wit-parser/tests/ui/gated-include.wit +67 -0
  1611. data/rust-vendor/wit-parser/tests/ui/gated-include.wit.json +346 -0
  1612. data/rust-vendor/wit-parser/tests/ui/gated-use.wit +13 -0
  1613. data/rust-vendor/wit-parser/tests/ui/gated-use.wit.json +34 -0
  1614. data/rust-vendor/wit-parser/tests/ui/ignore-files-deps/deps/bar/types.wit +2 -0
  1615. data/rust-vendor/wit-parser/tests/ui/ignore-files-deps/deps/ignore-me.txt +1 -0
  1616. data/rust-vendor/wit-parser/tests/ui/ignore-files-deps/world.wit +5 -0
  1617. data/rust-vendor/wit-parser/tests/ui/ignore-files-deps.wit.json +41 -0
  1618. data/rust-vendor/wit-parser/tests/ui/import-export-overlap1.wit +5 -0
  1619. data/rust-vendor/wit-parser/tests/ui/import-export-overlap1.wit.json +37 -0
  1620. data/rust-vendor/wit-parser/tests/ui/import-export-overlap2.wit +5 -0
  1621. data/rust-vendor/wit-parser/tests/ui/import-export-overlap2.wit.json +42 -0
  1622. data/rust-vendor/wit-parser/tests/ui/include-reps.wit +15 -0
  1623. data/rust-vendor/wit-parser/tests/ui/include-reps.wit.json +68 -0
  1624. data/rust-vendor/wit-parser/tests/ui/kebab-name-include-with.wit +8 -0
  1625. data/rust-vendor/wit-parser/tests/ui/kebab-name-include-with.wit.json +66 -0
  1626. data/rust-vendor/wit-parser/tests/ui/kinds-of-deps/a.wit +8 -0
  1627. data/rust-vendor/wit-parser/tests/ui/kinds-of-deps/deps/b/root.wit +3 -0
  1628. data/rust-vendor/wit-parser/tests/ui/kinds-of-deps/deps/c.wit +3 -0
  1629. data/rust-vendor/wit-parser/tests/ui/kinds-of-deps/deps/d.wat +6 -0
  1630. data/rust-vendor/wit-parser/tests/ui/kinds-of-deps/deps/e.wasm +0 -0
  1631. data/rust-vendor/wit-parser/tests/ui/kinds-of-deps.wit.json +95 -0
  1632. data/rust-vendor/wit-parser/tests/ui/many-names/a.wit +2 -0
  1633. data/rust-vendor/wit-parser/tests/ui/many-names/b.wit +5 -0
  1634. data/rust-vendor/wit-parser/tests/ui/many-names.wit.json +42 -0
  1635. data/rust-vendor/wit-parser/tests/ui/maps.wit +34 -0
  1636. data/rust-vendor/wit-parser/tests/ui/maps.wit.json +255 -0
  1637. data/rust-vendor/wit-parser/tests/ui/multi-file/bar.wit +21 -0
  1638. data/rust-vendor/wit-parser/tests/ui/multi-file/cycle-a.wit +7 -0
  1639. data/rust-vendor/wit-parser/tests/ui/multi-file/cycle-b.wit +3 -0
  1640. data/rust-vendor/wit-parser/tests/ui/multi-file/foo.wit +31 -0
  1641. data/rust-vendor/wit-parser/tests/ui/multi-file-multi-package/a.wit +24 -0
  1642. data/rust-vendor/wit-parser/tests/ui/multi-file-multi-package/b.wit +23 -0
  1643. data/rust-vendor/wit-parser/tests/ui/multi-file-multi-package.wit.json +255 -0
  1644. data/rust-vendor/wit-parser/tests/ui/multi-file.wit.json +300 -0
  1645. data/rust-vendor/wit-parser/tests/ui/multi-package-deps/deps/dep.wit +13 -0
  1646. data/rust-vendor/wit-parser/tests/ui/multi-package-deps/root.wit +16 -0
  1647. data/rust-vendor/wit-parser/tests/ui/multi-package-deps.wit.json +161 -0
  1648. data/rust-vendor/wit-parser/tests/ui/multi-package-gated-include.wit +114 -0
  1649. data/rust-vendor/wit-parser/tests/ui/multi-package-gated-include.wit.json +697 -0
  1650. data/rust-vendor/wit-parser/tests/ui/multi-package-shared-deps/deps/dep1/types.wit +4 -0
  1651. data/rust-vendor/wit-parser/tests/ui/multi-package-shared-deps/deps/dep2/types.wit +4 -0
  1652. data/rust-vendor/wit-parser/tests/ui/multi-package-shared-deps/packages.wit +41 -0
  1653. data/rust-vendor/wit-parser/tests/ui/multi-package-shared-deps.wit.json +261 -0
  1654. data/rust-vendor/wit-parser/tests/ui/multi-package-transitive-deps/deps/dep1/types.wit +8 -0
  1655. data/rust-vendor/wit-parser/tests/ui/multi-package-transitive-deps/deps/dep2/types.wit +14 -0
  1656. data/rust-vendor/wit-parser/tests/ui/multi-package-transitive-deps/packages.wit +12 -0
  1657. data/rust-vendor/wit-parser/tests/ui/multi-package-transitive-deps.wit.json +174 -0
  1658. data/rust-vendor/wit-parser/tests/ui/name-both-resource-and-type/deps/dep/foo.wit +5 -0
  1659. data/rust-vendor/wit-parser/tests/ui/name-both-resource-and-type/foo.wit +9 -0
  1660. data/rust-vendor/wit-parser/tests/ui/name-both-resource-and-type.wit.json +89 -0
  1661. data/rust-vendor/wit-parser/tests/ui/package-syntax1.wit +1 -0
  1662. data/rust-vendor/wit-parser/tests/ui/package-syntax1.wit.json +12 -0
  1663. data/rust-vendor/wit-parser/tests/ui/package-syntax3.wit +1 -0
  1664. data/rust-vendor/wit-parser/tests/ui/package-syntax3.wit.json +12 -0
  1665. data/rust-vendor/wit-parser/tests/ui/package-syntax4.wit +1 -0
  1666. data/rust-vendor/wit-parser/tests/ui/package-syntax4.wit.json +12 -0
  1667. data/rust-vendor/wit-parser/tests/ui/packages-multiple-nested.wit +35 -0
  1668. data/rust-vendor/wit-parser/tests/ui/packages-multiple-nested.wit.json +184 -0
  1669. data/rust-vendor/wit-parser/tests/ui/packages-nested-colliding-decl-names.wit +24 -0
  1670. data/rust-vendor/wit-parser/tests/ui/packages-nested-colliding-decl-names.wit.json +135 -0
  1671. data/rust-vendor/wit-parser/tests/ui/packages-nested-internal-references.wit +16 -0
  1672. data/rust-vendor/wit-parser/tests/ui/packages-nested-internal-references.wit.json +91 -0
  1673. data/rust-vendor/wit-parser/tests/ui/packages-nested-with-semver.wit +24 -0
  1674. data/rust-vendor/wit-parser/tests/ui/packages-nested-with-semver.wit.json +135 -0
  1675. data/rust-vendor/wit-parser/tests/ui/packages-single-nested.wit +12 -0
  1676. data/rust-vendor/wit-parser/tests/ui/packages-single-nested.wit.json +75 -0
  1677. data/rust-vendor/wit-parser/tests/ui/parse-fail/alias-no-type.wit +6 -0
  1678. data/rust-vendor/wit-parser/tests/ui/parse-fail/alias-no-type.wit.result +5 -0
  1679. data/rust-vendor/wit-parser/tests/ui/parse-fail/async-bad-world.wit +6 -0
  1680. data/rust-vendor/wit-parser/tests/ui/parse-fail/async-bad-world.wit.result +5 -0
  1681. data/rust-vendor/wit-parser/tests/ui/parse-fail/async-bad-world2.wit +6 -0
  1682. data/rust-vendor/wit-parser/tests/ui/parse-fail/async-bad-world2.wit.result +5 -0
  1683. data/rust-vendor/wit-parser/tests/ui/parse-fail/async-bad-world3.wit +6 -0
  1684. data/rust-vendor/wit-parser/tests/ui/parse-fail/async-bad-world3.wit.result +5 -0
  1685. data/rust-vendor/wit-parser/tests/ui/parse-fail/async-bad-world4.wit +11 -0
  1686. data/rust-vendor/wit-parser/tests/ui/parse-fail/async-bad-world4.wit.result +5 -0
  1687. data/rust-vendor/wit-parser/tests/ui/parse-fail/async-bad1.wit +7 -0
  1688. data/rust-vendor/wit-parser/tests/ui/parse-fail/async-bad1.wit.result +5 -0
  1689. data/rust-vendor/wit-parser/tests/ui/parse-fail/async-bad2.wit +7 -0
  1690. data/rust-vendor/wit-parser/tests/ui/parse-fail/async-bad2.wit.result +5 -0
  1691. data/rust-vendor/wit-parser/tests/ui/parse-fail/async.wit.result +5 -0
  1692. data/rust-vendor/wit-parser/tests/ui/parse-fail/async1.wit.result +5 -0
  1693. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-deprecated1.wit +4 -0
  1694. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-deprecated1.wit.result +5 -0
  1695. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-deprecated2.wit +4 -0
  1696. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-deprecated2.wit.result +5 -0
  1697. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-deprecated3.wit +4 -0
  1698. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-deprecated3.wit.result +5 -0
  1699. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-deprecated4.wit +5 -0
  1700. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-deprecated4.wit.result +5 -0
  1701. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-function.wit +7 -0
  1702. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-function.wit.result +5 -0
  1703. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-function2.wit +7 -0
  1704. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-function2.wit.result +5 -0
  1705. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-gate1.wit +8 -0
  1706. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-gate1.wit.result +5 -0
  1707. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-gate2.wit +8 -0
  1708. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-gate2.wit.result +5 -0
  1709. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-gate3.wit +6 -0
  1710. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-gate3.wit.result +5 -0
  1711. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-gate4.wit +8 -0
  1712. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-gate4.wit.result +5 -0
  1713. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-gate5.wit +11 -0
  1714. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-gate5.wit.result +5 -0
  1715. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-include1.wit +5 -0
  1716. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-include1.wit.result +5 -0
  1717. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-include2.wit +9 -0
  1718. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-include2.wit.result +5 -0
  1719. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-include3.wit +5 -0
  1720. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-include3.wit.result +5 -0
  1721. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-list.wit +7 -0
  1722. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-list.wit.result +5 -0
  1723. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-list2.wit +7 -0
  1724. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-list2.wit.result +5 -0
  1725. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-list3.wit +7 -0
  1726. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-list3.wit.result +5 -0
  1727. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-list4.wit +7 -0
  1728. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-list4.wit.result +5 -0
  1729. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-pkg1/root.wit +5 -0
  1730. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-pkg1.wit.result +5 -0
  1731. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-pkg2/deps/bar/empty.wit +1 -0
  1732. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-pkg2/root.wit +5 -0
  1733. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-pkg2.wit.result +5 -0
  1734. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-pkg3/deps/bar/.gitkeep +0 -0
  1735. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-pkg3/deps/bar/baz.wit +2 -0
  1736. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-pkg3/root.wit +5 -0
  1737. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-pkg3.wit.result +5 -0
  1738. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-pkg4/deps/bar/.gitkeep +0 -0
  1739. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-pkg4/deps/bar/baz.wit +4 -0
  1740. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-pkg4/root.wit +4 -0
  1741. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-pkg4.wit.result +5 -0
  1742. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-pkg5/deps/bar/.gitkeep +0 -0
  1743. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-pkg5/deps/bar/baz.wit +3 -0
  1744. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-pkg5/root.wit +4 -0
  1745. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-pkg5.wit.result +5 -0
  1746. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-pkg6/deps/bar/.gitkeep +0 -0
  1747. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-pkg6/deps/bar/baz.wit +4 -0
  1748. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-pkg6/root.wit +4 -0
  1749. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-pkg6.wit.result +8 -0
  1750. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource1.wit +5 -0
  1751. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource1.wit.result +5 -0
  1752. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource10.wit +5 -0
  1753. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource10.wit.result +5 -0
  1754. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource11.wit +5 -0
  1755. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource11.wit.result +5 -0
  1756. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource12.wit +6 -0
  1757. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource12.wit.result +5 -0
  1758. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource13.wit +6 -0
  1759. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource13.wit.result +5 -0
  1760. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource14.wit +7 -0
  1761. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource14.wit.result +5 -0
  1762. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource15/deps/foo/foo.wit +5 -0
  1763. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource15/foo.wit +7 -0
  1764. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource15.wit.result +5 -0
  1765. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource16.wit +7 -0
  1766. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource16.wit.result +5 -0
  1767. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource17.wit +8 -0
  1768. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource17.wit.result +5 -0
  1769. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource2.wit +5 -0
  1770. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource2.wit.result +5 -0
  1771. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource3.wit +6 -0
  1772. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource3.wit.result +5 -0
  1773. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource4.wit +6 -0
  1774. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource4.wit.result +5 -0
  1775. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource5.wit +7 -0
  1776. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource5.wit.result +5 -0
  1777. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource6.wit +7 -0
  1778. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource6.wit.result +5 -0
  1779. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource7.wit +8 -0
  1780. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource7.wit.result +5 -0
  1781. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource8.wit +8 -0
  1782. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource8.wit.result +5 -0
  1783. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource9.wit +7 -0
  1784. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-resource9.wit.result +5 -0
  1785. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-since1.wit +4 -0
  1786. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-since1.wit.result +5 -0
  1787. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-since3.wit +5 -0
  1788. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-since3.wit.result +5 -0
  1789. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-world-type1.wit +5 -0
  1790. data/rust-vendor/wit-parser/tests/ui/parse-fail/bad-world-type1.wit.result +5 -0
  1791. data/rust-vendor/wit-parser/tests/ui/parse-fail/case-insensitive-duplicates.wit +9 -0
  1792. data/rust-vendor/wit-parser/tests/ui/parse-fail/case-insensitive-duplicates.wit.result +1 -0
  1793. data/rust-vendor/wit-parser/tests/ui/parse-fail/conflicting-package/a.wit +1 -0
  1794. data/rust-vendor/wit-parser/tests/ui/parse-fail/conflicting-package/b.wit +1 -0
  1795. data/rust-vendor/wit-parser/tests/ui/parse-fail/conflicting-package.wit.result +5 -0
  1796. data/rust-vendor/wit-parser/tests/ui/parse-fail/cycle.wit +6 -0
  1797. data/rust-vendor/wit-parser/tests/ui/parse-fail/cycle.wit.result +5 -0
  1798. data/rust-vendor/wit-parser/tests/ui/parse-fail/cycle2.wit +7 -0
  1799. data/rust-vendor/wit-parser/tests/ui/parse-fail/cycle2.wit.result +5 -0
  1800. data/rust-vendor/wit-parser/tests/ui/parse-fail/cycle3.wit +7 -0
  1801. data/rust-vendor/wit-parser/tests/ui/parse-fail/cycle3.wit.result +5 -0
  1802. data/rust-vendor/wit-parser/tests/ui/parse-fail/cycle4.wit +7 -0
  1803. data/rust-vendor/wit-parser/tests/ui/parse-fail/cycle4.wit.result +5 -0
  1804. data/rust-vendor/wit-parser/tests/ui/parse-fail/cycle5.wit +7 -0
  1805. data/rust-vendor/wit-parser/tests/ui/parse-fail/cycle5.wit.result +5 -0
  1806. data/rust-vendor/wit-parser/tests/ui/parse-fail/dangling-type.wit +5 -0
  1807. data/rust-vendor/wit-parser/tests/ui/parse-fail/dangling-type.wit.result +5 -0
  1808. data/rust-vendor/wit-parser/tests/ui/parse-fail/duplicate-function-params.wit +7 -0
  1809. data/rust-vendor/wit-parser/tests/ui/parse-fail/duplicate-function-params.wit.result +5 -0
  1810. data/rust-vendor/wit-parser/tests/ui/parse-fail/duplicate-functions.wit +8 -0
  1811. data/rust-vendor/wit-parser/tests/ui/parse-fail/duplicate-functions.wit.result +5 -0
  1812. data/rust-vendor/wit-parser/tests/ui/parse-fail/duplicate-interface.wit +6 -0
  1813. data/rust-vendor/wit-parser/tests/ui/parse-fail/duplicate-interface.wit.result +5 -0
  1814. data/rust-vendor/wit-parser/tests/ui/parse-fail/duplicate-interface2/foo.wit +3 -0
  1815. data/rust-vendor/wit-parser/tests/ui/parse-fail/duplicate-interface2/foo2.wit +3 -0
  1816. data/rust-vendor/wit-parser/tests/ui/parse-fail/duplicate-interface2.wit.result +5 -0
  1817. data/rust-vendor/wit-parser/tests/ui/parse-fail/duplicate-type.wit +7 -0
  1818. data/rust-vendor/wit-parser/tests/ui/parse-fail/duplicate-type.wit.result +5 -0
  1819. data/rust-vendor/wit-parser/tests/ui/parse-fail/empty-enum.wit +6 -0
  1820. data/rust-vendor/wit-parser/tests/ui/parse-fail/empty-enum.wit.result +5 -0
  1821. data/rust-vendor/wit-parser/tests/ui/parse-fail/empty-variant1.wit +6 -0
  1822. data/rust-vendor/wit-parser/tests/ui/parse-fail/empty-variant1.wit.result +5 -0
  1823. data/rust-vendor/wit-parser/tests/ui/parse-fail/export-twice.wit +8 -0
  1824. data/rust-vendor/wit-parser/tests/ui/parse-fail/export-twice.wit.result +5 -0
  1825. data/rust-vendor/wit-parser/tests/ui/parse-fail/import-and-export1.wit +17 -0
  1826. data/rust-vendor/wit-parser/tests/ui/parse-fail/import-and-export1.wit.result +5 -0
  1827. data/rust-vendor/wit-parser/tests/ui/parse-fail/import-and-export2.wit +18 -0
  1828. data/rust-vendor/wit-parser/tests/ui/parse-fail/import-and-export2.wit.result +5 -0
  1829. data/rust-vendor/wit-parser/tests/ui/parse-fail/import-and-export3.wit +37 -0
  1830. data/rust-vendor/wit-parser/tests/ui/parse-fail/import-and-export3.wit.result +5 -0
  1831. data/rust-vendor/wit-parser/tests/ui/parse-fail/import-and-export4.wit +44 -0
  1832. data/rust-vendor/wit-parser/tests/ui/parse-fail/import-and-export4.wit.result +5 -0
  1833. data/rust-vendor/wit-parser/tests/ui/parse-fail/import-and-export5.wit +18 -0
  1834. data/rust-vendor/wit-parser/tests/ui/parse-fail/import-and-export5.wit.result +5 -0
  1835. data/rust-vendor/wit-parser/tests/ui/parse-fail/import-twice.wit +8 -0
  1836. data/rust-vendor/wit-parser/tests/ui/parse-fail/import-twice.wit.result +5 -0
  1837. data/rust-vendor/wit-parser/tests/ui/parse-fail/include-cycle.wit +9 -0
  1838. data/rust-vendor/wit-parser/tests/ui/parse-fail/include-cycle.wit.result +5 -0
  1839. data/rust-vendor/wit-parser/tests/ui/parse-fail/include-foreign/deps/bar/empty.wit +3 -0
  1840. data/rust-vendor/wit-parser/tests/ui/parse-fail/include-foreign/root.wit +5 -0
  1841. data/rust-vendor/wit-parser/tests/ui/parse-fail/include-foreign.wit.result +5 -0
  1842. data/rust-vendor/wit-parser/tests/ui/parse-fail/include-with-id.wit +11 -0
  1843. data/rust-vendor/wit-parser/tests/ui/parse-fail/include-with-id.wit.result +5 -0
  1844. data/rust-vendor/wit-parser/tests/ui/parse-fail/include-with-on-id.wit +11 -0
  1845. data/rust-vendor/wit-parser/tests/ui/parse-fail/include-with-on-id.wit.result +5 -0
  1846. data/rust-vendor/wit-parser/tests/ui/parse-fail/invalid-toplevel.wit +5 -0
  1847. data/rust-vendor/wit-parser/tests/ui/parse-fail/invalid-toplevel.wit.result +5 -0
  1848. data/rust-vendor/wit-parser/tests/ui/parse-fail/invalid-type-reference.wit +10 -0
  1849. data/rust-vendor/wit-parser/tests/ui/parse-fail/invalid-type-reference.wit.result +5 -0
  1850. data/rust-vendor/wit-parser/tests/ui/parse-fail/invalid-type-reference2.wit +6 -0
  1851. data/rust-vendor/wit-parser/tests/ui/parse-fail/invalid-type-reference2.wit.result +5 -0
  1852. data/rust-vendor/wit-parser/tests/ui/parse-fail/kebab-name-include-not-found.wit +8 -0
  1853. data/rust-vendor/wit-parser/tests/ui/parse-fail/kebab-name-include-not-found.wit.result +5 -0
  1854. data/rust-vendor/wit-parser/tests/ui/parse-fail/kebab-name-include.wit +8 -0
  1855. data/rust-vendor/wit-parser/tests/ui/parse-fail/kebab-name-include.wit.result +5 -0
  1856. data/rust-vendor/wit-parser/tests/ui/parse-fail/keyword.wit +5 -0
  1857. data/rust-vendor/wit-parser/tests/ui/parse-fail/keyword.wit.result +5 -0
  1858. data/rust-vendor/wit-parser/tests/ui/parse-fail/map-invalid-key.wit +7 -0
  1859. data/rust-vendor/wit-parser/tests/ui/parse-fail/map-invalid-key.wit.result +5 -0
  1860. data/rust-vendor/wit-parser/tests/ui/parse-fail/missing-main-declaration-initial-main.wit +23 -0
  1861. data/rust-vendor/wit-parser/tests/ui/parse-fail/missing-main-declaration-initial-main.wit.result +1 -0
  1862. data/rust-vendor/wit-parser/tests/ui/parse-fail/missing-main-declaration-initial-nested.wit +23 -0
  1863. data/rust-vendor/wit-parser/tests/ui/parse-fail/missing-main-declaration-initial-nested.wit.result +1 -0
  1864. data/rust-vendor/wit-parser/tests/ui/parse-fail/missing-package.wit +0 -0
  1865. data/rust-vendor/wit-parser/tests/ui/parse-fail/missing-package.wit.result +1 -0
  1866. data/rust-vendor/wit-parser/tests/ui/parse-fail/multi-file-missing-delimiter/observe.wit +5 -0
  1867. data/rust-vendor/wit-parser/tests/ui/parse-fail/multi-file-missing-delimiter/world.wit +5 -0
  1868. data/rust-vendor/wit-parser/tests/ui/parse-fail/multi-file-missing-delimiter.wit.result +5 -0
  1869. data/rust-vendor/wit-parser/tests/ui/parse-fail/multi-package-deps-share-nest/deps/dep1/types.wit +12 -0
  1870. data/rust-vendor/wit-parser/tests/ui/parse-fail/multi-package-deps-share-nest/deps/dep2/types.wit +12 -0
  1871. data/rust-vendor/wit-parser/tests/ui/parse-fail/multi-package-deps-share-nest/root.wit +8 -0
  1872. data/rust-vendor/wit-parser/tests/ui/parse-fail/multi-package-deps-share-nest.wit.result +3 -0
  1873. data/rust-vendor/wit-parser/tests/ui/parse-fail/multiple-package-docs/a.wit +2 -0
  1874. data/rust-vendor/wit-parser/tests/ui/parse-fail/multiple-package-docs/b.wit +2 -0
  1875. data/rust-vendor/wit-parser/tests/ui/parse-fail/multiple-package-docs.wit.result +5 -0
  1876. data/rust-vendor/wit-parser/tests/ui/parse-fail/multiple-package-inline-cycle.wit +12 -0
  1877. data/rust-vendor/wit-parser/tests/ui/parse-fail/multiple-package-inline-cycle.wit.result +5 -0
  1878. data/rust-vendor/wit-parser/tests/ui/parse-fail/multiple-packages-no-scope-blocks.wit +15 -0
  1879. data/rust-vendor/wit-parser/tests/ui/parse-fail/multiple-packages-no-scope-blocks.wit.result +5 -0
  1880. data/rust-vendor/wit-parser/tests/ui/parse-fail/nested-packages-colliding-names.wit +5 -0
  1881. data/rust-vendor/wit-parser/tests/ui/parse-fail/nested-packages-colliding-names.wit.result +3 -0
  1882. data/rust-vendor/wit-parser/tests/ui/parse-fail/nested-packages-with-error.wit +14 -0
  1883. data/rust-vendor/wit-parser/tests/ui/parse-fail/nested-packages-with-error.wit.result +5 -0
  1884. data/rust-vendor/wit-parser/tests/ui/parse-fail/no-access-to-sibling-use/bar.wit +1 -0
  1885. data/rust-vendor/wit-parser/tests/ui/parse-fail/no-access-to-sibling-use/foo.wit +5 -0
  1886. data/rust-vendor/wit-parser/tests/ui/parse-fail/no-access-to-sibling-use.wit.result +5 -0
  1887. data/rust-vendor/wit-parser/tests/ui/parse-fail/non-existance-world-include/deps/bar/.gitkeep +0 -0
  1888. data/rust-vendor/wit-parser/tests/ui/parse-fail/non-existance-world-include/deps/bar/baz.wit +4 -0
  1889. data/rust-vendor/wit-parser/tests/ui/parse-fail/non-existance-world-include/root.wit +5 -0
  1890. data/rust-vendor/wit-parser/tests/ui/parse-fail/non-existance-world-include.wit.result +5 -0
  1891. data/rust-vendor/wit-parser/tests/ui/parse-fail/old-float-types.wit +5 -0
  1892. data/rust-vendor/wit-parser/tests/ui/parse-fail/old-float-types.wit.result +5 -0
  1893. data/rust-vendor/wit-parser/tests/ui/parse-fail/pkg-cycle/deps/a1/root.wit +4 -0
  1894. data/rust-vendor/wit-parser/tests/ui/parse-fail/pkg-cycle/root.wit +4 -0
  1895. data/rust-vendor/wit-parser/tests/ui/parse-fail/pkg-cycle.wit.result +5 -0
  1896. data/rust-vendor/wit-parser/tests/ui/parse-fail/pkg-cycle2/deps/a1/root.wit +4 -0
  1897. data/rust-vendor/wit-parser/tests/ui/parse-fail/pkg-cycle2/deps/a2/root.wit +4 -0
  1898. data/rust-vendor/wit-parser/tests/ui/parse-fail/pkg-cycle2/root.wit +4 -0
  1899. data/rust-vendor/wit-parser/tests/ui/parse-fail/pkg-cycle2.wit.result +5 -0
  1900. data/rust-vendor/wit-parser/tests/ui/parse-fail/resources-multiple-returns-borrow.wit +10 -0
  1901. data/rust-vendor/wit-parser/tests/ui/parse-fail/resources-multiple-returns-borrow.wit.result +5 -0
  1902. data/rust-vendor/wit-parser/tests/ui/parse-fail/resources-return-borrow.wit +10 -0
  1903. data/rust-vendor/wit-parser/tests/ui/parse-fail/resources-return-borrow.wit.result +5 -0
  1904. data/rust-vendor/wit-parser/tests/ui/parse-fail/return-borrow1.wit +7 -0
  1905. data/rust-vendor/wit-parser/tests/ui/parse-fail/return-borrow1.wit.result +5 -0
  1906. data/rust-vendor/wit-parser/tests/ui/parse-fail/return-borrow2.wit +8 -0
  1907. data/rust-vendor/wit-parser/tests/ui/parse-fail/return-borrow2.wit.result +5 -0
  1908. data/rust-vendor/wit-parser/tests/ui/parse-fail/return-borrow3.wit +7 -0
  1909. data/rust-vendor/wit-parser/tests/ui/parse-fail/return-borrow3.wit.result +5 -0
  1910. data/rust-vendor/wit-parser/tests/ui/parse-fail/return-borrow4.wit +7 -0
  1911. data/rust-vendor/wit-parser/tests/ui/parse-fail/return-borrow4.wit.result +5 -0
  1912. data/rust-vendor/wit-parser/tests/ui/parse-fail/return-borrow5.wit +7 -0
  1913. data/rust-vendor/wit-parser/tests/ui/parse-fail/return-borrow5.wit.result +5 -0
  1914. data/rust-vendor/wit-parser/tests/ui/parse-fail/return-borrow6.wit +7 -0
  1915. data/rust-vendor/wit-parser/tests/ui/parse-fail/return-borrow6.wit.result +5 -0
  1916. data/rust-vendor/wit-parser/tests/ui/parse-fail/return-borrow7.wit +11 -0
  1917. data/rust-vendor/wit-parser/tests/ui/parse-fail/return-borrow7.wit.result +5 -0
  1918. data/rust-vendor/wit-parser/tests/ui/parse-fail/return-borrow8/deps/baz.wit +9 -0
  1919. data/rust-vendor/wit-parser/tests/ui/parse-fail/return-borrow8/foo.wit +7 -0
  1920. data/rust-vendor/wit-parser/tests/ui/parse-fail/return-borrow8.wit.result +5 -0
  1921. data/rust-vendor/wit-parser/tests/ui/parse-fail/type-and-resource-same-name/deps/dep/foo.wit +5 -0
  1922. data/rust-vendor/wit-parser/tests/ui/parse-fail/type-and-resource-same-name/foo.wit +8 -0
  1923. data/rust-vendor/wit-parser/tests/ui/parse-fail/type-and-resource-same-name.wit.result +5 -0
  1924. data/rust-vendor/wit-parser/tests/ui/parse-fail/undefined-typed.wit +6 -0
  1925. data/rust-vendor/wit-parser/tests/ui/parse-fail/undefined-typed.wit.result +5 -0
  1926. data/rust-vendor/wit-parser/tests/ui/parse-fail/unknown-interface.wit +7 -0
  1927. data/rust-vendor/wit-parser/tests/ui/parse-fail/unknown-interface.wit.result +5 -0
  1928. data/rust-vendor/wit-parser/tests/ui/parse-fail/unresolved-interface1.wit +7 -0
  1929. data/rust-vendor/wit-parser/tests/ui/parse-fail/unresolved-interface1.wit.result +5 -0
  1930. data/rust-vendor/wit-parser/tests/ui/parse-fail/unresolved-interface2.wit +8 -0
  1931. data/rust-vendor/wit-parser/tests/ui/parse-fail/unresolved-interface2.wit.result +5 -0
  1932. data/rust-vendor/wit-parser/tests/ui/parse-fail/unresolved-interface3.wit +5 -0
  1933. data/rust-vendor/wit-parser/tests/ui/parse-fail/unresolved-interface3.wit.result +5 -0
  1934. data/rust-vendor/wit-parser/tests/ui/parse-fail/unresolved-interface4.wit +7 -0
  1935. data/rust-vendor/wit-parser/tests/ui/parse-fail/unresolved-interface4.wit.result +7 -0
  1936. data/rust-vendor/wit-parser/tests/ui/parse-fail/unresolved-use1.wit +7 -0
  1937. data/rust-vendor/wit-parser/tests/ui/parse-fail/unresolved-use1.wit.result +5 -0
  1938. data/rust-vendor/wit-parser/tests/ui/parse-fail/unresolved-use10/bar.wit +5 -0
  1939. data/rust-vendor/wit-parser/tests/ui/parse-fail/unresolved-use10/foo.wit +2 -0
  1940. data/rust-vendor/wit-parser/tests/ui/parse-fail/unresolved-use10.wit.result +5 -0
  1941. data/rust-vendor/wit-parser/tests/ui/parse-fail/unresolved-use2.wit +10 -0
  1942. data/rust-vendor/wit-parser/tests/ui/parse-fail/unresolved-use2.wit.result +5 -0
  1943. data/rust-vendor/wit-parser/tests/ui/parse-fail/unresolved-use3.wit +11 -0
  1944. data/rust-vendor/wit-parser/tests/ui/parse-fail/unresolved-use3.wit.result +5 -0
  1945. data/rust-vendor/wit-parser/tests/ui/parse-fail/unresolved-use7.wit +10 -0
  1946. data/rust-vendor/wit-parser/tests/ui/parse-fail/unresolved-use7.wit.result +5 -0
  1947. data/rust-vendor/wit-parser/tests/ui/parse-fail/unresolved-use8.wit +9 -0
  1948. data/rust-vendor/wit-parser/tests/ui/parse-fail/unresolved-use8.wit.result +5 -0
  1949. data/rust-vendor/wit-parser/tests/ui/parse-fail/unresolved-use9.wit +9 -0
  1950. data/rust-vendor/wit-parser/tests/ui/parse-fail/unresolved-use9.wit.result +5 -0
  1951. data/rust-vendor/wit-parser/tests/ui/parse-fail/unterminated-string.wit.result +5 -0
  1952. data/rust-vendor/wit-parser/tests/ui/parse-fail/use-and-include-world/deps/bar/.gitkeep +0 -0
  1953. data/rust-vendor/wit-parser/tests/ui/parse-fail/use-and-include-world/deps/bar/baz.wit +4 -0
  1954. data/rust-vendor/wit-parser/tests/ui/parse-fail/use-and-include-world/root.wit +7 -0
  1955. data/rust-vendor/wit-parser/tests/ui/parse-fail/use-and-include-world.wit.result +5 -0
  1956. data/rust-vendor/wit-parser/tests/ui/parse-fail/use-conflict.wit +11 -0
  1957. data/rust-vendor/wit-parser/tests/ui/parse-fail/use-conflict.wit.result +5 -0
  1958. data/rust-vendor/wit-parser/tests/ui/parse-fail/use-conflict2.wit +13 -0
  1959. data/rust-vendor/wit-parser/tests/ui/parse-fail/use-conflict2.wit.result +5 -0
  1960. data/rust-vendor/wit-parser/tests/ui/parse-fail/use-conflict3.wit +13 -0
  1961. data/rust-vendor/wit-parser/tests/ui/parse-fail/use-conflict3.wit.result +5 -0
  1962. data/rust-vendor/wit-parser/tests/ui/parse-fail/use-cycle1.wit +7 -0
  1963. data/rust-vendor/wit-parser/tests/ui/parse-fail/use-cycle1.wit.result +5 -0
  1964. data/rust-vendor/wit-parser/tests/ui/parse-fail/use-cycle4.wit +14 -0
  1965. data/rust-vendor/wit-parser/tests/ui/parse-fail/use-cycle4.wit.result +5 -0
  1966. data/rust-vendor/wit-parser/tests/ui/parse-fail/use-shadow1.wit +7 -0
  1967. data/rust-vendor/wit-parser/tests/ui/parse-fail/use-shadow1.wit.result +5 -0
  1968. data/rust-vendor/wit-parser/tests/ui/parse-fail/use-world/deps/bar/.gitkeep +0 -0
  1969. data/rust-vendor/wit-parser/tests/ui/parse-fail/use-world/deps/bar/baz.wit +4 -0
  1970. data/rust-vendor/wit-parser/tests/ui/parse-fail/use-world/root.wit +7 -0
  1971. data/rust-vendor/wit-parser/tests/ui/parse-fail/use-world.wit.result +5 -0
  1972. data/rust-vendor/wit-parser/tests/ui/parse-fail/very-nested-packages.wit +8 -0
  1973. data/rust-vendor/wit-parser/tests/ui/parse-fail/very-nested-packages.wit.result +5 -0
  1974. data/rust-vendor/wit-parser/tests/ui/parse-fail/world-interface-clash.wit +3 -0
  1975. data/rust-vendor/wit-parser/tests/ui/parse-fail/world-interface-clash.wit.result +5 -0
  1976. data/rust-vendor/wit-parser/tests/ui/parse-fail/world-same-fields2.wit +8 -0
  1977. data/rust-vendor/wit-parser/tests/ui/parse-fail/world-same-fields2.wit.result +5 -0
  1978. data/rust-vendor/wit-parser/tests/ui/parse-fail/world-same-fields3.wit +8 -0
  1979. data/rust-vendor/wit-parser/tests/ui/parse-fail/world-same-fields3.wit.result +5 -0
  1980. data/rust-vendor/wit-parser/tests/ui/parse-fail/world-top-level-func.wit +5 -0
  1981. data/rust-vendor/wit-parser/tests/ui/parse-fail/world-top-level-func.wit.result +5 -0
  1982. data/rust-vendor/wit-parser/tests/ui/parse-fail/world-top-level-func2.wit +4 -0
  1983. data/rust-vendor/wit-parser/tests/ui/parse-fail/world-top-level-func2.wit.result +5 -0
  1984. data/rust-vendor/wit-parser/tests/ui/random.wit +27 -0
  1985. data/rust-vendor/wit-parser/tests/ui/random.wit.json +56 -0
  1986. data/rust-vendor/wit-parser/tests/ui/resources-empty.wit +10 -0
  1987. data/rust-vendor/wit-parser/tests/ui/resources-empty.wit.json +70 -0
  1988. data/rust-vendor/wit-parser/tests/ui/resources-multiple-returns-own.wit +10 -0
  1989. data/rust-vendor/wit-parser/tests/ui/resources-multiple-returns-own.wit.json +85 -0
  1990. data/rust-vendor/wit-parser/tests/ui/resources-multiple.wit +17 -0
  1991. data/rust-vendor/wit-parser/tests/ui/resources-multiple.wit.json +207 -0
  1992. data/rust-vendor/wit-parser/tests/ui/resources-return-own.wit +10 -0
  1993. data/rust-vendor/wit-parser/tests/ui/resources-return-own.wit.json +73 -0
  1994. data/rust-vendor/wit-parser/tests/ui/resources.wit +55 -0
  1995. data/rust-vendor/wit-parser/tests/ui/resources.wit.json +387 -0
  1996. data/rust-vendor/wit-parser/tests/ui/resources1.wit +12 -0
  1997. data/rust-vendor/wit-parser/tests/ui/resources1.wit.json +92 -0
  1998. data/rust-vendor/wit-parser/tests/ui/same-name-import-export.wit +6 -0
  1999. data/rust-vendor/wit-parser/tests/ui/same-name-import-export.wit.json +39 -0
  2000. data/rust-vendor/wit-parser/tests/ui/shared-types.wit +10 -0
  2001. data/rust-vendor/wit-parser/tests/ui/shared-types.wit.json +79 -0
  2002. data/rust-vendor/wit-parser/tests/ui/simple-wasm-text.wat +6 -0
  2003. data/rust-vendor/wit-parser/tests/ui/simple-wasm-text.wit.json +21 -0
  2004. data/rust-vendor/wit-parser/tests/ui/since-and-unstable.wit +107 -0
  2005. data/rust-vendor/wit-parser/tests/ui/since-and-unstable.wit.json +608 -0
  2006. data/rust-vendor/wit-parser/tests/ui/streams-and-futures.wit +15 -0
  2007. data/rust-vendor/wit-parser/tests/ui/streams-and-futures.wit.json +205 -0
  2008. data/rust-vendor/wit-parser/tests/ui/stress-export-elaborate.wit +54 -0
  2009. data/rust-vendor/wit-parser/tests/ui/stress-export-elaborate.wit.json +1156 -0
  2010. data/rust-vendor/wit-parser/tests/ui/type-then-eof.wit +5 -0
  2011. data/rust-vendor/wit-parser/tests/ui/type-then-eof.wit.json +28 -0
  2012. data/rust-vendor/wit-parser/tests/ui/types.wit +59 -0
  2013. data/rust-vendor/wit-parser/tests/ui/types.wit.json +768 -0
  2014. data/rust-vendor/wit-parser/tests/ui/union-fuzz-1.wit +9 -0
  2015. data/rust-vendor/wit-parser/tests/ui/union-fuzz-1.wit.json +35 -0
  2016. data/rust-vendor/wit-parser/tests/ui/union-fuzz-2.wit +12 -0
  2017. data/rust-vendor/wit-parser/tests/ui/union-fuzz-2.wit.json +62 -0
  2018. data/rust-vendor/wit-parser/tests/ui/unstable-resource.wit +17 -0
  2019. data/rust-vendor/wit-parser/tests/ui/unstable-resource.wit.json +44 -0
  2020. data/rust-vendor/wit-parser/tests/ui/use-chain.wit +11 -0
  2021. data/rust-vendor/wit-parser/tests/ui/use-chain.wit.json +53 -0
  2022. data/rust-vendor/wit-parser/tests/ui/use.wit +34 -0
  2023. data/rust-vendor/wit-parser/tests/ui/use.wit.json +168 -0
  2024. data/rust-vendor/wit-parser/tests/ui/version-syntax.wit +10 -0
  2025. data/rust-vendor/wit-parser/tests/ui/version-syntax.wit.json +57 -0
  2026. data/rust-vendor/wit-parser/tests/ui/versions/deps/a1/foo.wit +5 -0
  2027. data/rust-vendor/wit-parser/tests/ui/versions/deps/a2/foo.wit +5 -0
  2028. data/rust-vendor/wit-parser/tests/ui/versions/foo.wit +7 -0
  2029. data/rust-vendor/wit-parser/tests/ui/versions.wit.json +91 -0
  2030. data/rust-vendor/wit-parser/tests/ui/wasi.wit +178 -0
  2031. data/rust-vendor/wit-parser/tests/ui/wasi.wit.json +539 -0
  2032. data/rust-vendor/wit-parser/tests/ui/with-resource-as.wit +15 -0
  2033. data/rust-vendor/wit-parser/tests/ui/with-resource-as.wit.json +221 -0
  2034. data/rust-vendor/wit-parser/tests/ui/world-diamond.wit +23 -0
  2035. data/rust-vendor/wit-parser/tests/ui/world-diamond.wit.json +115 -0
  2036. data/rust-vendor/wit-parser/tests/ui/world-iface-no-collide.wit +11 -0
  2037. data/rust-vendor/wit-parser/tests/ui/world-iface-no-collide.wit.json +67 -0
  2038. data/rust-vendor/wit-parser/tests/ui/world-implicit-import1.wit +12 -0
  2039. data/rust-vendor/wit-parser/tests/ui/world-implicit-import1.wit.json +81 -0
  2040. data/rust-vendor/wit-parser/tests/ui/world-implicit-import2.wit +11 -0
  2041. data/rust-vendor/wit-parser/tests/ui/world-implicit-import2.wit.json +68 -0
  2042. data/rust-vendor/wit-parser/tests/ui/world-implicit-import3.wit +11 -0
  2043. data/rust-vendor/wit-parser/tests/ui/world-implicit-import3.wit.json +69 -0
  2044. data/rust-vendor/wit-parser/tests/ui/world-same-fields4.wit +13 -0
  2045. data/rust-vendor/wit-parser/tests/ui/world-same-fields4.wit.json +82 -0
  2046. data/rust-vendor/wit-parser/tests/ui/world-top-level-funcs.wit +9 -0
  2047. data/rust-vendor/wit-parser/tests/ui/world-top-level-funcs.wit.json +79 -0
  2048. data/rust-vendor/wit-parser/tests/ui/world-top-level-resources.wit +24 -0
  2049. data/rust-vendor/wit-parser/tests/ui/world-top-level-resources.wit.json +225 -0
  2050. data/rust-vendor/wit-parser/tests/ui/worlds-union-dedup.wit +23 -0
  2051. data/rust-vendor/wit-parser/tests/ui/worlds-union-dedup.wit.json +112 -0
  2052. data/rust-vendor/wit-parser/tests/ui/worlds-with-types.wit +34 -0
  2053. data/rust-vendor/wit-parser/tests/ui/worlds-with-types.wit.json +188 -0
  2054. data/rust-vendor/zerocopy/.cargo-checksum.json +1 -1
  2055. data/rust-vendor/zerocopy/.cargo_vcs_info.json +1 -2
  2056. data/rust-vendor/zerocopy/Cargo.lock +3 -3
  2057. data/rust-vendor/zerocopy/Cargo.toml +4 -4
  2058. data/rust-vendor/zerocopy/Cargo.toml.orig +4 -4
  2059. data/rust-vendor/zerocopy/agent_docs/reviewing.md +8 -0
  2060. data/rust-vendor/zerocopy/build.rs +1 -0
  2061. data/rust-vendor/zerocopy/ci/release_crate_version.sh +3 -0
  2062. data/rust-vendor/zerocopy/src/doctests.rs +18 -2
  2063. data/rust-vendor/zerocopy/src/impls.rs +7 -4
  2064. data/rust-vendor/zerocopy/src/lib.rs +60 -28
  2065. data/rust-vendor/zerocopy/src/macros.rs +24 -4
  2066. data/rust-vendor/zerocopy/src/pointer/invariant.rs +31 -3
  2067. data/rust-vendor/zerocopy/src/pointer/mod.rs +2 -2
  2068. data/rust-vendor/zerocopy/src/pointer/ptr.rs +3 -3
  2069. data/rust-vendor/zerocopy/src/util/macros.rs +21 -6
  2070. data/rust-vendor/zerocopy/tests/trybuild.rs +3 -18
  2071. data/rust-vendor/zerocopy-derive/.cargo-checksum.json +1 -1
  2072. data/rust-vendor/zerocopy-derive/.cargo_vcs_info.json +1 -1
  2073. data/rust-vendor/zerocopy-derive/Cargo.lock +1 -1
  2074. data/rust-vendor/zerocopy-derive/Cargo.toml +9 -2
  2075. data/rust-vendor/zerocopy-derive/Cargo.toml.orig +5 -2
  2076. data/rust-vendor/zerocopy-derive/src/derive/from_bytes.rs +9 -7
  2077. data/rust-vendor/zerocopy-derive/src/derive/into_bytes.rs +8 -4
  2078. data/rust-vendor/zerocopy-derive/src/derive/try_from_bytes.rs +52 -18
  2079. data/rust-vendor/zerocopy-derive/src/derive/unaligned.rs +3 -3
  2080. data/rust-vendor/zerocopy-derive/src/output_tests/expected/from_bytes_enum.expected.rs +7 -3
  2081. data/rust-vendor/zerocopy-derive/src/output_tests/expected/from_bytes_struct.expected.rs +7 -3
  2082. data/rust-vendor/zerocopy-derive/src/output_tests/expected/from_bytes_union.expected.rs +7 -3
  2083. data/rust-vendor/zerocopy-derive/src/output_tests/expected/from_zeros.expected.rs +7 -3
  2084. data/rust-vendor/zerocopy-derive/src/output_tests/expected/try_from_bytes.expected.rs +7 -3
  2085. data/rust-vendor/zerocopy-derive/src/output_tests/expected/try_from_bytes_enum_1.expected.rs +22 -10
  2086. data/rust-vendor/zerocopy-derive/src/output_tests/expected/try_from_bytes_enum_2.expected.rs +22 -10
  2087. data/rust-vendor/zerocopy-derive/src/output_tests/expected/try_from_bytes_enum_3.expected.rs +22 -10
  2088. data/rust-vendor/zerocopy-derive/src/output_tests/expected/try_from_bytes_trivial_is_bit_valid_enum.expected.rs +7 -3
  2089. data/rust-vendor/zerocopy-derive/src/util.rs +72 -5
  2090. data/rust-vendor/zerocopy-derive/tests/on_error.rs +169 -0
  2091. data/rust-vendor/zerocopy-derive/tests/trybuild.rs +9 -7
  2092. data/rust-vendor/zerocopy-derive/tests/ui-msrv/cfgs/on_error.rs +19 -0
  2093. data/rust-vendor/zerocopy-derive/tests/ui-msrv/cfgs/on_error.stderr +16 -0
  2094. data/rust-vendor/zerocopy-derive/tests/ui-msrv/{union_into_bytes_cfg → cfgs}/union_into_bytes_cfg.stderr +1 -1
  2095. data/rust-vendor/zerocopy-derive/tests/ui-nightly/cfgs/on_error.rs +19 -0
  2096. data/rust-vendor/zerocopy-derive/tests/ui-nightly/cfgs/on_error.stderr +31 -0
  2097. data/rust-vendor/zerocopy-derive/tests/ui-nightly/cfgs/union_into_bytes_cfg.stderr +8 -0
  2098. data/rust-vendor/zerocopy-derive/tests/ui-nightly/union.stderr +0 -14
  2099. data/rust-vendor/zerocopy-derive/tests/ui-stable/cfgs/on_error.rs +19 -0
  2100. data/rust-vendor/zerocopy-derive/tests/ui-stable/cfgs/on_error.stderr +27 -0
  2101. data/rust-vendor/zerocopy-derive/tests/ui-stable/cfgs/union_into_bytes_cfg.stderr +8 -0
  2102. data/rust-vendor/zerocopy-derive/tests/ui-stable/union.stderr +0 -14
  2103. data/rust-vendor/zmij/.cargo-checksum.json +1 -1
  2104. data/rust-vendor/zmij/.cargo_vcs_info.json +1 -1
  2105. data/rust-vendor/zmij/.github/workflows/ci.yml +9 -6
  2106. data/rust-vendor/zmij/Cargo.lock +281 -58
  2107. data/rust-vendor/zmij/Cargo.toml +3 -3
  2108. data/rust-vendor/zmij/Cargo.toml.orig +3 -3
  2109. data/rust-vendor/zmij/README.md +1 -1
  2110. data/rust-vendor/zmij/src/lib.rs +124 -79
  2111. data/rust-vendor/zmij/src/tests.rs +11 -5
  2112. data/rust-vendor/zmij/tests/ryu_comparison.rs +3 -3
  2113. metadata +1841 -55
  2114. data/rust-vendor/libc/src/qurt/hexagon.rs +0 -340
  2115. data/rust-vendor/regex/.vim/coc-settings.json +0 -6
  2116. data/rust-vendor/regex/Cross.toml +0 -7
  2117. data/rust-vendor/regex/rustfmt.toml +0 -2
  2118. data/rust-vendor/regex/test +0 -46
  2119. data/rust-vendor/regex/testdata/README.md +0 -22
  2120. data/rust-vendor/regex/testdata/fowler/basic.toml +0 -1611
  2121. data/rust-vendor/regex/testdata/fowler/dat/README +0 -25
  2122. data/rust-vendor/regex/testdata/fowler/dat/basic.dat +0 -223
  2123. data/rust-vendor/regex/testdata/fowler/dat/nullsubexpr.dat +0 -74
  2124. data/rust-vendor/regex/testdata/fowler/dat/repetition.dat +0 -169
  2125. data/rust-vendor/regex/testdata/fowler/nullsubexpr.toml +0 -405
  2126. data/rust-vendor/regex/testdata/fowler/repetition.toml +0 -746
  2127. data/rust-vendor/regex-automata/test +0 -95
  2128. data/rust-vendor/regex-automata/tests/fuzz/mod.rs +0 -2
  2129. data/rust-vendor/regex-automata/tests/fuzz/testdata/deserialize_dense_crash-9486fb7c8a93b12c12a62166b43d31640c0208a9 +0 -0
  2130. data/rust-vendor/regex-automata/tests/fuzz/testdata/deserialize_dense_minimized-from-9486fb7c8a93b12c12a62166b43d31640c0208a9 +0 -0
  2131. data/rust-vendor/regex-automata/tests/fuzz/testdata/deserialize_sparse_crash-0da59c0434eaf35e5a6b470fa9244bb79c72b000 +0 -0
  2132. data/rust-vendor/regex-automata/tests/fuzz/testdata/deserialize_sparse_crash-18cfc246f2ddfc3dfc92b0c7893178c7cf65efa9 +0 -0
  2133. data/rust-vendor/regex-automata/tests/fuzz/testdata/deserialize_sparse_crash-61fd8e3003bf9d99f6c1e5a8488727eefd234b98 +0 -0
  2134. data/rust-vendor/regex-automata/tests/fuzz/testdata/deserialize_sparse_crash-a1b839d899ced76d5d7d0f78f9edb7a421505838 +0 -0
  2135. data/rust-vendor/regex-automata/tests/fuzz/testdata/deserialize_sparse_crash-c383ae07ec5e191422eadc492117439011816570 +0 -0
  2136. data/rust-vendor/regex-automata/tests/fuzz/testdata/deserialize_sparse_crash-d07703ceb94b10dcd9e4acb809f2051420449e2b +0 -0
  2137. data/rust-vendor/regex-automata/tests/fuzz/testdata/deserialize_sparse_crash-dbb8172d3984e7e7d03f4b5f8bb86ecd1460eff9 +0 -0
  2138. data/rust-vendor/regex-automata/tests/gen/README.md +0 -65
  2139. data/rust-vendor/regex-automata/tests/gen/dense/multi_pattern_v2_fwd.bigendian.dfa +0 -0
  2140. data/rust-vendor/regex-automata/tests/gen/dense/multi_pattern_v2_fwd.littleendian.dfa +0 -0
  2141. data/rust-vendor/regex-automata/tests/gen/dense/multi_pattern_v2_rev.bigendian.dfa +0 -0
  2142. data/rust-vendor/regex-automata/tests/gen/dense/multi_pattern_v2_rev.littleendian.dfa +0 -0
  2143. data/rust-vendor/regex-automata/tests/gen/sparse/multi_pattern_v2_fwd.bigendian.dfa +0 -0
  2144. data/rust-vendor/regex-automata/tests/gen/sparse/multi_pattern_v2_fwd.littleendian.dfa +0 -0
  2145. data/rust-vendor/regex-automata/tests/gen/sparse/multi_pattern_v2_rev.bigendian.dfa +0 -0
  2146. data/rust-vendor/regex-automata/tests/gen/sparse/multi_pattern_v2_rev.littleendian.dfa +0 -0
  2147. data/rust-vendor/regex-syntax/benches/bench.rs +0 -63
  2148. data/rust-vendor/regex-syntax/test +0 -30
  2149. data/rust-vendor/zerocopy/tests/ui-msrv/invalid-impls/invalid-impls.rs +0 -31
  2150. data/rust-vendor/zerocopy/tests/ui-msrv/invalid-impls/invalid-impls.stderr +0 -159
  2151. data/rust-vendor/zerocopy/tests/ui-nightly/invalid-impls/invalid-impls.rs +0 -31
  2152. data/rust-vendor/zerocopy/tests/ui-nightly/invalid-impls/invalid-impls.stderr +0 -139
  2153. data/rust-vendor/zerocopy/tests/ui-stable/invalid-impls/invalid-impls.rs +0 -31
  2154. data/rust-vendor/zerocopy/tests/ui-stable/invalid-impls/invalid-impls.stderr +0 -155
  2155. data/rust-vendor/zerocopy-derive/tests/ui-nightly/union_into_bytes_cfg/union_into_bytes_cfg.stderr +0 -22
  2156. data/rust-vendor/zerocopy-derive/tests/ui-stable/union_into_bytes_cfg/union_into_bytes_cfg.stderr +0 -22
  2157. /data/rust-vendor/{getrandom → getrandom-0.3.4}/src/backends/sanitizer.rs +0 -0
  2158. /data/rust-vendor/{getrandom → getrandom-0.3.4}/src/backends/wasi_p2.rs +0 -0
  2159. /data/rust-vendor/{getrandom → getrandom-0.3.4}/src/lazy.rs +0 -0
  2160. /data/rust-vendor/{getrandom → getrandom-0.3.4}/src/util_libc.rs +0 -0
  2161. /data/rust-vendor/{wit-bindgen → wit-bindgen-0.46.0}/src/rt/wit_bindgen_cabi.c +0 -0
  2162. /data/rust-vendor/{wit-bindgen → wit-bindgen-0.46.0}/src/rt/wit_bindgen_cabi.o +0 -0
  2163. /data/rust-vendor/zerocopy-derive/tests/ui-msrv/{union_into_bytes_cfg → cfgs}/union_into_bytes_cfg.rs +0 -0
  2164. /data/rust-vendor/zerocopy-derive/tests/ui-nightly/{union_into_bytes_cfg → cfgs}/union_into_bytes_cfg.rs +0 -0
  2165. /data/rust-vendor/zerocopy-derive/tests/ui-stable/{union_into_bytes_cfg → cfgs}/union_into_bytes_cfg.rs +0 -0
@@ -0,0 +1,4765 @@
1
+ //! State relating to validating a WebAssembly component.
2
+
3
+ use super::{
4
+ check_max,
5
+ component_types::{
6
+ Abi, AliasableResourceId, ComponentAnyTypeId, ComponentCoreInstanceTypeId,
7
+ ComponentCoreModuleTypeId, ComponentCoreTypeId, ComponentDefinedType,
8
+ ComponentDefinedTypeId, ComponentEntityType, ComponentFuncType, ComponentFuncTypeId,
9
+ ComponentInstanceType, ComponentInstanceTypeId, ComponentType, ComponentTypeId,
10
+ ComponentValType, Context, CoreInstanceTypeKind, InstanceType, ModuleType, RecordType,
11
+ Remap, Remapping, ResourceId, SubtypeCx, TupleType, VariantCase, VariantType,
12
+ },
13
+ core::{InternRecGroup, Module},
14
+ types::{CoreTypeId, EntityType, TypeAlloc, TypeInfo, TypeList},
15
+ };
16
+ use crate::collections::index_map::Entry;
17
+ use crate::limits::*;
18
+ use crate::prelude::*;
19
+ use crate::validator::names::{ComponentName, ComponentNameKind, KebabStr, KebabString};
20
+ use crate::{
21
+ BinaryReaderError, CanonicalFunction, CanonicalOption, ComponentExportName,
22
+ ComponentExternalKind, ComponentOuterAliasKind, ComponentTypeRef, CompositeInnerType,
23
+ ExternalKind, FuncType, GlobalType, InstantiationArgKind, MemoryType, PackedIndex, RefType,
24
+ Result, SubType, TableType, TypeBounds, ValType, WasmFeatures,
25
+ };
26
+ use core::mem;
27
+
28
+ fn to_kebab_str<'a>(s: &'a str, desc: &str, offset: usize) -> Result<&'a KebabStr> {
29
+ match KebabStr::new(s) {
30
+ Some(s) => Ok(s),
31
+ None => {
32
+ if s.is_empty() {
33
+ bail!(offset, "{desc} name cannot be empty");
34
+ }
35
+
36
+ bail!(offset, "{desc} name `{s}` is not in kebab case");
37
+ }
38
+ }
39
+ }
40
+
41
+ pub(crate) struct ComponentState {
42
+ /// Whether this state is a concrete component, an instance type, or a
43
+ /// component type.
44
+ kind: ComponentKind,
45
+ features: WasmFeatures,
46
+
47
+ // Core index spaces
48
+ pub core_types: Vec<ComponentCoreTypeId>,
49
+ pub core_funcs: Vec<CoreTypeId>,
50
+ pub core_tags: Vec<CoreTypeId>,
51
+ pub core_modules: Vec<ComponentCoreModuleTypeId>,
52
+ pub core_instances: Vec<ComponentCoreInstanceTypeId>,
53
+ pub core_memories: Vec<MemoryType>,
54
+ pub core_tables: Vec<TableType>,
55
+ pub core_globals: Vec<GlobalType>,
56
+
57
+ // Component index spaces
58
+ pub types: Vec<ComponentAnyTypeId>,
59
+ pub funcs: Vec<ComponentFuncTypeId>,
60
+ pub values: Vec<(ComponentValType, bool)>,
61
+ pub instances: Vec<ComponentInstanceTypeId>,
62
+ pub components: Vec<ComponentTypeId>,
63
+
64
+ pub imports: IndexMap<String, ComponentEntityType>,
65
+ pub import_names: IndexSet<ComponentName>,
66
+ pub exports: IndexMap<String, ComponentEntityType>,
67
+ pub export_names: IndexSet<ComponentName>,
68
+
69
+ has_start: bool,
70
+ type_info: TypeInfo,
71
+
72
+ /// A mapping of imported resources in this component.
73
+ ///
74
+ /// This mapping represents all "type variables" imported into the
75
+ /// component, or resources. This could be resources imported directly as
76
+ /// a top-level type import or additionally transitively through other
77
+ /// imported instances.
78
+ ///
79
+ /// The mapping element here is a "path" which is a list of indexes into
80
+ /// the import map that will be generated for this component. Each index
81
+ /// is an index into an `IndexMap`, and each list is guaranteed to have at
82
+ /// least one element.
83
+ ///
84
+ /// An example of this map is:
85
+ ///
86
+ /// ```wasm
87
+ /// (component
88
+ /// ;; [0] - the first import
89
+ /// (import "r" (type (sub resource)))
90
+ ///
91
+ /// ;; [1] - the second import
92
+ /// (import "r2" (type (sub resource)))
93
+ ///
94
+ /// (import "i" (instance
95
+ /// ;; [2, 0] - the third import, and the first export the instance
96
+ /// (export "r3" (type (sub resource)))
97
+ /// ;; [2, 1] - the third import, and the second export the instance
98
+ /// (export "r4" (type (sub resource)))
99
+ /// ))
100
+ ///
101
+ /// ;; ...
102
+ /// )
103
+ /// ```
104
+ ///
105
+ /// The `Vec<usize>` here can be thought of as `Vec<String>` but a
106
+ /// (hopefully) more efficient representation.
107
+ ///
108
+ /// Finally note that this map is listed as an "append only" map because all
109
+ /// insertions into it should always succeed. Any insertion which overlaps
110
+ /// with a previous entry indicates a bug in the validator which needs to be
111
+ /// corrected via other means.
112
+ //
113
+ // TODO: make these `SkolemResourceId` and then go fix all the compile
114
+ // errors, don't add skolem things into the type area
115
+ imported_resources: IndexMapAppendOnly<ResourceId, Vec<usize>>,
116
+
117
+ /// A mapping of "defined" resources in this component, or those which
118
+ /// are defined within the instantiation of this component.
119
+ ///
120
+ /// Defined resources, as the name implies, can sort of be thought of as
121
+ /// "these are defined within the component". Note though that the means by
122
+ /// which a local definition can occur are not simply those defined in the
123
+ /// component but also in its transitively instantiated components
124
+ /// internally. This means that this set closes over many transitive
125
+ /// internal items in addition to those defined immediately in the component
126
+ /// itself.
127
+ ///
128
+ /// The `Option<ValType>` in this mapping is whether or not the underlying
129
+ /// representation of the resource is known to this component. Immediately
130
+ /// defined resources, for example, will have `Some(I32)` here. Resources
131
+ /// that come from transitively defined components, for example, will have
132
+ /// `None`. In the type context all entries here are `None`.
133
+ ///
134
+ /// Note that like `imported_resources` all insertions into this map are
135
+ /// expected to succeed to it's declared as append-only.
136
+ defined_resources: IndexMapAppendOnly<ResourceId, Option<ValType>>,
137
+
138
+ /// A mapping of explicitly exported resources from this component in
139
+ /// addition to the path that they're exported at.
140
+ ///
141
+ /// For more information on the path here see the documentation for
142
+ /// `imported_resources`. Note that the indexes here index into the
143
+ /// list of exports of this component.
144
+ explicit_resources: IndexMap<ResourceId, Vec<usize>>,
145
+
146
+ /// The set of types which are considered "exported" from this component.
147
+ ///
148
+ /// This is added to whenever a type export is found, or an instance export
149
+ /// which itself contains a type export. This additionally includes all
150
+ /// imported types since those are suitable for export as well.
151
+ ///
152
+ /// This set is consulted whenever an exported item is added since all
153
+ /// referenced types must be members of this set.
154
+ exported_types: Set<ComponentAnyTypeId>,
155
+
156
+ /// Same as `exported_types`, but for imports.
157
+ imported_types: Set<ComponentAnyTypeId>,
158
+
159
+ /// The set of top-level resource exports and their names.
160
+ ///
161
+ /// This context is used to validate method names such as `[method]foo.bar`
162
+ /// to ensure that `foo` is an exported resource and that the type mentioned
163
+ /// in a function type is actually named `foo`.
164
+ ///
165
+ /// Note that imports/exports have disjoint contexts to ensure that they're
166
+ /// validated correctly. Namely you can't retroactively attach methods to an
167
+ /// import, for example.
168
+ toplevel_exported_resources: ComponentNameContext,
169
+
170
+ /// Same as `toplevel_exported_resources`, but for imports.
171
+ toplevel_imported_resources: ComponentNameContext,
172
+ }
173
+
174
+ #[derive(Copy, Clone, Debug, PartialEq, Eq)]
175
+ pub enum ComponentKind {
176
+ Component,
177
+ InstanceType,
178
+ ComponentType,
179
+ }
180
+
181
+ /// Helper context used to track information about resource names for method
182
+ /// name validation.
183
+ #[derive(Default)]
184
+ struct ComponentNameContext {
185
+ /// A map from a resource type id to an index in the `all_resource_names`
186
+ /// set for the name of that resource.
187
+ resource_name_map: Map<AliasableResourceId, usize>,
188
+
189
+ /// All known resource names in this context, used to validate static method
190
+ /// names to by ensuring that static methods' resource names are somewhere
191
+ /// in this set.
192
+ all_resource_names: IndexSet<String>,
193
+ }
194
+
195
+ #[derive(Debug, Copy, Clone)]
196
+ pub enum ExternKind {
197
+ Import,
198
+ Export,
199
+ }
200
+
201
+ impl ExternKind {
202
+ pub fn desc(&self) -> &'static str {
203
+ match self {
204
+ ExternKind::Import => "import",
205
+ ExternKind::Export => "export",
206
+ }
207
+ }
208
+ }
209
+
210
+ #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
211
+ pub(crate) enum StringEncoding {
212
+ #[default]
213
+ Utf8,
214
+ Utf16,
215
+ CompactUtf16,
216
+ }
217
+
218
+ impl core::fmt::Display for StringEncoding {
219
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
220
+ f.write_str(match self {
221
+ Self::Utf8 => "utf8",
222
+ Self::Utf16 => "utf16",
223
+ Self::CompactUtf16 => "latin1-utf16",
224
+ })
225
+ }
226
+ }
227
+
228
+ #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
229
+ pub(crate) enum Concurrency {
230
+ /// Synchronous.
231
+ #[default]
232
+ Sync,
233
+
234
+ /// Asynchronous.
235
+ Async {
236
+ /// When present, this is the function index of the async callback. When
237
+ /// omitted, we are either using stack-switching based asynchrony or are
238
+ /// in an operation that does not support the `callback` option (like
239
+ /// lowering).
240
+ callback: Option<u32>,
241
+ },
242
+ }
243
+
244
+ impl Concurrency {
245
+ pub(crate) fn is_sync(&self) -> bool {
246
+ matches!(self, Self::Sync)
247
+ }
248
+
249
+ pub(crate) fn is_async(&self) -> bool {
250
+ !self.is_sync()
251
+ }
252
+ }
253
+
254
+ #[derive(Clone, Copy)]
255
+ pub(crate) struct CanonicalOptions {
256
+ pub(crate) string_encoding: StringEncoding,
257
+ pub(crate) memory: Option<u32>,
258
+ pub(crate) realloc: Option<u32>,
259
+ pub(crate) post_return: Option<u32>,
260
+ pub(crate) concurrency: Concurrency,
261
+ pub(crate) core_type: Option<CoreTypeId>,
262
+ pub(crate) gc: bool,
263
+ }
264
+
265
+ impl CanonicalOptions {
266
+ pub(crate) fn require_sync(&self, offset: usize, where_: &str) -> Result<&Self> {
267
+ if !self.concurrency.is_sync() {
268
+ bail!(offset, "cannot specify `async` option on `{where_}`")
269
+ }
270
+ Ok(self)
271
+ }
272
+
273
+ pub(crate) fn require_memory(&self, offset: usize) -> Result<&Self> {
274
+ if self.memory.is_none() {
275
+ bail!(offset, "canonical option `memory` is required");
276
+ }
277
+ Ok(self)
278
+ }
279
+
280
+ pub(crate) fn require_realloc(&self, offset: usize) -> Result<&Self> {
281
+ // Memory is always required when `realloc` is required.
282
+ self.require_memory(offset)?;
283
+
284
+ if self.realloc.is_none() {
285
+ bail!(offset, "canonical option `realloc` is required")
286
+ }
287
+
288
+ Ok(self)
289
+ }
290
+
291
+ pub(crate) fn require_memory_if(
292
+ &self,
293
+ offset: usize,
294
+ when: impl Fn() -> bool,
295
+ ) -> Result<&Self> {
296
+ if self.memory.is_none() && when() {
297
+ self.require_memory(offset)?;
298
+ }
299
+ Ok(self)
300
+ }
301
+
302
+ pub(crate) fn require_realloc_if(
303
+ &self,
304
+ offset: usize,
305
+ when: impl Fn() -> bool,
306
+ ) -> Result<&Self> {
307
+ if self.realloc.is_none() && when() {
308
+ self.require_realloc(offset)?;
309
+ }
310
+ Ok(self)
311
+ }
312
+
313
+ pub(crate) fn check_lower(&self, offset: usize) -> Result<&Self> {
314
+ if self.post_return.is_some() {
315
+ bail!(
316
+ offset,
317
+ "canonical option `post-return` cannot be specified for lowerings"
318
+ );
319
+ }
320
+
321
+ if let Concurrency::Async { callback: Some(_) } = self.concurrency {
322
+ bail!(
323
+ offset,
324
+ "canonical option `callback` cannot be specified for lowerings"
325
+ );
326
+ }
327
+
328
+ if self.gc && self.core_type.is_none() {
329
+ bail!(
330
+ offset,
331
+ "cannot specify `gc` without also specifying a `core-type` for lowerings"
332
+ )
333
+ }
334
+
335
+ Ok(self)
336
+ }
337
+
338
+ pub(crate) fn check_lift(
339
+ &mut self,
340
+ types: &TypeList,
341
+ state: &ComponentState,
342
+ core_ty_id: CoreTypeId,
343
+ offset: usize,
344
+ ) -> Result<&Self> {
345
+ debug_assert!(matches!(
346
+ types[core_ty_id].composite_type.inner,
347
+ CompositeInnerType::Func(_)
348
+ ));
349
+
350
+ if let Some(idx) = self.post_return {
351
+ let post_return_func_ty = types[state.core_function_at(idx, offset)?].unwrap_func();
352
+ let core_ty = types[core_ty_id].unwrap_func();
353
+ if post_return_func_ty.params() != core_ty.results()
354
+ || !post_return_func_ty.results().is_empty()
355
+ {
356
+ bail!(
357
+ offset,
358
+ "canonical option `post-return` uses a core function with an incorrect signature"
359
+ );
360
+ }
361
+ }
362
+
363
+ match self.concurrency {
364
+ Concurrency::Sync => {}
365
+
366
+ Concurrency::Async { callback: None } if !state.features.cm_async_stackful() => {
367
+ bail!(
368
+ offset,
369
+ "requires the component model async stackful feature"
370
+ )
371
+ }
372
+ Concurrency::Async { callback: None } => {}
373
+
374
+ Concurrency::Async {
375
+ callback: Some(idx),
376
+ } => {
377
+ let func_ty = types[state.core_function_at(idx, offset)?].unwrap_func();
378
+ if func_ty.params() != [ValType::I32; 3] && func_ty.params() != [ValType::I32] {
379
+ return Err(BinaryReaderError::new(
380
+ "canonical option `callback` uses a core function with an incorrect signature",
381
+ offset,
382
+ ));
383
+ }
384
+ }
385
+ }
386
+
387
+ if self.core_type.is_some() {
388
+ bail!(
389
+ offset,
390
+ "canonical option `core-type` is not allowed in `canon lift`"
391
+ )
392
+ }
393
+ self.core_type = Some(core_ty_id);
394
+
395
+ Ok(self)
396
+ }
397
+
398
+ pub(crate) fn check_core_type(
399
+ &self,
400
+ types: &mut TypeAlloc,
401
+ actual: FuncType,
402
+ offset: usize,
403
+ ) -> Result<CoreTypeId> {
404
+ if let Some(declared_id) = self.core_type {
405
+ let declared = types[declared_id].unwrap_func();
406
+
407
+ if actual.params() != declared.params() {
408
+ bail!(
409
+ offset,
410
+ "declared core type has `{:?}` parameter types, but actual lowering has \
411
+ `{:?}` parameter types",
412
+ declared.params(),
413
+ actual.params(),
414
+ );
415
+ }
416
+
417
+ if actual.results() != declared.results() {
418
+ bail!(
419
+ offset,
420
+ "declared core type has `{:?}` result types, but actual lowering has \
421
+ `{:?}` result types",
422
+ declared.results(),
423
+ actual.results(),
424
+ );
425
+ }
426
+
427
+ Ok(declared_id)
428
+ } else {
429
+ Ok(types.intern_func_type(actual, offset))
430
+ }
431
+ }
432
+ }
433
+
434
+ impl ComponentState {
435
+ pub fn new(kind: ComponentKind, features: WasmFeatures) -> Self {
436
+ Self {
437
+ kind,
438
+ features,
439
+ core_types: Default::default(),
440
+ core_modules: Default::default(),
441
+ core_instances: Default::default(),
442
+ core_funcs: Default::default(),
443
+ core_memories: Default::default(),
444
+ core_tables: Default::default(),
445
+ core_globals: Default::default(),
446
+ core_tags: Default::default(),
447
+ types: Default::default(),
448
+ funcs: Default::default(),
449
+ values: Default::default(),
450
+ instances: Default::default(),
451
+ components: Default::default(),
452
+ imports: Default::default(),
453
+ exports: Default::default(),
454
+ import_names: Default::default(),
455
+ export_names: Default::default(),
456
+ has_start: Default::default(),
457
+ type_info: TypeInfo::new(),
458
+ imported_resources: Default::default(),
459
+ defined_resources: Default::default(),
460
+ explicit_resources: Default::default(),
461
+ exported_types: Default::default(),
462
+ imported_types: Default::default(),
463
+ toplevel_exported_resources: Default::default(),
464
+ toplevel_imported_resources: Default::default(),
465
+ }
466
+ }
467
+
468
+ pub fn type_count(&self) -> usize {
469
+ self.core_types.len() + self.types.len()
470
+ }
471
+
472
+ pub fn instance_count(&self) -> usize {
473
+ self.core_instances.len() + self.instances.len()
474
+ }
475
+
476
+ pub fn function_count(&self) -> usize {
477
+ self.core_funcs.len() + self.funcs.len()
478
+ }
479
+
480
+ pub fn add_core_type(
481
+ components: &mut [Self],
482
+ ty: crate::CoreType,
483
+ types: &mut TypeAlloc,
484
+ offset: usize,
485
+ check_limit: bool,
486
+ ) -> Result<()> {
487
+ let current = components.last_mut().unwrap();
488
+ if check_limit {
489
+ check_max(current.type_count(), 1, MAX_WASM_TYPES, "types", offset)?;
490
+ }
491
+ match ty {
492
+ crate::CoreType::Rec(rec) => {
493
+ current.canonicalize_and_intern_rec_group(types, rec, offset)?;
494
+ }
495
+ crate::CoreType::Module(decls) => {
496
+ let mod_ty = Self::create_module_type(components, decls.into_vec(), types, offset)?;
497
+ let id = ComponentCoreTypeId::Module(types.push_ty(mod_ty));
498
+ components.last_mut().unwrap().core_types.push(id);
499
+ }
500
+ }
501
+
502
+ Ok(())
503
+ }
504
+
505
+ pub fn add_core_module(
506
+ &mut self,
507
+ module: &Module,
508
+ types: &mut TypeAlloc,
509
+ offset: usize,
510
+ ) -> Result<()> {
511
+ let imports = module.imports_for_module_type(offset)?;
512
+
513
+ // We have to clone the module's imports and exports here
514
+ // because we cannot take the data out of the `MaybeOwned`
515
+ // as it might be shared with a function validator.
516
+ let mod_ty = ModuleType {
517
+ info: TypeInfo::core(module.type_size),
518
+ imports,
519
+ exports: module.exports.clone(),
520
+ };
521
+
522
+ let mod_id = types.push_ty(mod_ty);
523
+ self.core_modules.push(mod_id);
524
+
525
+ Ok(())
526
+ }
527
+
528
+ pub fn add_core_instance(
529
+ &mut self,
530
+ instance: crate::Instance,
531
+ types: &mut TypeAlloc,
532
+ offset: usize,
533
+ ) -> Result<()> {
534
+ let instance = match instance {
535
+ crate::Instance::Instantiate { module_index, args } => {
536
+ self.instantiate_core_module(module_index, args.into_vec(), types, offset)?
537
+ }
538
+ crate::Instance::FromExports(exports) => {
539
+ self.instantiate_core_exports(exports.into_vec(), types, offset)?
540
+ }
541
+ };
542
+
543
+ self.core_instances.push(instance);
544
+
545
+ Ok(())
546
+ }
547
+
548
+ pub fn add_type(
549
+ components: &mut Vec<Self>,
550
+ ty: crate::ComponentType,
551
+ types: &mut TypeAlloc,
552
+ offset: usize,
553
+ check_limit: bool,
554
+ ) -> Result<()> {
555
+ assert!(!components.is_empty());
556
+
557
+ fn current(components: &mut Vec<ComponentState>) -> &mut ComponentState {
558
+ components.last_mut().unwrap()
559
+ }
560
+
561
+ let id = match ty {
562
+ crate::ComponentType::Defined(ty) => {
563
+ let ty = current(components).create_defined_type(ty, types, offset)?;
564
+ types.push(ty).into()
565
+ }
566
+ crate::ComponentType::Func(ty) => {
567
+ let ty = current(components).create_function_type(ty, types, offset)?;
568
+ types.push(ty).into()
569
+ }
570
+ crate::ComponentType::Component(decls) => {
571
+ let ty = Self::create_component_type(components, decls.into_vec(), types, offset)?;
572
+ types.push(ty).into()
573
+ }
574
+ crate::ComponentType::Instance(decls) => {
575
+ let ty = Self::create_instance_type(components, decls.into_vec(), types, offset)?;
576
+ types.push(ty).into()
577
+ }
578
+ crate::ComponentType::Resource { rep, dtor } => {
579
+ let component = current(components);
580
+
581
+ // Resource types cannot be declared in a type context, only
582
+ // within a component context.
583
+ if component.kind != ComponentKind::Component {
584
+ bail!(
585
+ offset,
586
+ "resources can only be defined within a concrete component"
587
+ );
588
+ }
589
+
590
+ // Current MVP restriction of the component model.
591
+ if rep != ValType::I32 {
592
+ bail!(offset, "resources can only be represented by `i32`");
593
+ }
594
+
595
+ // If specified validate that the destructor is both a valid
596
+ // function and has the correct signature.
597
+ if let Some(dtor) = dtor {
598
+ let ty = component.core_function_at(dtor, offset)?;
599
+ let ty = types[ty].composite_type.unwrap_func();
600
+ if ty.params() != [rep] || ty.results() != [] {
601
+ bail!(
602
+ offset,
603
+ "core function {dtor} has wrong signature for a destructor"
604
+ );
605
+ }
606
+ }
607
+
608
+ // As this is the introduction of a resource create a fresh new
609
+ // identifier for the resource. This is then added into the
610
+ // list of defined resources for this component, notably with a
611
+ // rep listed to enable getting access to various intrinsics
612
+ // such as `resource.rep`.
613
+ let id = types.alloc_resource_id();
614
+ component.defined_resources.insert(id.resource(), Some(rep));
615
+ id.into()
616
+ }
617
+ };
618
+
619
+ let current = current(components);
620
+ if check_limit {
621
+ check_max(current.type_count(), 1, MAX_WASM_TYPES, "types", offset)?;
622
+ }
623
+ current.types.push(id);
624
+
625
+ Ok(())
626
+ }
627
+
628
+ pub fn add_import(
629
+ &mut self,
630
+ import: crate::ComponentImport,
631
+ types: &mut TypeAlloc,
632
+ offset: usize,
633
+ ) -> Result<()> {
634
+ let mut entity = self.check_type_ref(&import.ty, types, offset)?;
635
+ self.add_entity(
636
+ &mut entity,
637
+ Some((import.name.0, ExternKind::Import)),
638
+ types,
639
+ offset,
640
+ )?;
641
+ self.toplevel_imported_resources.validate_extern(
642
+ import.name.0,
643
+ ExternKind::Import,
644
+ &entity,
645
+ types,
646
+ offset,
647
+ &mut self.import_names,
648
+ &mut self.imports,
649
+ &mut self.type_info,
650
+ &self.features,
651
+ )?;
652
+ Ok(())
653
+ }
654
+
655
+ fn add_entity(
656
+ &mut self,
657
+ ty: &mut ComponentEntityType,
658
+ name_and_kind: Option<(&str, ExternKind)>,
659
+ types: &mut TypeAlloc,
660
+ offset: usize,
661
+ ) -> Result<()> {
662
+ let kind = name_and_kind.map(|(_, k)| k);
663
+ let (len, max, desc) = match ty {
664
+ ComponentEntityType::Module(id) => {
665
+ self.core_modules.push(*id);
666
+ (self.core_modules.len(), MAX_WASM_MODULES, "modules")
667
+ }
668
+ ComponentEntityType::Component(id) => {
669
+ self.components.push(*id);
670
+ (self.components.len(), MAX_WASM_COMPONENTS, "components")
671
+ }
672
+ ComponentEntityType::Instance(id) => {
673
+ match kind {
674
+ Some(ExternKind::Import) => self.prepare_instance_import(id, types),
675
+ Some(ExternKind::Export) => self.prepare_instance_export(id, types),
676
+ None => {}
677
+ }
678
+ self.instances.push(*id);
679
+ (self.instance_count(), MAX_WASM_INSTANCES, "instances")
680
+ }
681
+ ComponentEntityType::Func(id) => {
682
+ self.funcs.push(*id);
683
+ (self.function_count(), MAX_WASM_FUNCTIONS, "functions")
684
+ }
685
+ ComponentEntityType::Value(ty) => {
686
+ self.check_value_support(offset)?;
687
+ let value_used = match kind {
688
+ Some(ExternKind::Import) | None => false,
689
+ Some(ExternKind::Export) => true,
690
+ };
691
+ self.values.push((*ty, value_used));
692
+ (self.values.len(), MAX_WASM_VALUES, "values")
693
+ }
694
+ ComponentEntityType::Type {
695
+ created,
696
+ referenced,
697
+ } => {
698
+ self.types.push(*created);
699
+
700
+ // Extra logic here for resources being imported and exported.
701
+ // Note that if `created` is the same as `referenced` then this
702
+ // is the original introduction of the resource which is where
703
+ // `self.{imported,defined}_resources` are updated.
704
+ if let ComponentAnyTypeId::Resource(id) = *created {
705
+ match kind {
706
+ Some(ExternKind::Import) => {
707
+ // A fresh new resource is being imported into a
708
+ // component. This arises from the import section of
709
+ // a component or from the import declaration in a
710
+ // component type. In both cases a new imported
711
+ // resource is injected with a fresh new identifier
712
+ // into our state.
713
+ if created == referenced {
714
+ self.imported_resources
715
+ .insert(id.resource(), vec![self.imports.len()]);
716
+ }
717
+ }
718
+
719
+ Some(ExternKind::Export) => {
720
+ // A fresh resource is being exported from this
721
+ // component. This arises as part of the
722
+ // declaration of a component type, for example. In
723
+ // this situation brand new resource identifier is
724
+ // allocated and a definition is added, unlike the
725
+ // import case where an imported resource is added.
726
+ // Notably the representation of this new resource
727
+ // is unknown so it's listed as `None`.
728
+ if created == referenced {
729
+ self.defined_resources.insert(id.resource(), None);
730
+ }
731
+
732
+ // If this is a type export of a resource type then
733
+ // update the `explicit_resources` list. A new
734
+ // export path is about to be created for this
735
+ // resource and this keeps track of that.
736
+ self.explicit_resources
737
+ .insert(id.resource(), vec![self.exports.len()]);
738
+ }
739
+
740
+ None => {}
741
+ }
742
+ }
743
+ (self.types.len(), MAX_WASM_TYPES, "types")
744
+ }
745
+ };
746
+
747
+ check_max(len, 0, max, desc, offset)?;
748
+
749
+ // Before returning perform the final validation of the type of the item
750
+ // being imported/exported. This will ensure that everything is
751
+ // appropriately named with respect to type definitions, resources, etc.
752
+ if let Some((name, kind)) = name_and_kind {
753
+ if !self.validate_and_register_named_types(Some(name), kind, ty, types) {
754
+ bail!(
755
+ offset,
756
+ "{} not valid to be used as {}",
757
+ ty.desc(),
758
+ kind.desc()
759
+ );
760
+ }
761
+ }
762
+ Ok(())
763
+ }
764
+
765
+ /// Validates that the `ty` referenced only refers to named types internally
766
+ /// and then inserts anything necessary, if applicable, to the defined sets
767
+ /// within this component.
768
+ ///
769
+ /// This function will validate that `ty` only refers to named types. For
770
+ /// example if it's a record then all of its fields must refer to named
771
+ /// types. This consults either `self.imported_types` or
772
+ /// `self.exported_types` as specified by `kind`. Note that this is not
773
+ /// inherently recursive itself but it ends up being recursive since if
774
+ /// recursive members were named then all their components must also be
775
+ /// named. Consequently this check stops at the "one layer deep" position,
776
+ /// or more accurately the position where types must be named (e.g. tuples
777
+ /// aren't required to be named).
778
+ fn validate_and_register_named_types(
779
+ &mut self,
780
+ toplevel_name: Option<&str>,
781
+ kind: ExternKind,
782
+ ty: &ComponentEntityType,
783
+ types: &TypeAlloc,
784
+ ) -> bool {
785
+ if let ComponentEntityType::Type { created, .. } = ty {
786
+ // If this is a top-level resource then register it in the
787
+ // appropriate context so later validation of method-like-names
788
+ // works out.
789
+ if let Some(name) = toplevel_name {
790
+ if let ComponentAnyTypeId::Resource(id) = *created {
791
+ let cx = match kind {
792
+ ExternKind::Import => &mut self.toplevel_imported_resources,
793
+ ExternKind::Export => &mut self.toplevel_exported_resources,
794
+ };
795
+ cx.register(name, id);
796
+ }
797
+ }
798
+ }
799
+
800
+ match self.kind {
801
+ ComponentKind::Component | ComponentKind::ComponentType => {}
802
+ ComponentKind::InstanceType => return true,
803
+ }
804
+ let set = match kind {
805
+ ExternKind::Import => &self.imported_types,
806
+ ExternKind::Export => &self.exported_types,
807
+ };
808
+ match ty {
809
+ // When a type is imported or exported than any recursive type
810
+ // referred to by that import/export must additionally be exported
811
+ // or imported. Here this walks the "first layer" of the type which
812
+ // delegates to `TypeAlloc::type_named_type_id` to determine whether
813
+ // the components of the type being named here are indeed all they
814
+ // themselves named.
815
+ ComponentEntityType::Type {
816
+ created,
817
+ referenced,
818
+ } => {
819
+ if !self.all_valtypes_named(types, *referenced, set) {
820
+ return false;
821
+ }
822
+ match kind {
823
+ // Imported types are both valid for import and valid for
824
+ // export.
825
+ ExternKind::Import => {
826
+ self.imported_types.insert(*created);
827
+ self.exported_types.insert(*created);
828
+ }
829
+ ExternKind::Export => {
830
+ self.exported_types.insert(*created);
831
+ }
832
+ }
833
+
834
+ true
835
+ }
836
+
837
+ // Instances are slightly nuanced here. The general idea is that if
838
+ // an instance is imported, then any type exported by the instance
839
+ // is then also exported. Additionally for exports. To get this to
840
+ // work out this arm will recursively call
841
+ // `validate_and_register_named_types` which means that types are
842
+ // inserted into `self.{imported,exported}_types` as-we-go rather
843
+ // than all at once.
844
+ //
845
+ // This then recursively validates that all items in the instance
846
+ // itself are valid to import/export, recursive instances are
847
+ // captured, and everything is appropriately added to the right
848
+ // imported/exported set.
849
+ ComponentEntityType::Instance(i) => types[*i]
850
+ .exports
851
+ .iter()
852
+ .all(|(_name, ty)| self.validate_and_register_named_types(None, kind, ty, types)),
853
+
854
+ // All types referred to by a function must be named.
855
+ ComponentEntityType::Func(id) => self.all_valtypes_named_in_func(types, *id, set),
856
+
857
+ ComponentEntityType::Value(ty) => types.type_named_valtype(ty, set),
858
+
859
+ // Components/modules are always "closed" or "standalone" and don't
860
+ // need validation with respect to their named types.
861
+ ComponentEntityType::Component(_) | ComponentEntityType::Module(_) => true,
862
+ }
863
+ }
864
+
865
+ fn all_valtypes_named(
866
+ &self,
867
+ types: &TypeAlloc,
868
+ id: ComponentAnyTypeId,
869
+ set: &Set<ComponentAnyTypeId>,
870
+ ) -> bool {
871
+ match id {
872
+ // Resource types, in isolation, are always valid to import or
873
+ // export since they're either attached to an import or being
874
+ // exported.
875
+ //
876
+ // Note that further validation of this happens in `finish`, too.
877
+ ComponentAnyTypeId::Resource(_) => true,
878
+
879
+ // Component types are validated as they are constructed,
880
+ // so all component types are valid to export if they've
881
+ // already been constructed.
882
+ ComponentAnyTypeId::Component(_) => true,
883
+
884
+ ComponentAnyTypeId::Defined(id) => self.all_valtypes_named_in_defined(types, id, set),
885
+ ComponentAnyTypeId::Func(id) => self.all_valtypes_named_in_func(types, id, set),
886
+ ComponentAnyTypeId::Instance(id) => self.all_valtypes_named_in_instance(types, id, set),
887
+ }
888
+ }
889
+
890
+ fn all_valtypes_named_in_instance(
891
+ &self,
892
+ types: &TypeAlloc,
893
+ id: ComponentInstanceTypeId,
894
+ set: &Set<ComponentAnyTypeId>,
895
+ ) -> bool {
896
+ // Instances must recursively have all referenced types named.
897
+ let ty = &types[id];
898
+ ty.exports.values().all(|ty| match ty {
899
+ ComponentEntityType::Module(_) => true,
900
+ ComponentEntityType::Func(id) => self.all_valtypes_named_in_func(types, *id, set),
901
+ ComponentEntityType::Type { created: id, .. } => {
902
+ self.all_valtypes_named(types, *id, set)
903
+ }
904
+ ComponentEntityType::Value(ComponentValType::Type(id)) => {
905
+ self.all_valtypes_named_in_defined(types, *id, set)
906
+ }
907
+ ComponentEntityType::Instance(id) => {
908
+ self.all_valtypes_named_in_instance(types, *id, set)
909
+ }
910
+ ComponentEntityType::Component(_)
911
+ | ComponentEntityType::Value(ComponentValType::Primitive(_)) => return true,
912
+ })
913
+ }
914
+
915
+ fn all_valtypes_named_in_defined(
916
+ &self,
917
+ types: &TypeAlloc,
918
+ id: ComponentDefinedTypeId,
919
+ set: &Set<ComponentAnyTypeId>,
920
+ ) -> bool {
921
+ let ty = &types[id];
922
+ match ty {
923
+ // These types do not contain anything which must be
924
+ // named.
925
+ ComponentDefinedType::Primitive(_)
926
+ | ComponentDefinedType::Flags(_)
927
+ | ComponentDefinedType::Enum(_) => true,
928
+
929
+ // Referenced types of all these aggregates must all be
930
+ // named.
931
+ ComponentDefinedType::Record(r) => {
932
+ r.fields.values().all(|t| types.type_named_valtype(t, set))
933
+ }
934
+ ComponentDefinedType::Tuple(r) => {
935
+ r.types.iter().all(|t| types.type_named_valtype(t, set))
936
+ }
937
+ ComponentDefinedType::Variant(r) => r
938
+ .cases
939
+ .values()
940
+ .filter_map(|t| t.ty.as_ref())
941
+ .all(|t| types.type_named_valtype(t, set)),
942
+ ComponentDefinedType::Result { ok, err } => {
943
+ ok.as_ref()
944
+ .map(|t| types.type_named_valtype(t, set))
945
+ .unwrap_or(true)
946
+ && err
947
+ .as_ref()
948
+ .map(|t| types.type_named_valtype(t, set))
949
+ .unwrap_or(true)
950
+ }
951
+ ComponentDefinedType::List(ty)
952
+ | ComponentDefinedType::FixedSizeList(ty, _)
953
+ | ComponentDefinedType::Option(ty) => types.type_named_valtype(ty, set),
954
+ ComponentDefinedType::Map(k, v) => {
955
+ types.type_named_valtype(k, set) && types.type_named_valtype(v, set)
956
+ }
957
+
958
+ // The resource referred to by own/borrow must be named.
959
+ ComponentDefinedType::Own(id) | ComponentDefinedType::Borrow(id) => {
960
+ set.contains(&ComponentAnyTypeId::from(*id))
961
+ }
962
+
963
+ ComponentDefinedType::Future(ty) => ty
964
+ .as_ref()
965
+ .map(|ty| types.type_named_valtype(ty, set))
966
+ .unwrap_or(true),
967
+ ComponentDefinedType::Stream(ty) => ty
968
+ .as_ref()
969
+ .map(|ty| types.type_named_valtype(ty, set))
970
+ .unwrap_or(true),
971
+ }
972
+ }
973
+
974
+ fn all_valtypes_named_in_func(
975
+ &self,
976
+ types: &TypeAlloc,
977
+ id: ComponentFuncTypeId,
978
+ set: &Set<ComponentAnyTypeId>,
979
+ ) -> bool {
980
+ let ty = &types[id];
981
+ // Function types must have all their parameters/results named.
982
+ ty.params
983
+ .iter()
984
+ .map(|(_, ty)| ty)
985
+ .chain(&ty.result)
986
+ .all(|ty| types.type_named_valtype(ty, set))
987
+ }
988
+
989
+ /// Updates the type `id` specified, an identifier for a component instance
990
+ /// type, to be imported into this component.
991
+ ///
992
+ /// Importing an instance type into a component specially handles the
993
+ /// defined resources registered in the instance type. Notably all
994
+ /// defined resources are "freshened" into brand new type variables and
995
+ /// these new variables are substituted within the type. This is what
996
+ /// creates a new `TypeId` and may update the `id` specified.
997
+ ///
998
+ /// One side effect of this operation, for example, is that if an instance
999
+ /// type is used twice to import two different instances then the instances
1000
+ /// do not share resource types despite sharing the same original instance
1001
+ /// type.
1002
+ fn prepare_instance_import(&mut self, id: &mut ComponentInstanceTypeId, types: &mut TypeAlloc) {
1003
+ let ty = &types[*id];
1004
+
1005
+ // No special treatment for imports of instances which themselves have
1006
+ // no defined resources
1007
+ if ty.defined_resources.is_empty() {
1008
+ return;
1009
+ }
1010
+
1011
+ let mut new_ty = ComponentInstanceType {
1012
+ // Copied from the input verbatim
1013
+ info: ty.info,
1014
+
1015
+ // Copied over as temporary storage for now, and both of these are
1016
+ // filled out and expanded below.
1017
+ exports: ty.exports.clone(),
1018
+ explicit_resources: ty.explicit_resources.clone(),
1019
+
1020
+ // Explicitly discard this field since the
1021
+ // defined resources are lifted into `self`
1022
+ defined_resources: Default::default(),
1023
+ };
1024
+
1025
+ // Create brand new resources for all defined ones in the instance.
1026
+ let resources = (0..ty.defined_resources.len())
1027
+ .map(|_| types.alloc_resource_id())
1028
+ .collect::<IndexSet<_>>();
1029
+
1030
+ // Build a map from the defined resources in `ty` to those in `new_ty`.
1031
+ //
1032
+ // As part of this same loop the new resources, which were previously
1033
+ // defined in `ty`, now become imported variables in `self`. Their
1034
+ // path for where they're imported is updated as well with
1035
+ // `self.next_import_index` as the import-to-be soon.
1036
+ let mut mapping = Remapping::default();
1037
+ let ty = &types[*id];
1038
+ for (old, new) in ty.defined_resources.iter().zip(&resources) {
1039
+ let prev = mapping.resources.insert(*old, new.resource());
1040
+ assert!(prev.is_none());
1041
+
1042
+ let mut base = vec![self.imports.len()];
1043
+ base.extend(ty.explicit_resources[old].iter().copied());
1044
+ self.imported_resources.insert(new.resource(), base);
1045
+ }
1046
+
1047
+ // Using the old-to-new resource mapping perform a substitution on
1048
+ // the `exports` and `explicit_resources` fields of `new_ty`
1049
+ for ty in new_ty.exports.values_mut() {
1050
+ types.remap_component_entity(ty, &mut mapping);
1051
+ }
1052
+ for (id, path) in mem::take(&mut new_ty.explicit_resources) {
1053
+ let id = *mapping.resources.get(&id).unwrap_or(&id);
1054
+ new_ty.explicit_resources.insert(id, path);
1055
+ }
1056
+
1057
+ // Now that `new_ty` is complete finish its registration and then
1058
+ // update `id` on the way out.
1059
+ *id = types.push_ty(new_ty);
1060
+ }
1061
+
1062
+ /// Prepares an instance type, pointed to `id`, for being exported as a
1063
+ /// concrete instance from `self`.
1064
+ ///
1065
+ /// This will internally perform any resource "freshening" as required and
1066
+ /// then additionally update metadata within `self` about resources being
1067
+ /// exported or defined.
1068
+ fn prepare_instance_export(&mut self, id: &mut ComponentInstanceTypeId, types: &mut TypeAlloc) {
1069
+ // Exports of an instance mean that the enclosing context
1070
+ // is inheriting the resources that the instance
1071
+ // encapsulates. This means that the instance type
1072
+ // recorded for this export will itself have no
1073
+ // defined resources.
1074
+ let ty = &types[*id];
1075
+
1076
+ // Check to see if `defined_resources` is non-empty, and if so then
1077
+ // "freshen" all the resources and inherit them to our own defined
1078
+ // resources, updating `id` in the process.
1079
+ //
1080
+ // Note though that this specifically is not rewriting the resources of
1081
+ // exported instances. The `defined_resources` set on instance types is
1082
+ // a little subtle (see its documentation for more info), but the
1083
+ // general idea is that for a concrete instance it's always empty. Only
1084
+ // for instance type definitions does it ever have elements in it.
1085
+ //
1086
+ // That means that if this set is non-empty then what's happening is
1087
+ // that we're in a type context an exporting an instance of a previously
1088
+ // specified type. In this case all resources are required to be
1089
+ // "freshened" to ensure that multiple exports of the same type all
1090
+ // export different types of resources.
1091
+ //
1092
+ // And finally note that this operation empties out the
1093
+ // `defined_resources` set of the type that is registered for the
1094
+ // instance, as this export is modeled as producing a concrete instance.
1095
+ if !ty.defined_resources.is_empty() {
1096
+ let mut new_ty = ty.clone();
1097
+ let mut mapping = Remapping::default();
1098
+ for old in mem::take(&mut new_ty.defined_resources) {
1099
+ let new = types.alloc_resource_id();
1100
+ mapping.resources.insert(old, new.resource());
1101
+ self.defined_resources.insert(new.resource(), None);
1102
+ }
1103
+ for ty in new_ty.exports.values_mut() {
1104
+ types.remap_component_entity(ty, &mut mapping);
1105
+ }
1106
+ for (id, path) in mem::take(&mut new_ty.explicit_resources) {
1107
+ let id = mapping.resources.get(&id).copied().unwrap_or(id);
1108
+ new_ty.explicit_resources.insert(id, path);
1109
+ }
1110
+ *id = types.push_ty(new_ty);
1111
+ }
1112
+
1113
+ // Any explicit resources in the instance are now additionally explicit
1114
+ // in this component since it's exported.
1115
+ //
1116
+ // The path to each explicit resources gets one element prepended which
1117
+ // is `self.next_export_index`, the index of the export about to be
1118
+ // generated.
1119
+ let ty = &types[*id];
1120
+ for (id, path) in ty.explicit_resources.iter() {
1121
+ let mut new_path = vec![self.exports.len()];
1122
+ new_path.extend(path);
1123
+ self.explicit_resources.insert(*id, new_path);
1124
+ }
1125
+ }
1126
+
1127
+ pub fn add_export(
1128
+ &mut self,
1129
+ name: ComponentExportName<'_>,
1130
+ mut ty: ComponentEntityType,
1131
+ types: &mut TypeAlloc,
1132
+ offset: usize,
1133
+ check_limit: bool,
1134
+ ) -> Result<()> {
1135
+ if check_limit {
1136
+ check_max(self.exports.len(), 1, MAX_WASM_EXPORTS, "exports", offset)?;
1137
+ }
1138
+ self.add_entity(&mut ty, Some((name.0, ExternKind::Export)), types, offset)?;
1139
+ self.toplevel_exported_resources.validate_extern(
1140
+ name.0,
1141
+ ExternKind::Export,
1142
+ &ty,
1143
+ types,
1144
+ offset,
1145
+ &mut self.export_names,
1146
+ &mut self.exports,
1147
+ &mut self.type_info,
1148
+ &self.features,
1149
+ )?;
1150
+ Ok(())
1151
+ }
1152
+
1153
+ pub fn canonical_function(
1154
+ &mut self,
1155
+ func: CanonicalFunction,
1156
+ types: &mut TypeAlloc,
1157
+ offset: usize,
1158
+ ) -> Result<()> {
1159
+ match func {
1160
+ CanonicalFunction::Lift {
1161
+ core_func_index,
1162
+ type_index,
1163
+ options,
1164
+ } => self.lift_function(core_func_index, type_index, &options, types, offset),
1165
+ CanonicalFunction::Lower {
1166
+ func_index,
1167
+ options,
1168
+ } => self.lower_function(func_index, &options, types, offset),
1169
+ CanonicalFunction::ResourceNew { resource } => {
1170
+ self.resource_new(resource, types, offset)
1171
+ }
1172
+ CanonicalFunction::ResourceDrop { resource } => {
1173
+ self.resource_drop(resource, types, offset)
1174
+ }
1175
+ CanonicalFunction::ResourceDropAsync { resource } => {
1176
+ self.resource_drop_async(resource, types, offset)
1177
+ }
1178
+ CanonicalFunction::ResourceRep { resource } => {
1179
+ self.resource_rep(resource, types, offset)
1180
+ }
1181
+ CanonicalFunction::ThreadSpawnRef { func_ty_index } => {
1182
+ self.thread_spawn_ref(func_ty_index, types, offset)
1183
+ }
1184
+ CanonicalFunction::ThreadSpawnIndirect {
1185
+ func_ty_index,
1186
+ table_index,
1187
+ } => self.thread_spawn_indirect(func_ty_index, table_index, types, offset),
1188
+ CanonicalFunction::ThreadAvailableParallelism => {
1189
+ self.thread_available_parallelism(types, offset)
1190
+ }
1191
+ CanonicalFunction::BackpressureInc => self.backpressure_inc(types, offset),
1192
+ CanonicalFunction::BackpressureDec => self.backpressure_dec(types, offset),
1193
+ CanonicalFunction::TaskReturn { result, options } => {
1194
+ self.task_return(&result, &options, types, offset)
1195
+ }
1196
+ CanonicalFunction::TaskCancel => self.task_cancel(types, offset),
1197
+ CanonicalFunction::ContextGet(i) => self.context_get(i, types, offset),
1198
+ CanonicalFunction::ContextSet(i) => self.context_set(i, types, offset),
1199
+ CanonicalFunction::ThreadYield { cancellable } => {
1200
+ self.thread_yield(cancellable, types, offset)
1201
+ }
1202
+ CanonicalFunction::SubtaskDrop => self.subtask_drop(types, offset),
1203
+ CanonicalFunction::SubtaskCancel { async_ } => {
1204
+ self.subtask_cancel(async_, types, offset)
1205
+ }
1206
+ CanonicalFunction::StreamNew { ty } => self.stream_new(ty, types, offset),
1207
+ CanonicalFunction::StreamRead { ty, options } => {
1208
+ self.stream_read(ty, &options, types, offset)
1209
+ }
1210
+ CanonicalFunction::StreamWrite { ty, options } => {
1211
+ self.stream_write(ty, &options, types, offset)
1212
+ }
1213
+ CanonicalFunction::StreamCancelRead { ty, async_ } => {
1214
+ self.stream_cancel_read(ty, async_, types, offset)
1215
+ }
1216
+ CanonicalFunction::StreamCancelWrite { ty, async_ } => {
1217
+ self.stream_cancel_write(ty, async_, types, offset)
1218
+ }
1219
+ CanonicalFunction::StreamDropReadable { ty } => {
1220
+ self.stream_drop_readable(ty, types, offset)
1221
+ }
1222
+ CanonicalFunction::StreamDropWritable { ty } => {
1223
+ self.stream_drop_writable(ty, types, offset)
1224
+ }
1225
+ CanonicalFunction::FutureNew { ty } => self.future_new(ty, types, offset),
1226
+ CanonicalFunction::FutureRead { ty, options } => {
1227
+ self.future_read(ty, &options, types, offset)
1228
+ }
1229
+ CanonicalFunction::FutureWrite { ty, options } => {
1230
+ self.future_write(ty, options.into_vec(), types, offset)
1231
+ }
1232
+ CanonicalFunction::FutureCancelRead { ty, async_ } => {
1233
+ self.future_cancel_read(ty, async_, types, offset)
1234
+ }
1235
+ CanonicalFunction::FutureCancelWrite { ty, async_ } => {
1236
+ self.future_cancel_write(ty, async_, types, offset)
1237
+ }
1238
+ CanonicalFunction::FutureDropReadable { ty } => {
1239
+ self.future_drop_readable(ty, types, offset)
1240
+ }
1241
+ CanonicalFunction::FutureDropWritable { ty } => {
1242
+ self.future_drop_writable(ty, types, offset)
1243
+ }
1244
+ CanonicalFunction::ErrorContextNew { options } => {
1245
+ self.error_context_new(options.into_vec(), types, offset)
1246
+ }
1247
+ CanonicalFunction::ErrorContextDebugMessage { options } => {
1248
+ self.error_context_debug_message(options.into_vec(), types, offset)
1249
+ }
1250
+ CanonicalFunction::ErrorContextDrop => self.error_context_drop(types, offset),
1251
+ CanonicalFunction::WaitableSetNew => self.waitable_set_new(types, offset),
1252
+ CanonicalFunction::WaitableSetWait {
1253
+ cancellable,
1254
+ memory,
1255
+ } => self.waitable_set_wait(cancellable, memory, types, offset),
1256
+ CanonicalFunction::WaitableSetPoll {
1257
+ cancellable,
1258
+ memory,
1259
+ } => self.waitable_set_poll(cancellable, memory, types, offset),
1260
+ CanonicalFunction::WaitableSetDrop => self.waitable_set_drop(types, offset),
1261
+ CanonicalFunction::WaitableJoin => self.waitable_join(types, offset),
1262
+ CanonicalFunction::ThreadIndex => self.thread_index(types, offset),
1263
+ CanonicalFunction::ThreadNewIndirect {
1264
+ func_ty_index,
1265
+ table_index,
1266
+ } => self.thread_new_indirect(func_ty_index, table_index, types, offset),
1267
+ CanonicalFunction::ThreadSwitchTo { cancellable } => {
1268
+ self.thread_switch_to(cancellable, types, offset)
1269
+ }
1270
+ CanonicalFunction::ThreadSuspend { cancellable } => {
1271
+ self.thread_suspend(cancellable, types, offset)
1272
+ }
1273
+ CanonicalFunction::ThreadResumeLater => self.thread_resume_later(types, offset),
1274
+
1275
+ CanonicalFunction::ThreadYieldTo { cancellable } => {
1276
+ self.thread_yield_to(cancellable, types, offset)
1277
+ }
1278
+ }
1279
+ }
1280
+
1281
+ fn lift_function(
1282
+ &mut self,
1283
+ core_func_index: u32,
1284
+ type_index: u32,
1285
+ options: &[CanonicalOption],
1286
+ types: &mut TypeAlloc,
1287
+ offset: usize,
1288
+ ) -> Result<()> {
1289
+ let ty = self.function_type_at(type_index, types, offset)?;
1290
+ let core_ty_id = self.core_function_at(core_func_index, offset)?;
1291
+
1292
+ // Lifting a function is for an export, so match the expected canonical ABI
1293
+ // export signature
1294
+ let mut options = self.check_options(types, options, offset)?;
1295
+ options.check_lift(types, self, core_ty_id, offset)?;
1296
+ let func_ty = ty.lower(types, &options, Abi::Lift, offset)?;
1297
+ let lowered_core_ty_id = func_ty.intern(types, offset);
1298
+
1299
+ if core_ty_id == lowered_core_ty_id {
1300
+ self.funcs
1301
+ .push(self.types[type_index as usize].unwrap_func());
1302
+ return Ok(());
1303
+ }
1304
+
1305
+ let ty = types[core_ty_id].unwrap_func();
1306
+ let lowered_ty = types[lowered_core_ty_id].unwrap_func();
1307
+
1308
+ if lowered_ty.params() != ty.params() {
1309
+ bail!(
1310
+ offset,
1311
+ "lowered parameter types `{:?}` do not match parameter types `{:?}` of \
1312
+ core function {core_func_index}",
1313
+ lowered_ty.params(),
1314
+ ty.params()
1315
+ );
1316
+ }
1317
+
1318
+ if lowered_ty.results() != ty.results() {
1319
+ bail!(
1320
+ offset,
1321
+ "lowered result types `{:?}` do not match result types `{:?}` of \
1322
+ core function {core_func_index}",
1323
+ lowered_ty.results(),
1324
+ ty.results()
1325
+ );
1326
+ }
1327
+
1328
+ // Otherwise, must be different rec groups or subtyping (which isn't
1329
+ // supported yet) or something.
1330
+ bail!(
1331
+ offset,
1332
+ "lowered function type `{:?}` does not match type `{:?}` of \
1333
+ core function {core_func_index}",
1334
+ types[lowered_core_ty_id],
1335
+ types[core_ty_id],
1336
+ );
1337
+ }
1338
+
1339
+ fn lower_function(
1340
+ &mut self,
1341
+ func_index: u32,
1342
+ options: &[CanonicalOption],
1343
+ types: &mut TypeAlloc,
1344
+ offset: usize,
1345
+ ) -> Result<()> {
1346
+ let ty = &types[self.function_at(func_index, offset)?];
1347
+
1348
+ // Lowering a function is for an import, so use a function type that matches
1349
+ // the expected canonical ABI import signature.
1350
+ let options = self.check_options(types, options, offset)?;
1351
+ options.check_lower(offset)?;
1352
+ let func_ty = ty.lower(types, &options, Abi::Lower, offset)?;
1353
+ let ty_id = func_ty.intern(types, offset);
1354
+
1355
+ self.core_funcs.push(ty_id);
1356
+ Ok(())
1357
+ }
1358
+
1359
+ fn resource_new(&mut self, resource: u32, types: &mut TypeAlloc, offset: usize) -> Result<()> {
1360
+ let rep = self.check_local_resource(resource, types, offset)?;
1361
+ let id = types.intern_func_type(FuncType::new([rep], [ValType::I32]), offset);
1362
+ self.core_funcs.push(id);
1363
+ Ok(())
1364
+ }
1365
+
1366
+ fn resource_drop(&mut self, resource: u32, types: &mut TypeAlloc, offset: usize) -> Result<()> {
1367
+ self.resource_at(resource, types, offset)?;
1368
+ let id = types.intern_func_type(FuncType::new([ValType::I32], []), offset);
1369
+ self.core_funcs.push(id);
1370
+ Ok(())
1371
+ }
1372
+
1373
+ fn resource_drop_async(
1374
+ &mut self,
1375
+ resource: u32,
1376
+ types: &mut TypeAlloc,
1377
+ offset: usize,
1378
+ ) -> Result<()> {
1379
+ if !self.features.cm_async_builtins() {
1380
+ bail!(
1381
+ offset,
1382
+ "`resource.drop` as `async` requires the component model async builtins feature"
1383
+ )
1384
+ }
1385
+ self.resource_at(resource, types, offset)?;
1386
+ let id = types.intern_func_type(FuncType::new([ValType::I32], []), offset);
1387
+ self.core_funcs.push(id);
1388
+ Ok(())
1389
+ }
1390
+
1391
+ fn resource_rep(&mut self, resource: u32, types: &mut TypeAlloc, offset: usize) -> Result<()> {
1392
+ let rep = self.check_local_resource(resource, types, offset)?;
1393
+ let id = types.intern_func_type(FuncType::new([ValType::I32], [rep]), offset);
1394
+ self.core_funcs.push(id);
1395
+ Ok(())
1396
+ }
1397
+
1398
+ fn backpressure_inc(&mut self, types: &mut TypeAlloc, offset: usize) -> Result<()> {
1399
+ if !self.features.cm_async() {
1400
+ bail!(
1401
+ offset,
1402
+ "`backpressure.inc` requires the component model async feature"
1403
+ )
1404
+ }
1405
+
1406
+ self.core_funcs
1407
+ .push(types.intern_func_type(FuncType::new([], []), offset));
1408
+ Ok(())
1409
+ }
1410
+
1411
+ fn backpressure_dec(&mut self, types: &mut TypeAlloc, offset: usize) -> Result<()> {
1412
+ if !self.features.cm_async() {
1413
+ bail!(
1414
+ offset,
1415
+ "`backpressure.dec` requires the component model async feature"
1416
+ )
1417
+ }
1418
+
1419
+ self.core_funcs
1420
+ .push(types.intern_func_type(FuncType::new([], []), offset));
1421
+ Ok(())
1422
+ }
1423
+
1424
+ fn task_return(
1425
+ &mut self,
1426
+ result: &Option<crate::ComponentValType>,
1427
+ options: &[CanonicalOption],
1428
+ types: &mut TypeAlloc,
1429
+ offset: usize,
1430
+ ) -> Result<()> {
1431
+ if !self.features.cm_async() {
1432
+ bail!(
1433
+ offset,
1434
+ "`task.return` requires the component model async feature"
1435
+ )
1436
+ }
1437
+
1438
+ let func_ty = ComponentFuncType {
1439
+ async_: false,
1440
+ info: TypeInfo::new(),
1441
+ params: result
1442
+ .iter()
1443
+ .map(|ty| {
1444
+ Ok((
1445
+ KebabString::new("v").unwrap(),
1446
+ match ty {
1447
+ crate::ComponentValType::Primitive(ty) => {
1448
+ ComponentValType::Primitive(*ty)
1449
+ }
1450
+ crate::ComponentValType::Type(index) => {
1451
+ ComponentValType::Type(self.defined_type_at(*index, offset)?)
1452
+ }
1453
+ },
1454
+ ))
1455
+ })
1456
+ .collect::<Result<_>>()?,
1457
+ result: None,
1458
+ };
1459
+
1460
+ let options = self.check_options(types, options, offset)?;
1461
+ if options.realloc.is_some() {
1462
+ bail!(offset, "cannot specify `realloc` option on `task.return`")
1463
+ }
1464
+ if options.post_return.is_some() {
1465
+ bail!(
1466
+ offset,
1467
+ "cannot specify `post-return` option on `task.return`"
1468
+ )
1469
+ }
1470
+ options.check_lower(offset)?;
1471
+ options.require_sync(offset, "task.return")?;
1472
+
1473
+ let func_ty = func_ty.lower(types, &options, Abi::Lower, offset)?;
1474
+ let ty_id = func_ty.intern(types, offset);
1475
+
1476
+ self.core_funcs.push(ty_id);
1477
+ Ok(())
1478
+ }
1479
+
1480
+ fn task_cancel(&mut self, types: &mut TypeAlloc, offset: usize) -> Result<()> {
1481
+ if !self.features.cm_async() {
1482
+ bail!(
1483
+ offset,
1484
+ "`task.cancel` requires the component model async feature"
1485
+ )
1486
+ }
1487
+
1488
+ self.core_funcs
1489
+ .push(types.intern_func_type(FuncType::new([], []), offset));
1490
+ Ok(())
1491
+ }
1492
+
1493
+ fn validate_context_immediate(
1494
+ &self,
1495
+ immediate: u32,
1496
+ operation: &str,
1497
+ offset: usize,
1498
+ ) -> Result<()> {
1499
+ if !self.features.cm_threading() && immediate > 0 {
1500
+ bail!(offset, "`{operation}` immediate must be zero: {immediate}")
1501
+ } else if immediate > 1 {
1502
+ bail!(
1503
+ offset,
1504
+ "`{operation}` immediate must be zero or one: {immediate}"
1505
+ )
1506
+ }
1507
+ Ok(())
1508
+ }
1509
+
1510
+ fn context_get(&mut self, i: u32, types: &mut TypeAlloc, offset: usize) -> Result<()> {
1511
+ if !self.features.cm_async() {
1512
+ bail!(
1513
+ offset,
1514
+ "`context.get` requires the component model async feature"
1515
+ )
1516
+ }
1517
+ self.validate_context_immediate(i, "context.get", offset)?;
1518
+
1519
+ self.core_funcs
1520
+ .push(types.intern_func_type(FuncType::new([], [ValType::I32]), offset));
1521
+ Ok(())
1522
+ }
1523
+
1524
+ fn context_set(&mut self, i: u32, types: &mut TypeAlloc, offset: usize) -> Result<()> {
1525
+ if !self.features.cm_async() {
1526
+ bail!(
1527
+ offset,
1528
+ "`context.set` requires the component model async feature"
1529
+ )
1530
+ }
1531
+ self.validate_context_immediate(i, "context.set", offset)?;
1532
+
1533
+ self.core_funcs
1534
+ .push(types.intern_func_type(FuncType::new([ValType::I32], []), offset));
1535
+ Ok(())
1536
+ }
1537
+
1538
+ fn thread_yield(
1539
+ &mut self,
1540
+ cancellable: bool,
1541
+ types: &mut TypeAlloc,
1542
+ offset: usize,
1543
+ ) -> Result<()> {
1544
+ if !self.features.cm_async() {
1545
+ bail!(
1546
+ offset,
1547
+ "`thread.yield` requires the component model async feature"
1548
+ )
1549
+ }
1550
+ if cancellable && !self.features.cm_async_stackful() {
1551
+ bail!(
1552
+ offset,
1553
+ "cancellable `thread.yield` requires the component model async stackful feature"
1554
+ )
1555
+ }
1556
+
1557
+ self.core_funcs
1558
+ .push(types.intern_func_type(FuncType::new([], [ValType::I32]), offset));
1559
+ Ok(())
1560
+ }
1561
+
1562
+ fn subtask_drop(&mut self, types: &mut TypeAlloc, offset: usize) -> Result<()> {
1563
+ if !self.features.cm_async() {
1564
+ bail!(
1565
+ offset,
1566
+ "`subtask.drop` requires the component model async feature"
1567
+ )
1568
+ }
1569
+
1570
+ self.core_funcs
1571
+ .push(types.intern_func_type(FuncType::new([ValType::I32], []), offset));
1572
+ Ok(())
1573
+ }
1574
+
1575
+ fn subtask_cancel(&mut self, async_: bool, types: &mut TypeAlloc, offset: usize) -> Result<()> {
1576
+ if !self.features.cm_async() {
1577
+ bail!(
1578
+ offset,
1579
+ "`subtask.cancel` requires the component model async feature"
1580
+ )
1581
+ }
1582
+ if async_ && !self.features.cm_async_builtins() {
1583
+ bail!(
1584
+ offset,
1585
+ "async `subtask.cancel` requires the component model async builtins feature"
1586
+ )
1587
+ }
1588
+
1589
+ self.core_funcs
1590
+ .push(types.intern_func_type(FuncType::new([ValType::I32], [ValType::I32]), offset));
1591
+ Ok(())
1592
+ }
1593
+
1594
+ fn stream_new(&mut self, ty: u32, types: &mut TypeAlloc, offset: usize) -> Result<()> {
1595
+ if !self.features.cm_async() {
1596
+ bail!(
1597
+ offset,
1598
+ "`stream.new` requires the component model async feature"
1599
+ )
1600
+ }
1601
+
1602
+ let ty = self.defined_type_at(ty, offset)?;
1603
+ let ComponentDefinedType::Stream(_) = &types[ty] else {
1604
+ bail!(offset, "`stream.new` requires a stream type")
1605
+ };
1606
+
1607
+ self.core_funcs
1608
+ .push(types.intern_func_type(FuncType::new([], [ValType::I64]), offset));
1609
+ Ok(())
1610
+ }
1611
+
1612
+ fn stream_read(
1613
+ &mut self,
1614
+ ty: u32,
1615
+ options: &[CanonicalOption],
1616
+ types: &mut TypeAlloc,
1617
+ offset: usize,
1618
+ ) -> Result<()> {
1619
+ if !self.features.cm_async() {
1620
+ bail!(
1621
+ offset,
1622
+ "`stream.read` requires the component model async feature"
1623
+ )
1624
+ }
1625
+
1626
+ let ty = self.defined_type_at(ty, offset)?;
1627
+ let ComponentDefinedType::Stream(elem_ty) = &types[ty] else {
1628
+ bail!(offset, "`stream.read` requires a stream type")
1629
+ };
1630
+
1631
+ let ty_id = self
1632
+ .check_options(types, options, offset)?
1633
+ .require_memory_if(offset, || elem_ty.is_some())?
1634
+ .require_realloc_if(offset, || elem_ty.is_some_and(|ty| ty.contains_ptr(types)))?
1635
+ .check_lower(offset)?
1636
+ .check_core_type(
1637
+ types,
1638
+ FuncType::new([ValType::I32; 3], [ValType::I32]),
1639
+ offset,
1640
+ )?;
1641
+
1642
+ self.core_funcs.push(ty_id);
1643
+ Ok(())
1644
+ }
1645
+
1646
+ fn stream_write(
1647
+ &mut self,
1648
+ ty: u32,
1649
+ options: &[CanonicalOption],
1650
+ types: &mut TypeAlloc,
1651
+ offset: usize,
1652
+ ) -> Result<()> {
1653
+ if !self.features.cm_async() {
1654
+ bail!(
1655
+ offset,
1656
+ "`stream.write` requires the component model async feature"
1657
+ )
1658
+ }
1659
+
1660
+ let ty = self.defined_type_at(ty, offset)?;
1661
+ let ComponentDefinedType::Stream(elem_ty) = &types[ty] else {
1662
+ bail!(offset, "`stream.write` requires a stream type")
1663
+ };
1664
+
1665
+ let ty_id = self
1666
+ .check_options(types, options, offset)?
1667
+ .require_memory_if(offset, || elem_ty.is_some())?
1668
+ .check_lower(offset)?
1669
+ .check_core_type(
1670
+ types,
1671
+ FuncType::new([ValType::I32; 3], [ValType::I32]),
1672
+ offset,
1673
+ )?;
1674
+
1675
+ self.core_funcs.push(ty_id);
1676
+ Ok(())
1677
+ }
1678
+
1679
+ fn stream_cancel_read(
1680
+ &mut self,
1681
+ ty: u32,
1682
+ cancellable: bool,
1683
+ types: &mut TypeAlloc,
1684
+ offset: usize,
1685
+ ) -> Result<()> {
1686
+ if !self.features.cm_async() {
1687
+ bail!(
1688
+ offset,
1689
+ "`stream.cancel-read` requires the component model async feature"
1690
+ )
1691
+ }
1692
+ if cancellable && !self.features.cm_async_builtins() {
1693
+ bail!(
1694
+ offset,
1695
+ "async `stream.cancel-read` requires the component model async builtins feature"
1696
+ )
1697
+ }
1698
+
1699
+ let ty = self.defined_type_at(ty, offset)?;
1700
+ let ComponentDefinedType::Stream(_) = &types[ty] else {
1701
+ bail!(offset, "`stream.cancel-read` requires a stream type")
1702
+ };
1703
+
1704
+ self.core_funcs
1705
+ .push(types.intern_func_type(FuncType::new([ValType::I32], [ValType::I32]), offset));
1706
+ Ok(())
1707
+ }
1708
+
1709
+ fn stream_cancel_write(
1710
+ &mut self,
1711
+ ty: u32,
1712
+ cancellable: bool,
1713
+ types: &mut TypeAlloc,
1714
+ offset: usize,
1715
+ ) -> Result<()> {
1716
+ if !self.features.cm_async() {
1717
+ bail!(
1718
+ offset,
1719
+ "`stream.cancel-write` requires the component model async feature"
1720
+ )
1721
+ }
1722
+ if cancellable && !self.features.cm_async_builtins() {
1723
+ bail!(
1724
+ offset,
1725
+ "async `stream.cancel-write` requires the component model async builtins feature"
1726
+ )
1727
+ }
1728
+
1729
+ let ty = self.defined_type_at(ty, offset)?;
1730
+ let ComponentDefinedType::Stream(_) = &types[ty] else {
1731
+ bail!(offset, "`stream.cancel-write` requires a stream type")
1732
+ };
1733
+
1734
+ self.core_funcs
1735
+ .push(types.intern_func_type(FuncType::new([ValType::I32], [ValType::I32]), offset));
1736
+ Ok(())
1737
+ }
1738
+
1739
+ fn stream_drop_readable(
1740
+ &mut self,
1741
+ ty: u32,
1742
+ types: &mut TypeAlloc,
1743
+ offset: usize,
1744
+ ) -> Result<()> {
1745
+ if !self.features.cm_async() {
1746
+ bail!(
1747
+ offset,
1748
+ "`stream.drop-readable` requires the component model async feature"
1749
+ )
1750
+ }
1751
+
1752
+ let ty = self.defined_type_at(ty, offset)?;
1753
+ let ComponentDefinedType::Stream(_) = &types[ty] else {
1754
+ bail!(offset, "`stream.drop-readable` requires a stream type")
1755
+ };
1756
+
1757
+ self.core_funcs
1758
+ .push(types.intern_func_type(FuncType::new([ValType::I32], []), offset));
1759
+ Ok(())
1760
+ }
1761
+
1762
+ fn stream_drop_writable(
1763
+ &mut self,
1764
+ ty: u32,
1765
+ types: &mut TypeAlloc,
1766
+ offset: usize,
1767
+ ) -> Result<()> {
1768
+ if !self.features.cm_async() {
1769
+ bail!(
1770
+ offset,
1771
+ "`stream.drop-writable` requires the component model async feature"
1772
+ )
1773
+ }
1774
+
1775
+ let ty = self.defined_type_at(ty, offset)?;
1776
+ let ComponentDefinedType::Stream(_) = &types[ty] else {
1777
+ bail!(offset, "`stream.drop-writable` requires a stream type")
1778
+ };
1779
+
1780
+ self.core_funcs
1781
+ .push(types.intern_func_type(FuncType::new([ValType::I32], []), offset));
1782
+ Ok(())
1783
+ }
1784
+
1785
+ fn future_new(&mut self, ty: u32, types: &mut TypeAlloc, offset: usize) -> Result<()> {
1786
+ if !self.features.cm_async() {
1787
+ bail!(
1788
+ offset,
1789
+ "`future.new` requires the component model async feature"
1790
+ )
1791
+ }
1792
+
1793
+ let ty = self.defined_type_at(ty, offset)?;
1794
+ let ComponentDefinedType::Future(_) = &types[ty] else {
1795
+ bail!(offset, "`future.new` requires a future type")
1796
+ };
1797
+
1798
+ self.core_funcs
1799
+ .push(types.intern_func_type(FuncType::new([], [ValType::I64]), offset));
1800
+ Ok(())
1801
+ }
1802
+
1803
+ fn future_read(
1804
+ &mut self,
1805
+ ty: u32,
1806
+ options: &[CanonicalOption],
1807
+ types: &mut TypeAlloc,
1808
+ offset: usize,
1809
+ ) -> Result<()> {
1810
+ if !self.features.cm_async() {
1811
+ bail!(
1812
+ offset,
1813
+ "`future.read` requires the component model async feature"
1814
+ )
1815
+ }
1816
+
1817
+ let ty = self.defined_type_at(ty, offset)?;
1818
+ let ComponentDefinedType::Future(elem_ty) = &types[ty] else {
1819
+ bail!(offset, "`future.read` requires a future type")
1820
+ };
1821
+
1822
+ let ty_id = self
1823
+ .check_options(types, options, offset)?
1824
+ .require_memory_if(offset, || elem_ty.is_some())?
1825
+ .require_realloc_if(offset, || elem_ty.is_some_and(|ty| ty.contains_ptr(types)))?
1826
+ .check_lower(offset)?
1827
+ .check_core_type(
1828
+ types,
1829
+ FuncType::new([ValType::I32; 2], [ValType::I32]),
1830
+ offset,
1831
+ )?;
1832
+
1833
+ self.core_funcs.push(ty_id);
1834
+ Ok(())
1835
+ }
1836
+
1837
+ fn future_write(
1838
+ &mut self,
1839
+ ty: u32,
1840
+ options: Vec<CanonicalOption>,
1841
+ types: &mut TypeAlloc,
1842
+ offset: usize,
1843
+ ) -> Result<()> {
1844
+ if !self.features.cm_async() {
1845
+ bail!(
1846
+ offset,
1847
+ "`future.write` requires the component model async feature"
1848
+ )
1849
+ }
1850
+
1851
+ let ty = self.defined_type_at(ty, offset)?;
1852
+ let ComponentDefinedType::Future(elem_ty) = &types[ty] else {
1853
+ bail!(offset, "`future.write` requires a future type")
1854
+ };
1855
+
1856
+ let ty_id = self
1857
+ .check_options(types, &options, offset)?
1858
+ .require_memory_if(offset, || elem_ty.is_some())?
1859
+ .check_core_type(
1860
+ types,
1861
+ FuncType::new([ValType::I32; 2], [ValType::I32]),
1862
+ offset,
1863
+ )?;
1864
+
1865
+ self.core_funcs.push(ty_id);
1866
+ Ok(())
1867
+ }
1868
+
1869
+ fn future_cancel_read(
1870
+ &mut self,
1871
+ ty: u32,
1872
+ cancellable: bool,
1873
+ types: &mut TypeAlloc,
1874
+ offset: usize,
1875
+ ) -> Result<()> {
1876
+ if !self.features.cm_async() {
1877
+ bail!(
1878
+ offset,
1879
+ "`future.cancel-read` requires the component model async feature"
1880
+ )
1881
+ }
1882
+ if cancellable && !self.features.cm_async_builtins() {
1883
+ bail!(
1884
+ offset,
1885
+ "async `future.cancel-read` requires the component model async builtins feature"
1886
+ )
1887
+ }
1888
+
1889
+ let ty = self.defined_type_at(ty, offset)?;
1890
+ let ComponentDefinedType::Future(_) = &types[ty] else {
1891
+ bail!(offset, "`future.cancel-read` requires a future type")
1892
+ };
1893
+
1894
+ self.core_funcs
1895
+ .push(types.intern_func_type(FuncType::new([ValType::I32], [ValType::I32]), offset));
1896
+ Ok(())
1897
+ }
1898
+
1899
+ fn future_cancel_write(
1900
+ &mut self,
1901
+ ty: u32,
1902
+ cancellable: bool,
1903
+ types: &mut TypeAlloc,
1904
+ offset: usize,
1905
+ ) -> Result<()> {
1906
+ if !self.features.cm_async() {
1907
+ bail!(
1908
+ offset,
1909
+ "`future.cancel-write` requires the component model async feature"
1910
+ )
1911
+ }
1912
+ if cancellable && !self.features.cm_async_builtins() {
1913
+ bail!(
1914
+ offset,
1915
+ "async `future.cancel-write` requires the component model async builtins feature"
1916
+ )
1917
+ }
1918
+
1919
+ let ty = self.defined_type_at(ty, offset)?;
1920
+ let ComponentDefinedType::Future(_) = &types[ty] else {
1921
+ bail!(offset, "`future.cancel-write` requires a future type")
1922
+ };
1923
+
1924
+ self.core_funcs
1925
+ .push(types.intern_func_type(FuncType::new([ValType::I32], [ValType::I32]), offset));
1926
+ Ok(())
1927
+ }
1928
+
1929
+ fn future_drop_readable(
1930
+ &mut self,
1931
+ ty: u32,
1932
+ types: &mut TypeAlloc,
1933
+ offset: usize,
1934
+ ) -> Result<()> {
1935
+ if !self.features.cm_async() {
1936
+ bail!(
1937
+ offset,
1938
+ "`future.drop-readable` requires the component model async feature"
1939
+ )
1940
+ }
1941
+
1942
+ let ty = self.defined_type_at(ty, offset)?;
1943
+ let ComponentDefinedType::Future(_) = &types[ty] else {
1944
+ bail!(offset, "`future.drop-readable` requires a future type")
1945
+ };
1946
+
1947
+ self.core_funcs
1948
+ .push(types.intern_func_type(FuncType::new([ValType::I32], []), offset));
1949
+ Ok(())
1950
+ }
1951
+
1952
+ fn future_drop_writable(
1953
+ &mut self,
1954
+ ty: u32,
1955
+ types: &mut TypeAlloc,
1956
+ offset: usize,
1957
+ ) -> Result<()> {
1958
+ if !self.features.cm_async() {
1959
+ bail!(
1960
+ offset,
1961
+ "`future.drop-writable` requires the component model async feature"
1962
+ )
1963
+ }
1964
+
1965
+ let ty = self.defined_type_at(ty, offset)?;
1966
+ let ComponentDefinedType::Future(_) = &types[ty] else {
1967
+ bail!(offset, "`future.drop-writable` requires a future type")
1968
+ };
1969
+
1970
+ self.core_funcs
1971
+ .push(types.intern_func_type(FuncType::new([ValType::I32], []), offset));
1972
+ Ok(())
1973
+ }
1974
+
1975
+ fn error_context_new(
1976
+ &mut self,
1977
+ options: Vec<CanonicalOption>,
1978
+ types: &mut TypeAlloc,
1979
+ offset: usize,
1980
+ ) -> Result<()> {
1981
+ if !self.features.cm_error_context() {
1982
+ bail!(
1983
+ offset,
1984
+ "`error-context.new` requires the component model error-context feature"
1985
+ )
1986
+ }
1987
+
1988
+ let ty_id = self
1989
+ .check_options(types, &options, offset)?
1990
+ .require_memory(offset)?
1991
+ .require_sync(offset, "error-context.new")?
1992
+ .check_lower(offset)?
1993
+ .check_core_type(
1994
+ types,
1995
+ FuncType::new([ValType::I32; 2], [ValType::I32]),
1996
+ offset,
1997
+ )?;
1998
+
1999
+ self.core_funcs.push(ty_id);
2000
+ Ok(())
2001
+ }
2002
+
2003
+ fn error_context_debug_message(
2004
+ &mut self,
2005
+ options: Vec<CanonicalOption>,
2006
+ types: &mut TypeAlloc,
2007
+ offset: usize,
2008
+ ) -> Result<()> {
2009
+ if !self.features.cm_error_context() {
2010
+ bail!(
2011
+ offset,
2012
+ "`error-context.debug-message` requires the component model error-context feature"
2013
+ )
2014
+ }
2015
+
2016
+ let ty_id = self
2017
+ .check_options(types, &options, offset)?
2018
+ .require_memory(offset)?
2019
+ .require_realloc(offset)?
2020
+ .require_sync(offset, "error-context.debug-message")?
2021
+ .check_lower(offset)?
2022
+ .check_core_type(types, FuncType::new([ValType::I32; 2], []), offset)?;
2023
+
2024
+ self.core_funcs.push(ty_id);
2025
+ Ok(())
2026
+ }
2027
+
2028
+ fn error_context_drop(&mut self, types: &mut TypeAlloc, offset: usize) -> Result<()> {
2029
+ if !self.features.cm_error_context() {
2030
+ bail!(
2031
+ offset,
2032
+ "`error-context.drop` requires the component model error-context feature"
2033
+ )
2034
+ }
2035
+
2036
+ self.core_funcs
2037
+ .push(types.intern_func_type(FuncType::new([ValType::I32], []), offset));
2038
+ Ok(())
2039
+ }
2040
+
2041
+ fn waitable_set_new(&mut self, types: &mut TypeAlloc, offset: usize) -> Result<()> {
2042
+ if !self.features.cm_async() {
2043
+ bail!(
2044
+ offset,
2045
+ "`waitable-set.new` requires the component model async feature"
2046
+ )
2047
+ }
2048
+
2049
+ self.core_funcs
2050
+ .push(types.intern_func_type(FuncType::new([], [ValType::I32]), offset));
2051
+ Ok(())
2052
+ }
2053
+
2054
+ fn waitable_set_wait(
2055
+ &mut self,
2056
+ cancellable: bool,
2057
+ memory: u32,
2058
+ types: &mut TypeAlloc,
2059
+ offset: usize,
2060
+ ) -> Result<()> {
2061
+ if !self.features.cm_async() {
2062
+ bail!(
2063
+ offset,
2064
+ "`waitable-set.wait` requires the component model async feature"
2065
+ )
2066
+ }
2067
+ if cancellable && !self.features.cm_async_stackful() {
2068
+ bail!(
2069
+ offset,
2070
+ "cancellable `waitable-set.wait` requires the component model async stackful feature"
2071
+ )
2072
+ }
2073
+
2074
+ self.cabi_memory_at(memory, offset)?;
2075
+
2076
+ self.core_funcs
2077
+ .push(types.intern_func_type(FuncType::new([ValType::I32; 2], [ValType::I32]), offset));
2078
+ Ok(())
2079
+ }
2080
+
2081
+ fn waitable_set_poll(
2082
+ &mut self,
2083
+ cancellable: bool,
2084
+ memory: u32,
2085
+ types: &mut TypeAlloc,
2086
+ offset: usize,
2087
+ ) -> Result<()> {
2088
+ if !self.features.cm_async() {
2089
+ bail!(
2090
+ offset,
2091
+ "`waitable-set.poll` requires the component model async feature"
2092
+ )
2093
+ }
2094
+ if cancellable && !self.features.cm_async_stackful() {
2095
+ bail!(
2096
+ offset,
2097
+ "cancellable `waitable-set.poll` requires the component model async stackful feature"
2098
+ )
2099
+ }
2100
+
2101
+ self.cabi_memory_at(memory, offset)?;
2102
+
2103
+ self.core_funcs
2104
+ .push(types.intern_func_type(FuncType::new([ValType::I32; 2], [ValType::I32]), offset));
2105
+ Ok(())
2106
+ }
2107
+
2108
+ fn waitable_set_drop(&mut self, types: &mut TypeAlloc, offset: usize) -> Result<()> {
2109
+ if !self.features.cm_async() {
2110
+ bail!(
2111
+ offset,
2112
+ "`waitable-set.drop` requires the component model async feature"
2113
+ )
2114
+ }
2115
+
2116
+ self.core_funcs
2117
+ .push(types.intern_func_type(FuncType::new([ValType::I32], []), offset));
2118
+ Ok(())
2119
+ }
2120
+
2121
+ fn waitable_join(&mut self, types: &mut TypeAlloc, offset: usize) -> Result<()> {
2122
+ if !self.features.cm_async() {
2123
+ bail!(
2124
+ offset,
2125
+ "`waitable.join` requires the component model async feature"
2126
+ )
2127
+ }
2128
+
2129
+ self.core_funcs
2130
+ .push(types.intern_func_type(FuncType::new([ValType::I32; 2], []), offset));
2131
+ Ok(())
2132
+ }
2133
+
2134
+ fn thread_index(&mut self, types: &mut TypeAlloc, offset: usize) -> Result<()> {
2135
+ if !self.features.cm_threading() {
2136
+ bail!(
2137
+ offset,
2138
+ "`thread.index` requires the component model threading feature"
2139
+ )
2140
+ }
2141
+
2142
+ self.core_funcs
2143
+ .push(types.intern_func_type(FuncType::new([], [ValType::I32]), offset));
2144
+ Ok(())
2145
+ }
2146
+
2147
+ fn thread_new_indirect(
2148
+ &mut self,
2149
+ func_ty_index: u32,
2150
+ table_index: u32,
2151
+ types: &mut TypeAlloc,
2152
+ offset: usize,
2153
+ ) -> Result<()> {
2154
+ if !self.features.cm_threading() {
2155
+ bail!(
2156
+ offset,
2157
+ "`thread.new-indirect` requires the component model threading feature"
2158
+ )
2159
+ }
2160
+
2161
+ let core_type_id = match self.core_type_at(func_ty_index, offset)? {
2162
+ ComponentCoreTypeId::Sub(c) => c,
2163
+ ComponentCoreTypeId::Module(_) => bail!(offset, "expected a core function type"),
2164
+ };
2165
+ let sub_ty = &types[core_type_id];
2166
+ match &sub_ty.composite_type.inner {
2167
+ CompositeInnerType::Func(func_ty) => {
2168
+ if func_ty.params() != [ValType::I32] {
2169
+ bail!(
2170
+ offset,
2171
+ "start function must take a single `i32` argument (currently)"
2172
+ );
2173
+ }
2174
+ if func_ty.results() != [] {
2175
+ bail!(offset, "start function must not return any values");
2176
+ }
2177
+ }
2178
+ _ => bail!(offset, "start type must be a function"),
2179
+ }
2180
+
2181
+ let table = self.table_at(table_index, offset)?;
2182
+
2183
+ SubtypeCx::table_type(
2184
+ table,
2185
+ &TableType {
2186
+ initial: 0,
2187
+ maximum: None,
2188
+ table64: false,
2189
+ shared: false,
2190
+ element_type: RefType::FUNCREF,
2191
+ },
2192
+ offset,
2193
+ )
2194
+ .map_err(|mut e| {
2195
+ e.add_context("table is not a 32-bit table of (ref null (func))".into());
2196
+ e
2197
+ })?;
2198
+
2199
+ self.core_funcs.push(types.intern_func_type(
2200
+ FuncType::new([ValType::I32, ValType::I32], [ValType::I32]),
2201
+ offset,
2202
+ ));
2203
+ Ok(())
2204
+ }
2205
+
2206
+ fn thread_switch_to(
2207
+ &mut self,
2208
+ _cancellable: bool,
2209
+ types: &mut TypeAlloc,
2210
+ offset: usize,
2211
+ ) -> Result<()> {
2212
+ if !self.features.cm_threading() {
2213
+ bail!(
2214
+ offset,
2215
+ "`thread.switch_to` requires the component model threading feature"
2216
+ )
2217
+ }
2218
+
2219
+ self.core_funcs
2220
+ .push(types.intern_func_type(FuncType::new([ValType::I32], [ValType::I32]), offset));
2221
+ Ok(())
2222
+ }
2223
+
2224
+ fn thread_suspend(
2225
+ &mut self,
2226
+ _cancellable: bool,
2227
+ types: &mut TypeAlloc,
2228
+ offset: usize,
2229
+ ) -> Result<()> {
2230
+ if !self.features.cm_threading() {
2231
+ bail!(
2232
+ offset,
2233
+ "`thread.suspend` requires the component model threading feature"
2234
+ )
2235
+ }
2236
+ self.core_funcs
2237
+ .push(types.intern_func_type(FuncType::new([], [ValType::I32]), offset));
2238
+ Ok(())
2239
+ }
2240
+
2241
+ fn thread_resume_later(&mut self, types: &mut TypeAlloc, offset: usize) -> Result<()> {
2242
+ if !self.features.cm_threading() {
2243
+ bail!(
2244
+ offset,
2245
+ "`thread.resume_later` requires the component model threading feature"
2246
+ )
2247
+ }
2248
+ self.core_funcs
2249
+ .push(types.intern_func_type(FuncType::new([ValType::I32], []), offset));
2250
+ Ok(())
2251
+ }
2252
+
2253
+ fn thread_yield_to(
2254
+ &mut self,
2255
+ _cancellable: bool,
2256
+ types: &mut TypeAlloc,
2257
+ offset: usize,
2258
+ ) -> Result<()> {
2259
+ if !self.features.cm_threading() {
2260
+ bail!(
2261
+ offset,
2262
+ "`thread.yield_to` requires the component model threading feature"
2263
+ )
2264
+ }
2265
+ self.core_funcs
2266
+ .push(types.intern_func_type(FuncType::new([ValType::I32], [ValType::I32]), offset));
2267
+ Ok(())
2268
+ }
2269
+
2270
+ fn check_local_resource(&self, idx: u32, types: &TypeList, offset: usize) -> Result<ValType> {
2271
+ let resource = self.resource_at(idx, types, offset)?;
2272
+ match self
2273
+ .defined_resources
2274
+ .get(&resource.resource())
2275
+ .and_then(|rep| *rep)
2276
+ {
2277
+ Some(ty) => Ok(ty),
2278
+ None => bail!(offset, "type {idx} is not a local resource"),
2279
+ }
2280
+ }
2281
+
2282
+ fn resource_at<'a>(
2283
+ &self,
2284
+ idx: u32,
2285
+ _types: &'a TypeList,
2286
+ offset: usize,
2287
+ ) -> Result<AliasableResourceId> {
2288
+ if let ComponentAnyTypeId::Resource(id) = self.component_type_at(idx, offset)? {
2289
+ return Ok(id);
2290
+ }
2291
+ bail!(offset, "type index {} is not a resource type", idx)
2292
+ }
2293
+
2294
+ fn thread_spawn_ref(
2295
+ &mut self,
2296
+ func_ty_index: u32,
2297
+ types: &mut TypeAlloc,
2298
+ offset: usize,
2299
+ ) -> Result<()> {
2300
+ if !self.features.shared_everything_threads() {
2301
+ bail!(
2302
+ offset,
2303
+ "`thread.spawn-ref` requires the shared-everything-threads proposal"
2304
+ )
2305
+ }
2306
+ let core_type_id = self.validate_spawn_type(func_ty_index, types, offset)?;
2307
+
2308
+ // Insert the core function.
2309
+ let packed_index = PackedIndex::from_id(core_type_id).ok_or_else(|| {
2310
+ format_err!(offset, "implementation limit: too many types in `TypeList`")
2311
+ })?;
2312
+ let start_func_ref = RefType::concrete(true, packed_index);
2313
+ let func_ty = FuncType::new([ValType::Ref(start_func_ref), ValType::I32], [ValType::I32]);
2314
+ let core_ty = SubType::func(func_ty, true);
2315
+ let id = types.intern_sub_type(core_ty, offset);
2316
+ self.core_funcs.push(id);
2317
+
2318
+ Ok(())
2319
+ }
2320
+
2321
+ fn thread_spawn_indirect(
2322
+ &mut self,
2323
+ func_ty_index: u32,
2324
+ table_index: u32,
2325
+ types: &mut TypeAlloc,
2326
+ offset: usize,
2327
+ ) -> Result<()> {
2328
+ if !self.features.shared_everything_threads() {
2329
+ bail!(
2330
+ offset,
2331
+ "`thread.spawn-indirect` requires the shared-everything-threads proposal"
2332
+ )
2333
+ }
2334
+ let _ = self.validate_spawn_type(func_ty_index, types, offset)?;
2335
+
2336
+ // Check this much like `call_indirect` (see
2337
+ // `OperatorValidatorTemp::check_call_indirect_ty`), but loosen the
2338
+ // table type restrictions to just a `funcref`. See the component model
2339
+ // for more details:
2340
+ // https://github.com/WebAssembly/component-model/blob/main/design/mvp/CanonicalABI.md#-canon-threadspawn-indirect.
2341
+ let table = self.table_at(table_index, offset)?;
2342
+
2343
+ SubtypeCx::table_type(
2344
+ table,
2345
+ &TableType {
2346
+ initial: 0,
2347
+ maximum: None,
2348
+ table64: false,
2349
+ shared: true,
2350
+ element_type: RefType::FUNCREF
2351
+ .shared()
2352
+ .expect("a funcref can always be shared"),
2353
+ },
2354
+ offset,
2355
+ )
2356
+ .map_err(|mut e| {
2357
+ e.add_context("table is not a 32-bit shared table of (ref null (shared func))".into());
2358
+ e
2359
+ })?;
2360
+
2361
+ // Insert the core function.
2362
+ let func_ty = FuncType::new([ValType::I32, ValType::I32], [ValType::I32]);
2363
+ let core_ty = SubType::func(func_ty, true);
2364
+ let id = types.intern_sub_type(core_ty, offset);
2365
+ self.core_funcs.push(id);
2366
+
2367
+ Ok(())
2368
+ }
2369
+
2370
+ /// Validates the type of a `thread.spawn*` instruction.
2371
+ ///
2372
+ /// This is currently limited to shared functions with the signature `[i32]
2373
+ /// -> []`. See component model [explanation] for more details.
2374
+ ///
2375
+ /// [explanation]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/CanonicalABI.md#-canon-threadspawn-ref
2376
+ fn validate_spawn_type(
2377
+ &self,
2378
+ func_ty_index: u32,
2379
+ types: &TypeAlloc,
2380
+ offset: usize,
2381
+ ) -> Result<CoreTypeId> {
2382
+ let core_type_id = match self.core_type_at(func_ty_index, offset)? {
2383
+ ComponentCoreTypeId::Sub(c) => c,
2384
+ ComponentCoreTypeId::Module(_) => bail!(offset, "expected a core function type"),
2385
+ };
2386
+ let sub_ty = &types[core_type_id];
2387
+ if !sub_ty.composite_type.shared {
2388
+ bail!(offset, "spawn type must be shared");
2389
+ }
2390
+ match &sub_ty.composite_type.inner {
2391
+ CompositeInnerType::Func(func_ty) => {
2392
+ if func_ty.params() != [ValType::I32] {
2393
+ bail!(
2394
+ offset,
2395
+ "spawn function must take a single `i32` argument (currently)"
2396
+ );
2397
+ }
2398
+ if func_ty.results() != [] {
2399
+ bail!(offset, "spawn function must not return any values");
2400
+ }
2401
+ }
2402
+ _ => bail!(offset, "spawn type must be a function"),
2403
+ }
2404
+ Ok(core_type_id)
2405
+ }
2406
+
2407
+ fn thread_available_parallelism(&mut self, types: &mut TypeAlloc, offset: usize) -> Result<()> {
2408
+ if !self.features.shared_everything_threads() {
2409
+ bail!(
2410
+ offset,
2411
+ "`thread.available_parallelism` requires the shared-everything-threads proposal"
2412
+ )
2413
+ }
2414
+
2415
+ let func_ty = FuncType::new([], [ValType::I32]);
2416
+ let core_ty = SubType::func(func_ty, true);
2417
+ let id = types.intern_sub_type(core_ty, offset);
2418
+ self.core_funcs.push(id);
2419
+
2420
+ Ok(())
2421
+ }
2422
+
2423
+ pub fn add_component(&mut self, component: ComponentType, types: &mut TypeAlloc) -> Result<()> {
2424
+ let id = types.push_ty(component);
2425
+ self.components.push(id);
2426
+ Ok(())
2427
+ }
2428
+
2429
+ pub fn add_instance(
2430
+ &mut self,
2431
+ instance: crate::ComponentInstance,
2432
+ types: &mut TypeAlloc,
2433
+ offset: usize,
2434
+ ) -> Result<()> {
2435
+ let instance = match instance {
2436
+ crate::ComponentInstance::Instantiate {
2437
+ component_index,
2438
+ args,
2439
+ } => self.instantiate_component(component_index, args.into_vec(), types, offset)?,
2440
+ crate::ComponentInstance::FromExports(exports) => {
2441
+ self.instantiate_component_exports(exports.into_vec(), types, offset)?
2442
+ }
2443
+ };
2444
+
2445
+ self.instances.push(instance);
2446
+
2447
+ Ok(())
2448
+ }
2449
+
2450
+ pub fn add_alias(
2451
+ components: &mut [Self],
2452
+ alias: crate::ComponentAlias,
2453
+ types: &mut TypeAlloc,
2454
+ offset: usize,
2455
+ ) -> Result<()> {
2456
+ match alias {
2457
+ crate::ComponentAlias::InstanceExport {
2458
+ instance_index,
2459
+ kind,
2460
+ name,
2461
+ } => components.last_mut().unwrap().alias_instance_export(
2462
+ instance_index,
2463
+ kind,
2464
+ name,
2465
+ types,
2466
+ offset,
2467
+ ),
2468
+ crate::ComponentAlias::CoreInstanceExport {
2469
+ instance_index,
2470
+ kind,
2471
+ name,
2472
+ } => components.last_mut().unwrap().alias_core_instance_export(
2473
+ instance_index,
2474
+ kind,
2475
+ name,
2476
+ types,
2477
+ offset,
2478
+ ),
2479
+ crate::ComponentAlias::Outer { kind, count, index } => match kind {
2480
+ ComponentOuterAliasKind::CoreModule => {
2481
+ Self::alias_module(components, count, index, offset)
2482
+ }
2483
+ ComponentOuterAliasKind::CoreType => {
2484
+ Self::alias_core_type(components, count, index, offset)
2485
+ }
2486
+ ComponentOuterAliasKind::Type => {
2487
+ Self::alias_type(components, count, index, types, offset)
2488
+ }
2489
+ ComponentOuterAliasKind::Component => {
2490
+ Self::alias_component(components, count, index, offset)
2491
+ }
2492
+ },
2493
+ }
2494
+ }
2495
+
2496
+ pub fn add_start(
2497
+ &mut self,
2498
+ func_index: u32,
2499
+ args: &[u32],
2500
+ results: u32,
2501
+ types: &mut TypeList,
2502
+ offset: usize,
2503
+ ) -> Result<()> {
2504
+ if !self.features.cm_values() {
2505
+ bail!(
2506
+ offset,
2507
+ "support for component model `value`s is not enabled"
2508
+ );
2509
+ }
2510
+ if self.has_start {
2511
+ return Err(BinaryReaderError::new(
2512
+ "component cannot have more than one start function",
2513
+ offset,
2514
+ ));
2515
+ }
2516
+
2517
+ let ft = &types[self.function_at(func_index, offset)?];
2518
+
2519
+ if ft.params.len() != args.len() {
2520
+ bail!(
2521
+ offset,
2522
+ "component start function requires {} arguments but was given {}",
2523
+ ft.params.len(),
2524
+ args.len()
2525
+ );
2526
+ }
2527
+
2528
+ if u32::from(ft.result.is_some()) != results {
2529
+ bail!(
2530
+ offset,
2531
+ "component start function has a result count of {results} \
2532
+ but the function type has a result count of {type_results}",
2533
+ type_results = u32::from(ft.result.is_some()),
2534
+ );
2535
+ }
2536
+
2537
+ let cx = SubtypeCx::new(types, types);
2538
+ for (i, ((_, ty), arg)) in ft.params.iter().zip(args).enumerate() {
2539
+ // Ensure the value's type is a subtype of the parameter type
2540
+ cx.component_val_type(self.value_at(*arg, offset)?, ty, offset)
2541
+ .with_context(|| {
2542
+ format!("value type mismatch for component start function argument {i}")
2543
+ })?;
2544
+ }
2545
+
2546
+ if let Some(ty) = ft.result {
2547
+ self.values.push((ty, false));
2548
+ }
2549
+
2550
+ self.has_start = true;
2551
+
2552
+ Ok(())
2553
+ }
2554
+
2555
+ fn check_options(
2556
+ &self,
2557
+ types: &TypeList,
2558
+ options: &[CanonicalOption],
2559
+ offset: usize,
2560
+ ) -> Result<CanonicalOptions> {
2561
+ fn display(option: CanonicalOption) -> &'static str {
2562
+ match option {
2563
+ CanonicalOption::UTF8 => "utf8",
2564
+ CanonicalOption::UTF16 => "utf16",
2565
+ CanonicalOption::CompactUTF16 => "latin1-utf16",
2566
+ CanonicalOption::Memory(_) => "memory",
2567
+ CanonicalOption::Realloc(_) => "realloc",
2568
+ CanonicalOption::PostReturn(_) => "post-return",
2569
+ CanonicalOption::Async => "async",
2570
+ CanonicalOption::Callback(_) => "callback",
2571
+ CanonicalOption::CoreType(_) => "core-type",
2572
+ CanonicalOption::Gc => "gc",
2573
+ }
2574
+ }
2575
+
2576
+ let mut encoding = None;
2577
+ let mut memory = None;
2578
+ let mut realloc = None;
2579
+ let mut post_return = None;
2580
+ let mut is_async = false;
2581
+ let mut callback = None;
2582
+ let mut core_type = None;
2583
+ let mut gc = false;
2584
+
2585
+ for option in options {
2586
+ match option {
2587
+ CanonicalOption::UTF8 | CanonicalOption::UTF16 | CanonicalOption::CompactUTF16 => {
2588
+ match encoding {
2589
+ Some(existing) => {
2590
+ bail!(
2591
+ offset,
2592
+ "canonical encoding option `{existing}` conflicts with option `{}`",
2593
+ display(*option),
2594
+ )
2595
+ }
2596
+ None => {
2597
+ encoding = Some(match option {
2598
+ CanonicalOption::UTF8 => StringEncoding::Utf8,
2599
+ CanonicalOption::UTF16 => StringEncoding::Utf16,
2600
+ CanonicalOption::CompactUTF16 => StringEncoding::CompactUtf16,
2601
+ _ => unreachable!(),
2602
+ });
2603
+ }
2604
+ }
2605
+ }
2606
+ CanonicalOption::Memory(idx) => {
2607
+ memory = match memory {
2608
+ None => {
2609
+ self.cabi_memory_at(*idx, offset)?;
2610
+ Some(*idx)
2611
+ }
2612
+ Some(_) => {
2613
+ return Err(BinaryReaderError::new(
2614
+ "canonical option `memory` is specified more than once",
2615
+ offset,
2616
+ ));
2617
+ }
2618
+ }
2619
+ }
2620
+ CanonicalOption::Realloc(idx) => {
2621
+ realloc = match realloc {
2622
+ None => {
2623
+ let ty_id = self.core_function_at(*idx, offset)?;
2624
+ let func_ty = types[ty_id].unwrap_func();
2625
+ if func_ty.params()
2626
+ != [ValType::I32, ValType::I32, ValType::I32, ValType::I32]
2627
+ || func_ty.results() != [ValType::I32]
2628
+ {
2629
+ return Err(BinaryReaderError::new(
2630
+ "canonical option `realloc` uses a core function with an incorrect signature",
2631
+ offset,
2632
+ ));
2633
+ }
2634
+ Some(*idx)
2635
+ }
2636
+ Some(_) => {
2637
+ return Err(BinaryReaderError::new(
2638
+ "canonical option `realloc` is specified more than once",
2639
+ offset,
2640
+ ));
2641
+ }
2642
+ }
2643
+ }
2644
+ CanonicalOption::PostReturn(idx) => {
2645
+ post_return = match post_return {
2646
+ None => Some(*idx),
2647
+ Some(_) => {
2648
+ return Err(BinaryReaderError::new(
2649
+ "canonical option `post-return` is specified more than once",
2650
+ offset,
2651
+ ));
2652
+ }
2653
+ }
2654
+ }
2655
+ CanonicalOption::Async => {
2656
+ if is_async {
2657
+ return Err(BinaryReaderError::new(
2658
+ "canonical option `async` is specified more than once",
2659
+ offset,
2660
+ ));
2661
+ } else {
2662
+ if !self.features.cm_async() {
2663
+ bail!(
2664
+ offset,
2665
+ "canonical option `async` requires the component model async feature"
2666
+ );
2667
+ }
2668
+
2669
+ is_async = true;
2670
+ }
2671
+ }
2672
+ CanonicalOption::Callback(idx) => {
2673
+ callback = match callback {
2674
+ None => Some(*idx),
2675
+ Some(_) => {
2676
+ return Err(BinaryReaderError::new(
2677
+ "canonical option `callback` is specified more than once",
2678
+ offset,
2679
+ ));
2680
+ }
2681
+ }
2682
+ }
2683
+ CanonicalOption::CoreType(idx) => {
2684
+ core_type = match core_type {
2685
+ None => {
2686
+ if !self.features.cm_gc() {
2687
+ bail!(
2688
+ offset,
2689
+ "canonical option `core type` requires the component model gc feature"
2690
+ )
2691
+ }
2692
+ let ty = match self.core_type_at(*idx, offset)? {
2693
+ ComponentCoreTypeId::Sub(ty) => ty,
2694
+ ComponentCoreTypeId::Module(_) => {
2695
+ return Err(BinaryReaderError::new(
2696
+ "canonical option `core type` must reference a core function \
2697
+ type",
2698
+ offset,
2699
+ ));
2700
+ }
2701
+ };
2702
+ match &types[ty].composite_type.inner {
2703
+ CompositeInnerType::Func(_) => {}
2704
+ CompositeInnerType::Array(_)
2705
+ | CompositeInnerType::Struct(_)
2706
+ | CompositeInnerType::Cont(_) => {
2707
+ return Err(BinaryReaderError::new(
2708
+ "canonical option `core type` must reference a core function \
2709
+ type",
2710
+ offset,
2711
+ ));
2712
+ }
2713
+ }
2714
+ Some(ty)
2715
+ }
2716
+ Some(_) => {
2717
+ return Err(BinaryReaderError::new(
2718
+ "canonical option `core type` is specified more than once",
2719
+ offset,
2720
+ ));
2721
+ }
2722
+ };
2723
+ }
2724
+ CanonicalOption::Gc => {
2725
+ if gc {
2726
+ return Err(BinaryReaderError::new(
2727
+ "canonical option `gc` is specified more than once",
2728
+ offset,
2729
+ ));
2730
+ }
2731
+ if !self.features.cm_gc() {
2732
+ return Err(BinaryReaderError::new(
2733
+ "canonical option `gc` requires the `cm-gc` feature",
2734
+ offset,
2735
+ ));
2736
+ }
2737
+ gc = true;
2738
+ }
2739
+ }
2740
+ }
2741
+
2742
+ let string_encoding = encoding.unwrap_or_default();
2743
+
2744
+ let concurrency = match (is_async, callback, post_return.is_some()) {
2745
+ (false, Some(_), _) => {
2746
+ bail!(offset, "cannot specify callback without async")
2747
+ }
2748
+ (true, _, true) => {
2749
+ bail!(offset, "cannot specify post-return function in async")
2750
+ }
2751
+ (false, None, _) => Concurrency::Sync,
2752
+ (true, callback, false) => Concurrency::Async { callback },
2753
+ };
2754
+
2755
+ if !gc && core_type.is_some() {
2756
+ bail!(offset, "cannot specify `core-type` without `gc`")
2757
+ }
2758
+
2759
+ Ok(CanonicalOptions {
2760
+ string_encoding,
2761
+ memory,
2762
+ realloc,
2763
+ post_return,
2764
+ concurrency,
2765
+ core_type,
2766
+ gc,
2767
+ })
2768
+ }
2769
+
2770
+ fn check_type_ref(
2771
+ &mut self,
2772
+ ty: &ComponentTypeRef,
2773
+ types: &mut TypeAlloc,
2774
+ offset: usize,
2775
+ ) -> Result<ComponentEntityType> {
2776
+ Ok(match ty {
2777
+ ComponentTypeRef::Module(index) => {
2778
+ let id = self.core_type_at(*index, offset)?;
2779
+ match id {
2780
+ ComponentCoreTypeId::Sub(_) => {
2781
+ bail!(offset, "core type index {index} is not a module type")
2782
+ }
2783
+ ComponentCoreTypeId::Module(id) => ComponentEntityType::Module(id),
2784
+ }
2785
+ }
2786
+ ComponentTypeRef::Func(index) => {
2787
+ let id = self.component_type_at(*index, offset)?;
2788
+ match id {
2789
+ ComponentAnyTypeId::Func(id) => ComponentEntityType::Func(id),
2790
+ _ => bail!(offset, "type index {index} is not a function type"),
2791
+ }
2792
+ }
2793
+ ComponentTypeRef::Value(ty) => {
2794
+ self.check_value_support(offset)?;
2795
+ let ty = match ty {
2796
+ crate::ComponentValType::Primitive(ty) => ComponentValType::Primitive(*ty),
2797
+ crate::ComponentValType::Type(index) => {
2798
+ ComponentValType::Type(self.defined_type_at(*index, offset)?)
2799
+ }
2800
+ };
2801
+ ComponentEntityType::Value(ty)
2802
+ }
2803
+ ComponentTypeRef::Type(TypeBounds::Eq(index)) => {
2804
+ let referenced = self.component_type_at(*index, offset)?;
2805
+ let created = types.with_unique(referenced);
2806
+ ComponentEntityType::Type {
2807
+ referenced,
2808
+ created,
2809
+ }
2810
+ }
2811
+ ComponentTypeRef::Type(TypeBounds::SubResource) => {
2812
+ let id = types.alloc_resource_id();
2813
+ ComponentEntityType::Type {
2814
+ referenced: id.into(),
2815
+ created: id.into(),
2816
+ }
2817
+ }
2818
+ ComponentTypeRef::Instance(index) => {
2819
+ let id = self.component_type_at(*index, offset)?;
2820
+ match id {
2821
+ ComponentAnyTypeId::Instance(id) => ComponentEntityType::Instance(id),
2822
+ _ => bail!(offset, "type index {index} is not an instance type"),
2823
+ }
2824
+ }
2825
+ ComponentTypeRef::Component(index) => {
2826
+ let id = self.component_type_at(*index, offset)?;
2827
+ match id {
2828
+ ComponentAnyTypeId::Component(id) => ComponentEntityType::Component(id),
2829
+ _ => bail!(offset, "type index {index} is not a component type"),
2830
+ }
2831
+ }
2832
+ })
2833
+ }
2834
+
2835
+ pub fn export_to_entity_type(
2836
+ &mut self,
2837
+ export: &crate::ComponentExport,
2838
+ types: &mut TypeAlloc,
2839
+ offset: usize,
2840
+ ) -> Result<ComponentEntityType> {
2841
+ let actual = match export.kind {
2842
+ ComponentExternalKind::Module => {
2843
+ ComponentEntityType::Module(self.module_at(export.index, offset)?)
2844
+ }
2845
+ ComponentExternalKind::Func => {
2846
+ ComponentEntityType::Func(self.function_at(export.index, offset)?)
2847
+ }
2848
+ ComponentExternalKind::Value => {
2849
+ self.check_value_support(offset)?;
2850
+ ComponentEntityType::Value(*self.value_at(export.index, offset)?)
2851
+ }
2852
+ ComponentExternalKind::Type => {
2853
+ let referenced = self.component_type_at(export.index, offset)?;
2854
+ let created = types.with_unique(referenced);
2855
+ ComponentEntityType::Type {
2856
+ referenced,
2857
+ created,
2858
+ }
2859
+ }
2860
+ ComponentExternalKind::Instance => {
2861
+ ComponentEntityType::Instance(self.instance_at(export.index, offset)?)
2862
+ }
2863
+ ComponentExternalKind::Component => {
2864
+ ComponentEntityType::Component(self.component_at(export.index, offset)?)
2865
+ }
2866
+ };
2867
+
2868
+ let ascribed = match &export.ty {
2869
+ Some(ty) => self.check_type_ref(ty, types, offset)?,
2870
+ None => return Ok(actual),
2871
+ };
2872
+
2873
+ SubtypeCx::new(types, types)
2874
+ .component_entity_type(&actual, &ascribed, offset)
2875
+ .with_context(|| "ascribed type of export is not compatible with item's type")?;
2876
+
2877
+ Ok(ascribed)
2878
+ }
2879
+
2880
+ fn create_module_type(
2881
+ components: &[Self],
2882
+ decls: Vec<crate::ModuleTypeDeclaration>,
2883
+ types: &mut TypeAlloc,
2884
+ offset: usize,
2885
+ ) -> Result<ModuleType> {
2886
+ let mut state = Module::new(components[0].features);
2887
+
2888
+ for decl in decls {
2889
+ match decl {
2890
+ crate::ModuleTypeDeclaration::Type(rec) => {
2891
+ state.add_types(rec, types, offset, true)?;
2892
+ }
2893
+ crate::ModuleTypeDeclaration::Export { name, mut ty } => {
2894
+ let ty = state.check_type_ref(&mut ty, types, offset)?;
2895
+ state.add_export(name, ty, offset, true, types)?;
2896
+ }
2897
+ crate::ModuleTypeDeclaration::OuterAlias { kind, count, index } => {
2898
+ match kind {
2899
+ crate::OuterAliasKind::Type => {
2900
+ let ty = if count == 0 {
2901
+ // Local alias, check the local module state
2902
+ ComponentCoreTypeId::Sub(state.type_id_at(index, offset)?)
2903
+ } else {
2904
+ // Otherwise, check the enclosing component state
2905
+ let component =
2906
+ Self::check_alias_count(components, count - 1, offset)?;
2907
+ component.core_type_at(index, offset)?
2908
+ };
2909
+
2910
+ check_max(state.types.len(), 1, MAX_WASM_TYPES, "types", offset)?;
2911
+
2912
+ match ty {
2913
+ ComponentCoreTypeId::Sub(ty) => state.types.push(ty),
2914
+ // TODO https://github.com/WebAssembly/component-model/issues/265
2915
+ ComponentCoreTypeId::Module(_) => bail!(
2916
+ offset,
2917
+ "not implemented: aliasing core module types into a core \
2918
+ module's types index space"
2919
+ ),
2920
+ }
2921
+ }
2922
+ }
2923
+ }
2924
+ crate::ModuleTypeDeclaration::Import(import) => {
2925
+ state.add_import(import, types, offset)?;
2926
+ }
2927
+ }
2928
+ }
2929
+
2930
+ let imports = state.imports_for_module_type(offset)?;
2931
+
2932
+ Ok(ModuleType {
2933
+ info: TypeInfo::core(state.type_size),
2934
+ imports,
2935
+ exports: state.exports,
2936
+ })
2937
+ }
2938
+
2939
+ fn create_component_type(
2940
+ components: &mut Vec<Self>,
2941
+ decls: Vec<crate::ComponentTypeDeclaration>,
2942
+ types: &mut TypeAlloc,
2943
+ offset: usize,
2944
+ ) -> Result<ComponentType> {
2945
+ let features = components[0].features;
2946
+ components.push(ComponentState::new(ComponentKind::ComponentType, features));
2947
+
2948
+ for decl in decls {
2949
+ match decl {
2950
+ crate::ComponentTypeDeclaration::CoreType(ty) => {
2951
+ Self::add_core_type(components, ty, types, offset, true)?;
2952
+ }
2953
+ crate::ComponentTypeDeclaration::Type(ty) => {
2954
+ Self::add_type(components, ty, types, offset, true)?;
2955
+ }
2956
+ crate::ComponentTypeDeclaration::Export { name, ty } => {
2957
+ let current = components.last_mut().unwrap();
2958
+ let ty = current.check_type_ref(&ty, types, offset)?;
2959
+ current.add_export(name, ty, types, offset, true)?;
2960
+ }
2961
+ crate::ComponentTypeDeclaration::Import(import) => {
2962
+ components
2963
+ .last_mut()
2964
+ .unwrap()
2965
+ .add_import(import, types, offset)?;
2966
+ }
2967
+ crate::ComponentTypeDeclaration::Alias(alias) => {
2968
+ Self::add_alias(components, alias, types, offset)?;
2969
+ }
2970
+ };
2971
+ }
2972
+
2973
+ components.pop().unwrap().finish(types, offset)
2974
+ }
2975
+
2976
+ fn create_instance_type(
2977
+ components: &mut Vec<Self>,
2978
+ decls: Vec<crate::InstanceTypeDeclaration>,
2979
+ types: &mut TypeAlloc,
2980
+ offset: usize,
2981
+ ) -> Result<ComponentInstanceType> {
2982
+ let features = components[0].features;
2983
+ components.push(ComponentState::new(ComponentKind::InstanceType, features));
2984
+
2985
+ for decl in decls {
2986
+ match decl {
2987
+ crate::InstanceTypeDeclaration::CoreType(ty) => {
2988
+ Self::add_core_type(components, ty, types, offset, true)?;
2989
+ }
2990
+ crate::InstanceTypeDeclaration::Type(ty) => {
2991
+ Self::add_type(components, ty, types, offset, true)?;
2992
+ }
2993
+ crate::InstanceTypeDeclaration::Export { name, ty } => {
2994
+ let current = components.last_mut().unwrap();
2995
+ let ty = current.check_type_ref(&ty, types, offset)?;
2996
+ current.add_export(name, ty, types, offset, true)?;
2997
+ }
2998
+ crate::InstanceTypeDeclaration::Alias(alias) => {
2999
+ Self::add_alias(components, alias, types, offset)?;
3000
+ }
3001
+ };
3002
+ }
3003
+
3004
+ let mut state = components.pop().unwrap();
3005
+
3006
+ assert!(state.imported_resources.is_empty());
3007
+
3008
+ Ok(ComponentInstanceType {
3009
+ info: state.type_info,
3010
+
3011
+ // The defined resources for this instance type are those listed on
3012
+ // the component state. The path to each defined resource is
3013
+ // guaranteed to live within the `explicit_resources` map since,
3014
+ // when in the type context, the introduction of any defined
3015
+ // resource must have been done with `(export "x" (type (sub
3016
+ // resource)))` which, in a sense, "fuses" the introduction of the
3017
+ // variable with the export. This means that all defined resources,
3018
+ // if any, should be guaranteed to have an `explicit_resources` path
3019
+ // listed.
3020
+ defined_resources: mem::take(&mut state.defined_resources)
3021
+ .into_iter()
3022
+ .map(|(id, rep)| {
3023
+ assert!(rep.is_none());
3024
+ id
3025
+ })
3026
+ .collect(),
3027
+
3028
+ // The map of what resources are explicitly exported and where
3029
+ // they're exported is plumbed through as-is.
3030
+ explicit_resources: mem::take(&mut state.explicit_resources),
3031
+
3032
+ exports: mem::take(&mut state.exports),
3033
+ })
3034
+ }
3035
+
3036
+ fn create_function_type(
3037
+ &self,
3038
+ ty: crate::ComponentFuncType,
3039
+ types: &TypeList,
3040
+ offset: usize,
3041
+ ) -> Result<ComponentFuncType> {
3042
+ let mut info = TypeInfo::new();
3043
+
3044
+ if ty.async_ && !self.features.cm_async() {
3045
+ bail!(
3046
+ offset,
3047
+ "async component functions require the component model async feature"
3048
+ );
3049
+ }
3050
+
3051
+ let mut set = Set::default();
3052
+ set.reserve(core::cmp::max(
3053
+ ty.params.len(),
3054
+ usize::from(ty.result.is_some()),
3055
+ ));
3056
+
3057
+ let params = ty
3058
+ .params
3059
+ .iter()
3060
+ .map(|(name, ty)| {
3061
+ let name: &KebabStr = to_kebab_str(name, "function parameter", offset)?;
3062
+ if !set.insert(name) {
3063
+ bail!(
3064
+ offset,
3065
+ "function parameter name `{name}` conflicts with previous parameter name `{prev}`",
3066
+ prev = set.get(&name).unwrap(),
3067
+ );
3068
+ }
3069
+
3070
+ let ty = self.create_component_val_type(*ty, offset)?;
3071
+ info.combine(ty.info(types), offset)?;
3072
+ Ok((name.to_owned(), ty))
3073
+ })
3074
+ .collect::<Result<_>>()?;
3075
+
3076
+ set.clear();
3077
+
3078
+ let result = ty
3079
+ .result
3080
+ .map(|ty| {
3081
+ let ty = self.create_component_val_type(ty, offset)?;
3082
+ let ty_info = ty.info(types);
3083
+ if ty_info.contains_borrow() {
3084
+ bail!(offset, "function result cannot contain a `borrow` type");
3085
+ }
3086
+ info.combine(ty.info(types), offset)?;
3087
+ Ok(ty)
3088
+ })
3089
+ .transpose()?;
3090
+
3091
+ Ok(ComponentFuncType {
3092
+ async_: ty.async_,
3093
+ info,
3094
+ params,
3095
+ result,
3096
+ })
3097
+ }
3098
+
3099
+ fn instantiate_core_module(
3100
+ &self,
3101
+ module_index: u32,
3102
+ module_args: Vec<crate::InstantiationArg>,
3103
+ types: &mut TypeAlloc,
3104
+ offset: usize,
3105
+ ) -> Result<ComponentCoreInstanceTypeId> {
3106
+ fn insert_arg<'a>(
3107
+ name: &'a str,
3108
+ arg: &'a InstanceType,
3109
+ args: &mut IndexMap<&'a str, &'a InstanceType>,
3110
+ offset: usize,
3111
+ ) -> Result<()> {
3112
+ if args.insert(name, arg).is_some() {
3113
+ bail!(
3114
+ offset,
3115
+ "duplicate module instantiation argument named `{name}`"
3116
+ );
3117
+ }
3118
+
3119
+ Ok(())
3120
+ }
3121
+
3122
+ let module_type_id = self.module_at(module_index, offset)?;
3123
+ let mut args = IndexMap::default();
3124
+
3125
+ // Populate the arguments
3126
+ for module_arg in module_args {
3127
+ match module_arg.kind {
3128
+ InstantiationArgKind::Instance => {
3129
+ let instance_type = &types[self.core_instance_at(module_arg.index, offset)?];
3130
+ insert_arg(module_arg.name, instance_type, &mut args, offset)?;
3131
+ }
3132
+ }
3133
+ }
3134
+
3135
+ // Validate the arguments
3136
+ let module_type = &types[module_type_id];
3137
+ let cx = SubtypeCx::new(types, types);
3138
+ for ((module, name), expected) in module_type.imports.iter() {
3139
+ let instance = args.get(module.as_str()).ok_or_else(|| {
3140
+ format_err!(
3141
+ offset,
3142
+ "missing module instantiation argument named `{module}`"
3143
+ )
3144
+ })?;
3145
+
3146
+ let arg = instance
3147
+ .internal_exports(types)
3148
+ .get(name.as_str())
3149
+ .ok_or_else(|| {
3150
+ format_err!(
3151
+ offset,
3152
+ "module instantiation argument `{module}` does not \
3153
+ export an item named `{name}`",
3154
+ )
3155
+ })?;
3156
+
3157
+ cx.entity_type(arg, expected, offset).with_context(|| {
3158
+ format!(
3159
+ "type mismatch for export `{name}` of module \
3160
+ instantiation argument `{module}`"
3161
+ )
3162
+ })?;
3163
+ }
3164
+
3165
+ let mut info = TypeInfo::new();
3166
+ for (_, ty) in module_type.exports.iter() {
3167
+ info.combine(ty.info(types), offset)?;
3168
+ }
3169
+
3170
+ Ok(types.push_ty(InstanceType {
3171
+ info,
3172
+ kind: CoreInstanceTypeKind::Instantiated(module_type_id),
3173
+ }))
3174
+ }
3175
+
3176
+ fn instantiate_component(
3177
+ &mut self,
3178
+ component_index: u32,
3179
+ component_args: Vec<crate::ComponentInstantiationArg>,
3180
+ types: &mut TypeAlloc,
3181
+ offset: usize,
3182
+ ) -> Result<ComponentInstanceTypeId> {
3183
+ let component_type_id = self.component_at(component_index, offset)?;
3184
+ let mut args = IndexMap::default();
3185
+
3186
+ // Populate the arguments
3187
+ for component_arg in component_args {
3188
+ let ty = match component_arg.kind {
3189
+ ComponentExternalKind::Module => {
3190
+ ComponentEntityType::Module(self.module_at(component_arg.index, offset)?)
3191
+ }
3192
+ ComponentExternalKind::Component => {
3193
+ ComponentEntityType::Component(self.component_at(component_arg.index, offset)?)
3194
+ }
3195
+ ComponentExternalKind::Instance => {
3196
+ ComponentEntityType::Instance(self.instance_at(component_arg.index, offset)?)
3197
+ }
3198
+ ComponentExternalKind::Func => {
3199
+ ComponentEntityType::Func(self.function_at(component_arg.index, offset)?)
3200
+ }
3201
+ ComponentExternalKind::Value => {
3202
+ self.check_value_support(offset)?;
3203
+ ComponentEntityType::Value(*self.value_at(component_arg.index, offset)?)
3204
+ }
3205
+ ComponentExternalKind::Type => {
3206
+ let ty = self.component_type_at(component_arg.index, offset)?;
3207
+ ComponentEntityType::Type {
3208
+ referenced: ty,
3209
+ created: ty,
3210
+ }
3211
+ }
3212
+ };
3213
+ match args.entry(component_arg.name.to_string()) {
3214
+ Entry::Occupied(e) => {
3215
+ bail!(
3216
+ offset,
3217
+ "instantiation argument `{name}` conflicts with previous argument `{prev}`",
3218
+ prev = e.key(),
3219
+ name = component_arg.name
3220
+ );
3221
+ }
3222
+ Entry::Vacant(e) => {
3223
+ e.insert(ty);
3224
+ }
3225
+ }
3226
+ }
3227
+
3228
+ // Here comes the fun part of the component model, we're instantiating
3229
+ // the component with type `component_type_id` with the `args`
3230
+ // specified. Easy enough!
3231
+ //
3232
+ // This operation, however, is one of the lynchpins of safety in the
3233
+ // component model. Additionally what this ends up implementing ranges
3234
+ // from "well just check the types are equal" to "let's have a
3235
+ // full-blown ML-style module type system in the component model". There
3236
+ // are primarily two major tricky pieces to the component model which
3237
+ // make this operation, instantiating components, hard:
3238
+ //
3239
+ // 1. Components can import and exports other components. This means
3240
+ // that arguments to instantiation are along the lines of functions
3241
+ // being passed to functions or similar. Effectively this means that
3242
+ // the term "variance" comes into play with either contravariance
3243
+ // or covariance depending on where you are in typechecking. This is
3244
+ // one of the main rationales, however, that this check below is a
3245
+ // check for subtyping as opposed to exact type equivalence. For
3246
+ // example an instance that exports something is a subtype of an
3247
+ // instance that exports nothing. Components get a bit trick since
3248
+ // they both have imports and exports. My way of thinking about it
3249
+ // is "who's asking for what". If you're asking for imports then
3250
+ // I need to at least supply those imports, but I can possibly
3251
+ // supply more. If you're asking for a thing which you'll give a set
3252
+ // of imports, then I can give you something which takes less imports
3253
+ // because what you give still suffices. (things like that). The
3254
+ // real complication with components, however, comes with...
3255
+ //
3256
+ // 2. Resources. Resources in the component model are akin to "abstract
3257
+ // types". They're not abstract in the sense that they have no
3258
+ // representation, they're always backed by a 32-bit integer right
3259
+ // now. Instead they're abstract in the sense that some components
3260
+ // aren't allowed to understand the representation of a resource.
3261
+ // For example if you import a resource you can't get the underlying
3262
+ // internals of it. Furthermore the resource is strictly tracked
3263
+ // within the component with `own` and `borrow` runtime semantics.
3264
+ // The hardest part about resources, though, is handling them as
3265
+ // part of instantiation and subtyping.
3266
+ //
3267
+ // For example one major aspect of resources is that if a component
3268
+ // exports a resource then each instantiation of the component
3269
+ // produces a fresh resource type. This means that the type recorded
3270
+ // for the instantiation here can't simply be "I instantiated
3271
+ // component X" since in such a situation the type of all
3272
+ // instantiations would be the same, which they aren't.
3273
+ //
3274
+ // This sort of subtlety comes up quite frequently for resources.
3275
+ // This file contains references to `imported_resources` and
3276
+ // `defined_resources` for example which refer to the formal
3277
+ // nature of components and their abstract variables. Specifically
3278
+ // for instantiation though we're eventually faced with the problem
3279
+ // of subtype checks where resource subtyping is defined as "does
3280
+ // your id equal mine". Naively implemented that means anything with
3281
+ // resources isn't subtypes of anything else since resource ids are
3282
+ // unique between components. Instead what actually needs to happen
3283
+ // is types need to be substituted.
3284
+ //
3285
+ // Much of the complexity here is not actually apparent here in this
3286
+ // literal one function. Instead it's spread out across validation
3287
+ // in this file and type-checking in the `types.rs` module. Note that
3288
+ // the "spread out" nature isn't because we're bad maintainers
3289
+ // (hopefully), but rather it's quite infectious how many parts need
3290
+ // to handle resources and account for defined/imported variables.
3291
+ //
3292
+ // For example only one subtyping method is called here where `args` is
3293
+ // passed in. This method is quite recursive in its nature though and
3294
+ // will internally touch all the fields that this file maintains to
3295
+ // end up putting into various bits and pieces of type information.
3296
+ //
3297
+ // Unfortunately there's probably not really a succinct way to read
3298
+ // this method and understand everything. If you've written ML module
3299
+ // type systems this will probably look quite familiar, but otherwise
3300
+ // the whole system is not really easily approachable at this time. It's
3301
+ // hoped in the future that there's a formalism to refer to which will
3302
+ // make things more clear as the code would be able to reference this
3303
+ // hypothetical formalism. Until that's the case, though, these
3304
+ // comments are hopefully enough when augmented with communication with
3305
+ // the authors.
3306
+
3307
+ let component_type = &types[component_type_id];
3308
+ let mut exports = component_type.exports.clone();
3309
+ let mut info = TypeInfo::new();
3310
+ for (_, ty) in component_type.exports.iter() {
3311
+ info.combine(ty.info(types), offset)?;
3312
+ }
3313
+
3314
+ // Perform the subtype check that `args` matches the imports of
3315
+ // `component_type_id`. The result of this subtype check is the
3316
+ // production of a mapping of resource types from the imports to the
3317
+ // arguments provided. This is a substitution map which is then used
3318
+ // below to perform a substitution into the exports of the instance
3319
+ // since the types of the exports are now in terms of whatever was
3320
+ // supplied as imports.
3321
+ let mut mapping = SubtypeCx::new(types, types).open_instance_type(
3322
+ &args,
3323
+ component_type_id,
3324
+ ExternKind::Import,
3325
+ offset,
3326
+ )?;
3327
+
3328
+ // Part of the instantiation of a component is that all of its
3329
+ // defined resources become "fresh" on each instantiation. This
3330
+ // means that each instantiation of a component gets brand new type
3331
+ // variables representing its defined resources, modeling that each
3332
+ // instantiation produces distinct types. The freshening is performed
3333
+ // here by allocating new ids and inserting them into `mapping`.
3334
+ //
3335
+ // Note that technically the `mapping` from subtyping should be applied
3336
+ // first and then the mapping for freshening should be applied
3337
+ // afterwards. The keys of the map from subtyping are the imported
3338
+ // resources from this component which are disjoint from its defined
3339
+ // resources. That means it should be possible to place everything
3340
+ // into one large map which maps from:
3341
+ //
3342
+ // * the component's imported resources go to whatever was explicitly
3343
+ // supplied in the import map
3344
+ // * the component's defined resources go to fresh new resources
3345
+ //
3346
+ // These two remapping operations can then get folded into one by
3347
+ // placing everything in the same `mapping` and using that for a remap
3348
+ // only once.
3349
+ let fresh_defined_resources = (0..component_type.defined_resources.len())
3350
+ .map(|_| types.alloc_resource_id().resource())
3351
+ .collect::<IndexSet<_>>();
3352
+ let component_type = &types[component_type_id];
3353
+ for ((old, _path), new) in component_type
3354
+ .defined_resources
3355
+ .iter()
3356
+ .zip(&fresh_defined_resources)
3357
+ {
3358
+ let prev = mapping.resources.insert(*old, *new);
3359
+ assert!(prev.is_none());
3360
+ }
3361
+
3362
+ // Perform the remapping operation over all the exports that will be
3363
+ // listed for the final instance type. Note that this is performed
3364
+ // both for all the export types in addition to the explicitly exported
3365
+ // resources list.
3366
+ //
3367
+ // Note that this is a crucial step of the instantiation process which
3368
+ // is intentionally transforming the type of a component based on the
3369
+ // variables provided by imports and additionally ensuring that all
3370
+ // references to the component's defined resources are rebound to the
3371
+ // fresh ones introduced just above.
3372
+ for entity in exports.values_mut() {
3373
+ types.remap_component_entity(entity, &mut mapping);
3374
+ }
3375
+ let component_type = &types[component_type_id];
3376
+ let explicit_resources = component_type
3377
+ .explicit_resources
3378
+ .iter()
3379
+ .map(|(id, path)| {
3380
+ (
3381
+ mapping.resources.get(id).copied().unwrap_or(*id),
3382
+ path.clone(),
3383
+ )
3384
+ })
3385
+ .collect::<IndexMap<_, _>>();
3386
+
3387
+ // Technically in the last formalism that was consulted in writing this
3388
+ // implementation there are two further steps that are part of the
3389
+ // instantiation process:
3390
+ //
3391
+ // 1. The set of defined resources from the instance created, which are
3392
+ // added to the outer component, is the subset of the instance's
3393
+ // original defined resources and the free variables of the exports.
3394
+ //
3395
+ // 2. Each element of this subset is required to be "explicit in" the
3396
+ // instance, or otherwise explicitly exported somewhere within the
3397
+ // instance.
3398
+ //
3399
+ // With the syntactic structure of the component model, however, neither
3400
+ // of these conditions should be necessary. The main reason for this is
3401
+ // that this function is specifically dealing with instantiation of
3402
+ // components which should already have these properties validated
3403
+ // about them. Subsequently we shouldn't have to re-check them.
3404
+ //
3405
+ // In debug mode, however, do a sanity check.
3406
+ if cfg!(debug_assertions) {
3407
+ let mut free = IndexSet::default();
3408
+ for ty in exports.values() {
3409
+ types.free_variables_component_entity(ty, &mut free);
3410
+ }
3411
+ assert!(fresh_defined_resources.is_subset(&free));
3412
+ for resource in fresh_defined_resources.iter() {
3413
+ assert!(explicit_resources.contains_key(resource));
3414
+ }
3415
+ }
3416
+
3417
+ // And as the final step of the instantiation process all of the
3418
+ // new defined resources from this component instantiation are moved
3419
+ // onto `self`. Note that concrete instances never have defined
3420
+ // resources (see more comments in `instantiate_exports`) so the
3421
+ // `defined_resources` listing in the final type is always empty. This
3422
+ // represents how by having a concrete instance the definitions
3423
+ // referred to in that instance are now problems for the outer
3424
+ // component rather than the inner instance since the instance is bound
3425
+ // to the component.
3426
+ //
3427
+ // All defined resources here have no known representation, so they're
3428
+ // all listed with `None`. Also note that none of the resources were
3429
+ // exported yet so `self.explicit_resources` is not updated yet. If
3430
+ // this instance is exported, however, it'll consult the type's
3431
+ // `explicit_resources` array and use that appropriately.
3432
+ for resource in fresh_defined_resources {
3433
+ self.defined_resources.insert(resource, None);
3434
+ }
3435
+
3436
+ Ok(types.push_ty(ComponentInstanceType {
3437
+ info,
3438
+ defined_resources: Default::default(),
3439
+ explicit_resources,
3440
+ exports,
3441
+ }))
3442
+ }
3443
+
3444
+ fn instantiate_component_exports(
3445
+ &mut self,
3446
+ exports: Vec<crate::ComponentExport>,
3447
+ types: &mut TypeAlloc,
3448
+ offset: usize,
3449
+ ) -> Result<ComponentInstanceTypeId> {
3450
+ let mut info = TypeInfo::new();
3451
+ let mut inst_exports = IndexMap::default();
3452
+ let mut explicit_resources = IndexMap::default();
3453
+ let mut export_names = IndexSet::default();
3454
+
3455
+ // NB: It's intentional that this context is empty since no indices are
3456
+ // introduced in the bag-of-exports construct which means there's no
3457
+ // way syntactically to register something inside of this.
3458
+ let names = ComponentNameContext::default();
3459
+
3460
+ for export in exports {
3461
+ assert!(export.ty.is_none());
3462
+ let ty = match export.kind {
3463
+ ComponentExternalKind::Module => {
3464
+ ComponentEntityType::Module(self.module_at(export.index, offset)?)
3465
+ }
3466
+ ComponentExternalKind::Component => {
3467
+ ComponentEntityType::Component(self.component_at(export.index, offset)?)
3468
+ }
3469
+ ComponentExternalKind::Instance => {
3470
+ let ty = self.instance_at(export.index, offset)?;
3471
+
3472
+ // When an instance is exported from an instance then
3473
+ // all explicitly exported resources on the sub-instance are
3474
+ // now also listed as exported resources on the outer
3475
+ // instance, just with one more element in their path.
3476
+ explicit_resources.extend(types[ty].explicit_resources.iter().map(
3477
+ |(id, path)| {
3478
+ let mut new_path = vec![inst_exports.len()];
3479
+ new_path.extend(path);
3480
+ (*id, new_path)
3481
+ },
3482
+ ));
3483
+ ComponentEntityType::Instance(ty)
3484
+ }
3485
+ ComponentExternalKind::Func => {
3486
+ ComponentEntityType::Func(self.function_at(export.index, offset)?)
3487
+ }
3488
+ ComponentExternalKind::Value => {
3489
+ self.check_value_support(offset)?;
3490
+ ComponentEntityType::Value(*self.value_at(export.index, offset)?)
3491
+ }
3492
+ ComponentExternalKind::Type => {
3493
+ let ty = self.component_type_at(export.index, offset)?;
3494
+ // If this is an export of a resource type be sure to
3495
+ // record that in the explicit list with the appropriate
3496
+ // path because if this instance ends up getting used
3497
+ // it'll count towards the "explicit in" check.
3498
+ if let ComponentAnyTypeId::Resource(id) = ty {
3499
+ explicit_resources.insert(id.resource(), vec![inst_exports.len()]);
3500
+ }
3501
+ ComponentEntityType::Type {
3502
+ referenced: ty,
3503
+ // The created type index here isn't used anywhere
3504
+ // in index spaces because a "bag of exports"
3505
+ // doesn't build up its own index spaces. Just fill
3506
+ // in the same index here in this case as what's
3507
+ // referenced.
3508
+ created: ty,
3509
+ }
3510
+ }
3511
+ };
3512
+
3513
+ names.validate_extern(
3514
+ export.name.0,
3515
+ ExternKind::Export,
3516
+ &ty,
3517
+ types,
3518
+ offset,
3519
+ &mut export_names,
3520
+ &mut inst_exports,
3521
+ &mut info,
3522
+ &self.features,
3523
+ )?;
3524
+ }
3525
+
3526
+ Ok(types.push_ty(ComponentInstanceType {
3527
+ info,
3528
+ explicit_resources,
3529
+ exports: inst_exports,
3530
+
3531
+ // NB: the list of defined resources for this instance itself
3532
+ // is always empty. Even if this instance exports resources,
3533
+ // it's empty.
3534
+ //
3535
+ // The reason for this is a bit subtle. The general idea, though, is
3536
+ // that the defined resources list here is only used for instance
3537
+ // types that are sort of "floating around" and haven't actually
3538
+ // been attached to something yet. For example when an instance type
3539
+ // is simply declared it can have defined resources introduced
3540
+ // through `(export "name" (type (sub resource)))`. These
3541
+ // definitions, however, are local to the instance itself and aren't
3542
+ // defined elsewhere.
3543
+ //
3544
+ // Here, though, no new definitions were introduced. The instance
3545
+ // created here is a "bag of exports" which could only refer to
3546
+ // preexisting items. This means that inherently no new resources
3547
+ // were created so there's nothing to put in this list. Any
3548
+ // resources referenced by the instance must be bound by the outer
3549
+ // component context or further above.
3550
+ //
3551
+ // Furthermore, however, actual instances of instances, which this
3552
+ // is, aren't allowed to have defined resources. Instead the
3553
+ // resources would have to be injected into the outer component
3554
+ // enclosing the instance. That means that even if bag-of-exports
3555
+ // could declare a new resource then the resource would be moved
3556
+ // from here to `self.defined_resources`. This doesn't exist at this
3557
+ // time, though, so this still remains empty and
3558
+ // `self.defined_resources` remains unperturbed.
3559
+ defined_resources: Default::default(),
3560
+ }))
3561
+ }
3562
+
3563
+ fn instantiate_core_exports(
3564
+ &mut self,
3565
+ exports: Vec<crate::Export>,
3566
+ types: &mut TypeAlloc,
3567
+ offset: usize,
3568
+ ) -> Result<ComponentCoreInstanceTypeId> {
3569
+ fn insert_export(
3570
+ types: &TypeList,
3571
+ name: &str,
3572
+ export: EntityType,
3573
+ exports: &mut IndexMap<String, EntityType>,
3574
+ info: &mut TypeInfo,
3575
+ offset: usize,
3576
+ ) -> Result<()> {
3577
+ info.combine(export.info(types), offset)?;
3578
+
3579
+ if exports.insert(name.to_string(), export).is_some() {
3580
+ bail!(
3581
+ offset,
3582
+ "duplicate instantiation export name `{name}` already defined",
3583
+ )
3584
+ }
3585
+
3586
+ Ok(())
3587
+ }
3588
+
3589
+ let mut info = TypeInfo::new();
3590
+ let mut inst_exports = IndexMap::default();
3591
+ for export in exports {
3592
+ match export.kind {
3593
+ ExternalKind::Func | ExternalKind::FuncExact => {
3594
+ insert_export(
3595
+ types,
3596
+ export.name,
3597
+ EntityType::Func(self.core_function_at(export.index, offset)?),
3598
+ &mut inst_exports,
3599
+ &mut info,
3600
+ offset,
3601
+ )?;
3602
+ }
3603
+ ExternalKind::Table => insert_export(
3604
+ types,
3605
+ export.name,
3606
+ EntityType::Table(*self.table_at(export.index, offset)?),
3607
+ &mut inst_exports,
3608
+ &mut info,
3609
+ offset,
3610
+ )?,
3611
+ ExternalKind::Memory => insert_export(
3612
+ types,
3613
+ export.name,
3614
+ EntityType::Memory(*self.memory_at(export.index, offset)?),
3615
+ &mut inst_exports,
3616
+ &mut info,
3617
+ offset,
3618
+ )?,
3619
+ ExternalKind::Global => {
3620
+ insert_export(
3621
+ types,
3622
+ export.name,
3623
+ EntityType::Global(*self.global_at(export.index, offset)?),
3624
+ &mut inst_exports,
3625
+ &mut info,
3626
+ offset,
3627
+ )?;
3628
+ }
3629
+ ExternalKind::Tag => {
3630
+ if !self.features.exceptions() {
3631
+ bail!(offset, "exceptions proposal not enabled");
3632
+ }
3633
+ insert_export(
3634
+ types,
3635
+ export.name,
3636
+ EntityType::Tag(self.tag_at(export.index, offset)?),
3637
+ &mut inst_exports,
3638
+ &mut info,
3639
+ offset,
3640
+ )?
3641
+ }
3642
+ }
3643
+ }
3644
+
3645
+ Ok(types.push_ty(InstanceType {
3646
+ info,
3647
+ kind: CoreInstanceTypeKind::Exports(inst_exports),
3648
+ }))
3649
+ }
3650
+
3651
+ fn alias_core_instance_export(
3652
+ &mut self,
3653
+ instance_index: u32,
3654
+ kind: ExternalKind,
3655
+ name: &str,
3656
+ types: &TypeList,
3657
+ offset: usize,
3658
+ ) -> Result<()> {
3659
+ macro_rules! push_module_export {
3660
+ ($expected:path, $collection:ident, $ty:literal) => {{
3661
+ match self.core_instance_export(instance_index, name, types, offset)? {
3662
+ $expected(ty) => {
3663
+ self.$collection.push(*ty);
3664
+ }
3665
+ _ => {
3666
+ bail!(
3667
+ offset,
3668
+ "export `{name}` for core instance {instance_index} is not a {}",
3669
+ $ty
3670
+ )
3671
+ }
3672
+ }
3673
+ }};
3674
+ }
3675
+
3676
+ match kind {
3677
+ ExternalKind::Func | ExternalKind::FuncExact => {
3678
+ check_max(
3679
+ self.function_count(),
3680
+ 1,
3681
+ MAX_WASM_FUNCTIONS,
3682
+ "functions",
3683
+ offset,
3684
+ )?;
3685
+ push_module_export!(EntityType::Func, core_funcs, "function");
3686
+ }
3687
+ ExternalKind::Table => {
3688
+ check_max(
3689
+ self.core_tables.len(),
3690
+ 1,
3691
+ MAX_CORE_INDEX_SPACE_ITEMS,
3692
+ "tables",
3693
+ offset,
3694
+ )?;
3695
+ push_module_export!(EntityType::Table, core_tables, "table");
3696
+ }
3697
+ ExternalKind::Memory => {
3698
+ check_max(
3699
+ self.core_memories.len(),
3700
+ 1,
3701
+ MAX_CORE_INDEX_SPACE_ITEMS,
3702
+ "memories",
3703
+ offset,
3704
+ )?;
3705
+ push_module_export!(EntityType::Memory, core_memories, "memory");
3706
+ }
3707
+ ExternalKind::Global => {
3708
+ check_max(
3709
+ self.core_globals.len(),
3710
+ 1,
3711
+ MAX_CORE_INDEX_SPACE_ITEMS,
3712
+ "globals",
3713
+ offset,
3714
+ )?;
3715
+ push_module_export!(EntityType::Global, core_globals, "global");
3716
+ }
3717
+ ExternalKind::Tag => {
3718
+ if !self.features.exceptions() {
3719
+ bail!(offset, "exceptions proposal not enabled");
3720
+ }
3721
+ check_max(
3722
+ self.core_tags.len(),
3723
+ 1,
3724
+ MAX_CORE_INDEX_SPACE_ITEMS,
3725
+ "tags",
3726
+ offset,
3727
+ )?;
3728
+ push_module_export!(EntityType::Tag, core_tags, "tag");
3729
+ }
3730
+ }
3731
+
3732
+ Ok(())
3733
+ }
3734
+
3735
+ fn alias_instance_export(
3736
+ &mut self,
3737
+ instance_index: u32,
3738
+ kind: ComponentExternalKind,
3739
+ name: &str,
3740
+ types: &mut TypeAlloc,
3741
+ offset: usize,
3742
+ ) -> Result<()> {
3743
+ if let ComponentExternalKind::Value = kind {
3744
+ self.check_value_support(offset)?;
3745
+ }
3746
+ let mut ty = match types[self.instance_at(instance_index, offset)?]
3747
+ .exports
3748
+ .get(name)
3749
+ {
3750
+ Some(ty) => *ty,
3751
+ None => bail!(
3752
+ offset,
3753
+ "instance {instance_index} has no export named `{name}`"
3754
+ ),
3755
+ };
3756
+
3757
+ let ok = match (&ty, kind) {
3758
+ (ComponentEntityType::Module(_), ComponentExternalKind::Module) => true,
3759
+ (ComponentEntityType::Module(_), _) => false,
3760
+ (ComponentEntityType::Component(_), ComponentExternalKind::Component) => true,
3761
+ (ComponentEntityType::Component(_), _) => false,
3762
+ (ComponentEntityType::Func(_), ComponentExternalKind::Func) => true,
3763
+ (ComponentEntityType::Func(_), _) => false,
3764
+ (ComponentEntityType::Instance(_), ComponentExternalKind::Instance) => true,
3765
+ (ComponentEntityType::Instance(_), _) => false,
3766
+ (ComponentEntityType::Value(_), ComponentExternalKind::Value) => true,
3767
+ (ComponentEntityType::Value(_), _) => false,
3768
+ (ComponentEntityType::Type { .. }, ComponentExternalKind::Type) => true,
3769
+ (ComponentEntityType::Type { .. }, _) => false,
3770
+ };
3771
+ if !ok {
3772
+ bail!(
3773
+ offset,
3774
+ "export `{name}` for instance {instance_index} is not a {}",
3775
+ kind.desc(),
3776
+ );
3777
+ }
3778
+
3779
+ self.add_entity(&mut ty, None, types, offset)?;
3780
+ Ok(())
3781
+ }
3782
+
3783
+ fn alias_module(components: &mut [Self], count: u32, index: u32, offset: usize) -> Result<()> {
3784
+ let component = Self::check_alias_count(components, count, offset)?;
3785
+ let ty = component.module_at(index, offset)?;
3786
+
3787
+ let current = components.last_mut().unwrap();
3788
+ check_max(
3789
+ current.core_modules.len(),
3790
+ 1,
3791
+ MAX_WASM_MODULES,
3792
+ "modules",
3793
+ offset,
3794
+ )?;
3795
+
3796
+ current.core_modules.push(ty);
3797
+ Ok(())
3798
+ }
3799
+
3800
+ fn alias_component(
3801
+ components: &mut [Self],
3802
+ count: u32,
3803
+ index: u32,
3804
+ offset: usize,
3805
+ ) -> Result<()> {
3806
+ let component = Self::check_alias_count(components, count, offset)?;
3807
+ let ty = component.component_at(index, offset)?;
3808
+
3809
+ let current = components.last_mut().unwrap();
3810
+ check_max(
3811
+ current.components.len(),
3812
+ 1,
3813
+ MAX_WASM_COMPONENTS,
3814
+ "components",
3815
+ offset,
3816
+ )?;
3817
+
3818
+ current.components.push(ty);
3819
+ Ok(())
3820
+ }
3821
+
3822
+ fn alias_core_type(
3823
+ components: &mut [Self],
3824
+ count: u32,
3825
+ index: u32,
3826
+ offset: usize,
3827
+ ) -> Result<()> {
3828
+ let component = Self::check_alias_count(components, count, offset)?;
3829
+ let ty = component.core_type_at(index, offset)?;
3830
+
3831
+ let current = components.last_mut().unwrap();
3832
+ check_max(current.type_count(), 1, MAX_WASM_TYPES, "types", offset)?;
3833
+
3834
+ current.core_types.push(ty);
3835
+
3836
+ Ok(())
3837
+ }
3838
+
3839
+ fn alias_type(
3840
+ components: &mut [Self],
3841
+ count: u32,
3842
+ index: u32,
3843
+ types: &mut TypeAlloc,
3844
+ offset: usize,
3845
+ ) -> Result<()> {
3846
+ let component = Self::check_alias_count(components, count, offset)?;
3847
+ let ty = component.component_type_at(index, offset)?;
3848
+
3849
+ // If `count` "crossed a component boundary", meaning that it went from
3850
+ // one component to another, then this must additionally verify that
3851
+ // `ty` has no free variables with respect to resources. This is
3852
+ // intended to preserve the property for components where each component
3853
+ // is an isolated unit that can theoretically be extracted from other
3854
+ // components. If resources from other components were allowed to leak
3855
+ // in then it would prevent that.
3856
+ //
3857
+ // This check is done by calculating the `pos` within `components` that
3858
+ // our target `component` above was selected at. Once this is acquired
3859
+ // the component to the "right" is checked, and if that's a component
3860
+ // then it's considered as crossing a component boundary meaning the
3861
+ // free variables check runs.
3862
+ //
3863
+ // The reason this works is that in the list of `ComponentState` types
3864
+ // it's guaranteed that any `is_type` components are contiguous at the
3865
+ // end of the array. This means that if state one level deeper than the
3866
+ // target of this alias is a `!is_type` component, then the target must
3867
+ // be a component as well. If the one-level deeper state `is_type` then
3868
+ // the target is either a type or a component, both of which are valid
3869
+ // (as aliases can reach the enclosing component and have as many free
3870
+ // variables as they want).
3871
+ let pos_after_component = components.len() - (count as usize);
3872
+ if let Some(component) = components.get(pos_after_component) {
3873
+ if component.kind == ComponentKind::Component {
3874
+ let mut free = IndexSet::default();
3875
+ types.free_variables_any_type_id(ty, &mut free);
3876
+ if !free.is_empty() {
3877
+ bail!(
3878
+ offset,
3879
+ "cannot alias outer type which transitively refers \
3880
+ to resources not defined in the current component"
3881
+ );
3882
+ }
3883
+ }
3884
+ }
3885
+
3886
+ let current = components.last_mut().unwrap();
3887
+ check_max(current.type_count(), 1, MAX_WASM_TYPES, "types", offset)?;
3888
+
3889
+ current.types.push(ty);
3890
+
3891
+ Ok(())
3892
+ }
3893
+
3894
+ fn check_alias_count(components: &[Self], count: u32, offset: usize) -> Result<&Self> {
3895
+ let count = count as usize;
3896
+ if count >= components.len() {
3897
+ bail!(offset, "invalid outer alias count of {count}");
3898
+ }
3899
+
3900
+ Ok(&components[components.len() - count - 1])
3901
+ }
3902
+
3903
+ fn create_defined_type(
3904
+ &self,
3905
+ ty: crate::ComponentDefinedType,
3906
+ types: &TypeList,
3907
+ offset: usize,
3908
+ ) -> Result<ComponentDefinedType> {
3909
+ match ty {
3910
+ crate::ComponentDefinedType::Primitive(ty) => {
3911
+ self.check_primitive_type(ty, offset)?;
3912
+ Ok(ComponentDefinedType::Primitive(ty))
3913
+ }
3914
+ crate::ComponentDefinedType::Record(fields) => {
3915
+ self.create_record_type(fields.as_ref(), types, offset)
3916
+ }
3917
+ crate::ComponentDefinedType::Variant(cases) => {
3918
+ self.create_variant_type(cases.as_ref(), types, offset)
3919
+ }
3920
+ crate::ComponentDefinedType::List(ty) => Ok(ComponentDefinedType::List(
3921
+ self.create_component_val_type(ty, offset)?,
3922
+ )),
3923
+ crate::ComponentDefinedType::Map(key, value) => {
3924
+ if !self.features.cm_map() {
3925
+ bail!(offset, "Maps require the component model map feature")
3926
+ }
3927
+ Ok(ComponentDefinedType::Map(
3928
+ self.create_component_val_type(key, offset)?,
3929
+ self.create_component_val_type(value, offset)?,
3930
+ ))
3931
+ }
3932
+ crate::ComponentDefinedType::FixedSizeList(ty, elements) => {
3933
+ if !self.features.cm_fixed_size_list() {
3934
+ bail!(
3935
+ offset,
3936
+ "Fixed size lists require the component model fixed size list feature"
3937
+ )
3938
+ }
3939
+ if elements < 1 {
3940
+ bail!(offset, "Fixed size lists must have more than zero elements")
3941
+ }
3942
+ Ok(ComponentDefinedType::FixedSizeList(
3943
+ self.create_component_val_type(ty, offset)?,
3944
+ elements,
3945
+ ))
3946
+ }
3947
+ crate::ComponentDefinedType::Tuple(tys) => {
3948
+ self.create_tuple_type(tys.as_ref(), types, offset)
3949
+ }
3950
+ crate::ComponentDefinedType::Flags(names) => {
3951
+ self.create_flags_type(names.as_ref(), offset)
3952
+ }
3953
+ crate::ComponentDefinedType::Enum(cases) => {
3954
+ self.create_enum_type(cases.as_ref(), offset)
3955
+ }
3956
+ crate::ComponentDefinedType::Option(ty) => Ok(ComponentDefinedType::Option(
3957
+ self.create_component_val_type(ty, offset)?,
3958
+ )),
3959
+ crate::ComponentDefinedType::Result { ok, err } => Ok(ComponentDefinedType::Result {
3960
+ ok: ok
3961
+ .map(|ty| self.create_component_val_type(ty, offset))
3962
+ .transpose()?,
3963
+ err: err
3964
+ .map(|ty| self.create_component_val_type(ty, offset))
3965
+ .transpose()?,
3966
+ }),
3967
+ crate::ComponentDefinedType::Own(idx) => Ok(ComponentDefinedType::Own(
3968
+ self.resource_at(idx, types, offset)?,
3969
+ )),
3970
+ crate::ComponentDefinedType::Borrow(idx) => Ok(ComponentDefinedType::Borrow(
3971
+ self.resource_at(idx, types, offset)?,
3972
+ )),
3973
+ crate::ComponentDefinedType::Future(ty) => {
3974
+ if !self.features.cm_async() {
3975
+ bail!(
3976
+ offset,
3977
+ "`future` requires the component model async feature"
3978
+ )
3979
+ }
3980
+ Ok(ComponentDefinedType::Future(
3981
+ ty.map(|ty| self.create_component_val_type(ty, offset))
3982
+ .transpose()?,
3983
+ ))
3984
+ }
3985
+ crate::ComponentDefinedType::Stream(ty) => {
3986
+ if !self.features.cm_async() {
3987
+ bail!(
3988
+ offset,
3989
+ "`stream` requires the component model async feature"
3990
+ )
3991
+ }
3992
+ Ok(ComponentDefinedType::Stream(
3993
+ ty.map(|ty| self.create_component_val_type(ty, offset))
3994
+ .transpose()?,
3995
+ ))
3996
+ }
3997
+ }
3998
+ }
3999
+
4000
+ fn create_record_type(
4001
+ &self,
4002
+ fields: &[(&str, crate::ComponentValType)],
4003
+ types: &TypeList,
4004
+ offset: usize,
4005
+ ) -> Result<ComponentDefinedType> {
4006
+ let mut info = TypeInfo::new();
4007
+ let mut field_map = IndexMap::default();
4008
+ field_map.reserve(fields.len());
4009
+
4010
+ if fields.is_empty() {
4011
+ bail!(offset, "record type must have at least one field");
4012
+ }
4013
+
4014
+ for (name, ty) in fields {
4015
+ let name = to_kebab_str(name, "record field", offset)?;
4016
+ let ty = self.create_component_val_type(*ty, offset)?;
4017
+
4018
+ match field_map.entry(name.to_owned()) {
4019
+ Entry::Occupied(e) => bail!(
4020
+ offset,
4021
+ "record field name `{name}` conflicts with previous field name `{prev}`",
4022
+ prev = e.key()
4023
+ ),
4024
+ Entry::Vacant(e) => {
4025
+ info.combine(ty.info(types), offset)?;
4026
+ e.insert(ty);
4027
+ }
4028
+ }
4029
+ }
4030
+
4031
+ Ok(ComponentDefinedType::Record(RecordType {
4032
+ info,
4033
+ fields: field_map,
4034
+ }))
4035
+ }
4036
+
4037
+ fn create_variant_type(
4038
+ &self,
4039
+ cases: &[crate::VariantCase],
4040
+ types: &TypeList,
4041
+ offset: usize,
4042
+ ) -> Result<ComponentDefinedType> {
4043
+ let mut info = TypeInfo::new();
4044
+ let mut case_map: IndexMap<KebabString, VariantCase> = IndexMap::default();
4045
+ case_map.reserve(cases.len());
4046
+
4047
+ if cases.is_empty() {
4048
+ bail!(offset, "variant type must have at least one case");
4049
+ }
4050
+
4051
+ if cases.len() > u32::MAX as usize {
4052
+ return Err(BinaryReaderError::new(
4053
+ "variant type cannot be represented with a 32-bit discriminant value",
4054
+ offset,
4055
+ ));
4056
+ }
4057
+
4058
+ for (i, case) in cases.iter().enumerate() {
4059
+ if let Some(refines) = case.refines {
4060
+ if refines >= i as u32 {
4061
+ return Err(BinaryReaderError::new(
4062
+ "variant case can only refine a previously defined case",
4063
+ offset,
4064
+ ));
4065
+ }
4066
+ }
4067
+
4068
+ let name = to_kebab_str(case.name, "variant case", offset)?;
4069
+
4070
+ let ty = case
4071
+ .ty
4072
+ .map(|ty| self.create_component_val_type(ty, offset))
4073
+ .transpose()?;
4074
+
4075
+ match case_map.entry(name.to_owned()) {
4076
+ Entry::Occupied(e) => bail!(
4077
+ offset,
4078
+ "variant case name `{name}` conflicts with previous case name `{prev}`",
4079
+ name = case.name,
4080
+ prev = e.key()
4081
+ ),
4082
+ Entry::Vacant(e) => {
4083
+ if let Some(ty) = ty {
4084
+ info.combine(ty.info(types), offset)?;
4085
+ }
4086
+
4087
+ // Safety: the use of `KebabStr::new_unchecked` here is safe because the string
4088
+ // was already verified to be kebab case.
4089
+ e.insert(VariantCase {
4090
+ ty,
4091
+ refines: case
4092
+ .refines
4093
+ .map(|i| KebabStr::new_unchecked(cases[i as usize].name).to_owned()),
4094
+ });
4095
+ }
4096
+ }
4097
+ }
4098
+
4099
+ Ok(ComponentDefinedType::Variant(VariantType {
4100
+ info,
4101
+ cases: case_map,
4102
+ }))
4103
+ }
4104
+
4105
+ fn create_tuple_type(
4106
+ &self,
4107
+ tys: &[crate::ComponentValType],
4108
+ types: &TypeList,
4109
+ offset: usize,
4110
+ ) -> Result<ComponentDefinedType> {
4111
+ let mut info = TypeInfo::new();
4112
+ if tys.is_empty() {
4113
+ bail!(offset, "tuple type must have at least one type");
4114
+ }
4115
+ let types = tys
4116
+ .iter()
4117
+ .map(|ty| {
4118
+ let ty = self.create_component_val_type(*ty, offset)?;
4119
+ info.combine(ty.info(types), offset)?;
4120
+ Ok(ty)
4121
+ })
4122
+ .collect::<Result<_>>()?;
4123
+
4124
+ Ok(ComponentDefinedType::Tuple(TupleType { info, types }))
4125
+ }
4126
+
4127
+ fn create_flags_type(&self, names: &[&str], offset: usize) -> Result<ComponentDefinedType> {
4128
+ let mut names_set = IndexSet::default();
4129
+ names_set.reserve(names.len());
4130
+
4131
+ if names.is_empty() {
4132
+ bail!(offset, "flags must have at least one entry");
4133
+ }
4134
+
4135
+ if names.len() > 32 {
4136
+ bail!(offset, "cannot have more than 32 flags");
4137
+ }
4138
+
4139
+ for name in names {
4140
+ let name = to_kebab_str(name, "flag", offset)?;
4141
+ if !names_set.insert(name.to_owned()) {
4142
+ bail!(
4143
+ offset,
4144
+ "flag name `{name}` conflicts with previous flag name `{prev}`",
4145
+ prev = names_set.get(name).unwrap()
4146
+ );
4147
+ }
4148
+ }
4149
+
4150
+ Ok(ComponentDefinedType::Flags(names_set))
4151
+ }
4152
+
4153
+ fn create_enum_type(&self, cases: &[&str], offset: usize) -> Result<ComponentDefinedType> {
4154
+ if cases.len() > u32::MAX as usize {
4155
+ return Err(BinaryReaderError::new(
4156
+ "enumeration type cannot be represented with a 32-bit discriminant value",
4157
+ offset,
4158
+ ));
4159
+ }
4160
+
4161
+ if cases.is_empty() {
4162
+ bail!(offset, "enum type must have at least one variant");
4163
+ }
4164
+
4165
+ let mut tags = IndexSet::default();
4166
+ tags.reserve(cases.len());
4167
+
4168
+ for tag in cases {
4169
+ let tag = to_kebab_str(tag, "enum tag", offset)?;
4170
+ if !tags.insert(tag.to_owned()) {
4171
+ bail!(
4172
+ offset,
4173
+ "enum tag name `{tag}` conflicts with previous tag name `{prev}`",
4174
+ prev = tags.get(tag).unwrap()
4175
+ );
4176
+ }
4177
+ }
4178
+
4179
+ Ok(ComponentDefinedType::Enum(tags))
4180
+ }
4181
+
4182
+ fn create_component_val_type(
4183
+ &self,
4184
+ ty: crate::ComponentValType,
4185
+ offset: usize,
4186
+ ) -> Result<ComponentValType> {
4187
+ Ok(match ty {
4188
+ crate::ComponentValType::Primitive(pt) => {
4189
+ self.check_primitive_type(pt, offset)?;
4190
+ ComponentValType::Primitive(pt)
4191
+ }
4192
+ crate::ComponentValType::Type(idx) => {
4193
+ ComponentValType::Type(self.defined_type_at(idx, offset)?)
4194
+ }
4195
+ })
4196
+ }
4197
+
4198
+ pub fn core_type_at(&self, idx: u32, offset: usize) -> Result<ComponentCoreTypeId> {
4199
+ self.core_types
4200
+ .get(idx as usize)
4201
+ .copied()
4202
+ .ok_or_else(|| format_err!(offset, "unknown type {idx}: type index out of bounds"))
4203
+ }
4204
+
4205
+ pub fn component_type_at(&self, idx: u32, offset: usize) -> Result<ComponentAnyTypeId> {
4206
+ self.types
4207
+ .get(idx as usize)
4208
+ .copied()
4209
+ .ok_or_else(|| format_err!(offset, "unknown type {idx}: type index out of bounds"))
4210
+ }
4211
+
4212
+ fn function_type_at<'a>(
4213
+ &self,
4214
+ idx: u32,
4215
+ types: &'a TypeList,
4216
+ offset: usize,
4217
+ ) -> Result<&'a ComponentFuncType> {
4218
+ let id = self.component_type_at(idx, offset)?;
4219
+ match id {
4220
+ ComponentAnyTypeId::Func(id) => Ok(&types[id]),
4221
+ _ => bail!(offset, "type index {idx} is not a function type"),
4222
+ }
4223
+ }
4224
+
4225
+ fn function_at(&self, idx: u32, offset: usize) -> Result<ComponentFuncTypeId> {
4226
+ self.funcs.get(idx as usize).copied().ok_or_else(|| {
4227
+ format_err!(
4228
+ offset,
4229
+ "unknown function {idx}: function index out of bounds"
4230
+ )
4231
+ })
4232
+ }
4233
+
4234
+ fn component_at(&self, idx: u32, offset: usize) -> Result<ComponentTypeId> {
4235
+ self.components.get(idx as usize).copied().ok_or_else(|| {
4236
+ format_err!(
4237
+ offset,
4238
+ "unknown component {idx}: component index out of bounds"
4239
+ )
4240
+ })
4241
+ }
4242
+
4243
+ fn instance_at(&self, idx: u32, offset: usize) -> Result<ComponentInstanceTypeId> {
4244
+ self.instances.get(idx as usize).copied().ok_or_else(|| {
4245
+ format_err!(
4246
+ offset,
4247
+ "unknown instance {idx}: instance index out of bounds"
4248
+ )
4249
+ })
4250
+ }
4251
+
4252
+ fn value_at(&mut self, idx: u32, offset: usize) -> Result<&ComponentValType> {
4253
+ match self.values.get_mut(idx as usize) {
4254
+ Some((ty, used)) if !*used => {
4255
+ *used = true;
4256
+ Ok(ty)
4257
+ }
4258
+ Some(_) => bail!(offset, "value {idx} cannot be used more than once"),
4259
+ None => bail!(offset, "unknown value {idx}: value index out of bounds"),
4260
+ }
4261
+ }
4262
+
4263
+ fn defined_type_at(&self, idx: u32, offset: usize) -> Result<ComponentDefinedTypeId> {
4264
+ match self.component_type_at(idx, offset)? {
4265
+ ComponentAnyTypeId::Defined(id) => Ok(id),
4266
+ _ => bail!(offset, "type index {idx} is not a defined type"),
4267
+ }
4268
+ }
4269
+
4270
+ fn core_function_at(&self, idx: u32, offset: usize) -> Result<CoreTypeId> {
4271
+ match self.core_funcs.get(idx as usize) {
4272
+ Some(id) => Ok(*id),
4273
+ None => bail!(
4274
+ offset,
4275
+ "unknown core function {idx}: function index out of bounds"
4276
+ ),
4277
+ }
4278
+ }
4279
+
4280
+ fn module_at(&self, idx: u32, offset: usize) -> Result<ComponentCoreModuleTypeId> {
4281
+ match self.core_modules.get(idx as usize) {
4282
+ Some(id) => Ok(*id),
4283
+ None => bail!(offset, "unknown module {idx}: module index out of bounds"),
4284
+ }
4285
+ }
4286
+
4287
+ fn core_instance_at(&self, idx: u32, offset: usize) -> Result<ComponentCoreInstanceTypeId> {
4288
+ match self.core_instances.get(idx as usize) {
4289
+ Some(id) => Ok(*id),
4290
+ None => bail!(
4291
+ offset,
4292
+ "unknown core instance {idx}: instance index out of bounds"
4293
+ ),
4294
+ }
4295
+ }
4296
+
4297
+ fn core_instance_export<'a>(
4298
+ &self,
4299
+ instance_index: u32,
4300
+ name: &str,
4301
+ types: &'a TypeList,
4302
+ offset: usize,
4303
+ ) -> Result<&'a EntityType> {
4304
+ match types[self.core_instance_at(instance_index, offset)?]
4305
+ .internal_exports(types)
4306
+ .get(name)
4307
+ {
4308
+ Some(export) => Ok(export),
4309
+ None => bail!(
4310
+ offset,
4311
+ "core instance {instance_index} has no export named `{name}`"
4312
+ ),
4313
+ }
4314
+ }
4315
+
4316
+ fn global_at(&self, idx: u32, offset: usize) -> Result<&GlobalType> {
4317
+ match self.core_globals.get(idx as usize) {
4318
+ Some(t) => Ok(t),
4319
+ None => bail!(offset, "unknown global {idx}: global index out of bounds"),
4320
+ }
4321
+ }
4322
+
4323
+ fn table_at(&self, idx: u32, offset: usize) -> Result<&TableType> {
4324
+ match self.core_tables.get(idx as usize) {
4325
+ Some(t) => Ok(t),
4326
+ None => bail!(offset, "unknown table {idx}: table index out of bounds"),
4327
+ }
4328
+ }
4329
+
4330
+ fn memory_at(&self, idx: u32, offset: usize) -> Result<&MemoryType> {
4331
+ match self.core_memories.get(idx as usize) {
4332
+ Some(t) => Ok(t),
4333
+ None => bail!(offset, "unknown memory {idx}: memory index out of bounds"),
4334
+ }
4335
+ }
4336
+
4337
+ fn tag_at(&self, idx: u32, offset: usize) -> Result<CoreTypeId> {
4338
+ match self.core_tags.get(idx as usize) {
4339
+ Some(t) => Ok(*t),
4340
+ None => bail!(offset, "unknown tag {idx}: tag index out of bounds"),
4341
+ }
4342
+ }
4343
+
4344
+ /// Validates that the linear memory at `idx` is valid to use as a canonical
4345
+ /// ABI memory.
4346
+ ///
4347
+ /// At this time this requires that the memory is a plain 32-bit linear
4348
+ /// memory. Notably this disallows shared memory and 64-bit linear memories.
4349
+ fn cabi_memory_at(&self, idx: u32, offset: usize) -> Result<()> {
4350
+ let ty = self.memory_at(idx, offset)?;
4351
+ SubtypeCx::memory_type(
4352
+ ty,
4353
+ &MemoryType {
4354
+ initial: 0,
4355
+ maximum: None,
4356
+ memory64: false,
4357
+ shared: false,
4358
+ page_size_log2: None,
4359
+ },
4360
+ offset,
4361
+ )
4362
+ .map_err(|mut e| {
4363
+ e.add_context("canonical ABI memory is not a 32-bit linear memory".into());
4364
+ e
4365
+ })
4366
+ }
4367
+
4368
+ /// Completes the translation of this component, performing final
4369
+ /// validation of its structure.
4370
+ ///
4371
+ /// This method is required to be called for translating all components.
4372
+ /// Internally this will convert local data structures into a
4373
+ /// `ComponentType` which is suitable to use to describe the type of this
4374
+ /// component.
4375
+ pub fn finish(&mut self, types: &TypeAlloc, offset: usize) -> Result<ComponentType> {
4376
+ let mut ty = ComponentType {
4377
+ // Inherit some fields based on translation of the component.
4378
+ info: self.type_info,
4379
+ imports: self.imports.clone(),
4380
+ exports: self.exports.clone(),
4381
+
4382
+ // This is filled in as a subset of `self.defined_resources`
4383
+ // depending on what's actually used by the exports. See the
4384
+ // bottom of this function.
4385
+ defined_resources: Default::default(),
4386
+
4387
+ // These are inherited directly from what was calculated for this
4388
+ // component.
4389
+ imported_resources: mem::take(&mut self.imported_resources)
4390
+ .into_iter()
4391
+ .collect(),
4392
+ explicit_resources: mem::take(&mut self.explicit_resources),
4393
+ };
4394
+
4395
+ // Collect all "free variables", or resources, from the imports of this
4396
+ // component. None of the resources defined within this component can
4397
+ // be used as part of the exports. This set is then used to reject any
4398
+ // of `self.defined_resources` which show up.
4399
+ let mut free = IndexSet::default();
4400
+ for ty in ty.imports.values() {
4401
+ types.free_variables_component_entity(ty, &mut free);
4402
+ }
4403
+ for (resource, _path) in self.defined_resources.iter() {
4404
+ // FIXME: this error message is quite opaque and doesn't indicate
4405
+ // more contextual information such as:
4406
+ //
4407
+ // * what was the exported resource found in the imports
4408
+ // * which import was the resource found within
4409
+ //
4410
+ // These are possible to calculate here if necessary, however.
4411
+ if free.contains(resource) {
4412
+ bail!(offset, "local resource type found in imports");
4413
+ }
4414
+ }
4415
+
4416
+ // The next step in validation a component, with respect to resources,
4417
+ // is to minimize the set of defined resources to only those that
4418
+ // are actually used by the exports. This weeds out resources that are
4419
+ // defined, used within a component, and never exported, for example.
4420
+ //
4421
+ // The free variables of all exports are inserted into the `free` set
4422
+ // (which is reused from the imports after clearing it). The defined
4423
+ // resources calculated for this component are then inserted into this
4424
+ // type's list of defined resources if it's contained somewhere in
4425
+ // the free variables.
4426
+ //
4427
+ // Note that at the same time all defined resources must be exported,
4428
+ // somehow, transitively from this component. The `explicit_resources`
4429
+ // map is consulted for this purpose which lists all explicitly
4430
+ // exported resources in the component, regardless from whence they
4431
+ // came. If not present in this map then it's not exported and an error
4432
+ // is returned.
4433
+ //
4434
+ // NB: the "types are exported" check is probably sufficient nowadays
4435
+ // that the check of the `explicit_resources` map is probably not
4436
+ // necessary, but it's left here for completeness and out of an
4437
+ // abundance of caution.
4438
+ free.clear();
4439
+ for ty in ty.exports.values() {
4440
+ types.free_variables_component_entity(ty, &mut free);
4441
+ }
4442
+ for (id, _rep) in mem::take(&mut self.defined_resources) {
4443
+ if !free.contains(&id) {
4444
+ continue;
4445
+ }
4446
+
4447
+ let path = match ty.explicit_resources.get(&id).cloned() {
4448
+ Some(path) => path,
4449
+ // FIXME: this error message is quite opaque and doesn't
4450
+ // indicate more contextual information such as:
4451
+ //
4452
+ // * which resource wasn't found in an export
4453
+ // * which export has a reference to the resource
4454
+ //
4455
+ // These are possible to calculate here if necessary, however.
4456
+ None => bail!(
4457
+ offset,
4458
+ "local resource type found in export but not exported itself"
4459
+ ),
4460
+ };
4461
+
4462
+ ty.defined_resources.push((id, path));
4463
+ }
4464
+
4465
+ Ok(ty)
4466
+ }
4467
+
4468
+ fn check_value_support(&self, offset: usize) -> Result<()> {
4469
+ if !self.features.cm_values() {
4470
+ bail!(
4471
+ offset,
4472
+ "support for component model `value`s is not enabled"
4473
+ );
4474
+ }
4475
+ Ok(())
4476
+ }
4477
+
4478
+ fn check_primitive_type(&self, ty: crate::PrimitiveValType, offset: usize) -> Result<()> {
4479
+ if ty == crate::PrimitiveValType::ErrorContext && !self.features.cm_error_context() {
4480
+ bail!(
4481
+ offset,
4482
+ "`error-context` requires the component model error-context feature"
4483
+ )
4484
+ }
4485
+ Ok(())
4486
+ }
4487
+ }
4488
+
4489
+ impl InternRecGroup for ComponentState {
4490
+ fn features(&self) -> &WasmFeatures {
4491
+ &self.features
4492
+ }
4493
+
4494
+ fn add_type_id(&mut self, id: CoreTypeId) {
4495
+ self.core_types.push(ComponentCoreTypeId::Sub(id));
4496
+ }
4497
+
4498
+ fn type_id_at(&self, idx: u32, offset: usize) -> Result<CoreTypeId> {
4499
+ match self.core_type_at(idx, offset)? {
4500
+ ComponentCoreTypeId::Sub(id) => Ok(id),
4501
+ ComponentCoreTypeId::Module(_) => {
4502
+ bail!(offset, "type index {idx} is a module type, not a sub type");
4503
+ }
4504
+ }
4505
+ }
4506
+
4507
+ fn types_len(&self) -> u32 {
4508
+ u32::try_from(self.core_types.len()).unwrap()
4509
+ }
4510
+ }
4511
+
4512
+ impl ComponentNameContext {
4513
+ /// Registers that the resource `id` is named `name` within this context.
4514
+ fn register(&mut self, name: &str, id: AliasableResourceId) {
4515
+ let idx = self.all_resource_names.len();
4516
+ let prev = self.resource_name_map.insert(id, idx);
4517
+ assert!(
4518
+ prev.is_none(),
4519
+ "for {id:?}, inserted {idx:?} but already had {prev:?}"
4520
+ );
4521
+ self.all_resource_names.insert(name.to_string());
4522
+ }
4523
+
4524
+ fn validate_extern(
4525
+ &self,
4526
+ name: &str,
4527
+ kind: ExternKind,
4528
+ ty: &ComponentEntityType,
4529
+ types: &TypeAlloc,
4530
+ offset: usize,
4531
+ kind_names: &mut IndexSet<ComponentName>,
4532
+ items: &mut IndexMap<String, ComponentEntityType>,
4533
+ info: &mut TypeInfo,
4534
+ features: &WasmFeatures,
4535
+ ) -> Result<()> {
4536
+ // First validate that `name` is even a valid kebab name, meaning it's
4537
+ // in kebab-case, is an ID, etc.
4538
+ let kebab = ComponentName::new_with_features(name, offset, *features)
4539
+ .with_context(|| format!("{} name `{name}` is not a valid extern name", kind.desc()))?;
4540
+
4541
+ if let ExternKind::Export = kind {
4542
+ match kebab.kind() {
4543
+ ComponentNameKind::Label(_)
4544
+ | ComponentNameKind::Method(_)
4545
+ | ComponentNameKind::Static(_)
4546
+ | ComponentNameKind::Constructor(_)
4547
+ | ComponentNameKind::Interface(_) => {}
4548
+
4549
+ ComponentNameKind::Hash(_)
4550
+ | ComponentNameKind::Url(_)
4551
+ | ComponentNameKind::Dependency(_) => {
4552
+ bail!(offset, "name `{name}` is not a valid export name")
4553
+ }
4554
+ }
4555
+ }
4556
+
4557
+ // Validate that the kebab name, if it has structure such as
4558
+ // `[method]a.b`, is indeed valid with respect to known resources.
4559
+ self.validate(&kebab, ty, types, offset)
4560
+ .with_context(|| format!("{} name `{kebab}` is not valid", kind.desc()))?;
4561
+
4562
+ // Top-level kebab-names must all be unique, even between both imports
4563
+ // and exports ot a component. For those names consult the `kebab_names`
4564
+ // set.
4565
+ if let Some(prev) = kind_names.replace(kebab.clone()) {
4566
+ bail!(
4567
+ offset,
4568
+ "{} name `{kebab}` conflicts with previous name `{prev}`",
4569
+ kind.desc()
4570
+ );
4571
+ }
4572
+
4573
+ // Otherwise all strings must be unique, regardless of their name, so
4574
+ // consult the `items` set to ensure that we're not for example
4575
+ // importing the same interface ID twice.
4576
+ match items.entry(name.to_string()) {
4577
+ Entry::Occupied(e) => {
4578
+ bail!(
4579
+ offset,
4580
+ "{kind} name `{name}` conflicts with previous name `{prev}`",
4581
+ kind = kind.desc(),
4582
+ prev = e.key(),
4583
+ );
4584
+ }
4585
+ Entry::Vacant(e) => {
4586
+ e.insert(*ty);
4587
+ info.combine(ty.info(types), offset)?;
4588
+ }
4589
+ }
4590
+ Ok(())
4591
+ }
4592
+
4593
+ /// Validates that the `name` provided is allowed to have the type `ty`.
4594
+ fn validate(
4595
+ &self,
4596
+ name: &ComponentName,
4597
+ ty: &ComponentEntityType,
4598
+ types: &TypeAlloc,
4599
+ offset: usize,
4600
+ ) -> Result<()> {
4601
+ let func = || {
4602
+ let id = match ty {
4603
+ ComponentEntityType::Func(id) => *id,
4604
+ _ => bail!(offset, "item is not a func"),
4605
+ };
4606
+ Ok(&types[id])
4607
+ };
4608
+
4609
+ match name.kind() {
4610
+ // No validation necessary for these styles of names
4611
+ ComponentNameKind::Label(_)
4612
+ | ComponentNameKind::Interface(_)
4613
+ | ComponentNameKind::Url(_)
4614
+ | ComponentNameKind::Dependency(_)
4615
+ | ComponentNameKind::Hash(_) => {}
4616
+
4617
+ // Constructors must return `(own $resource)` or
4618
+ // `(result (own $Tresource))` and the `$resource` must be named
4619
+ // within this context to match `rname`.
4620
+ ComponentNameKind::Constructor(rname) => {
4621
+ let ty = func()?;
4622
+ if ty.async_ {
4623
+ bail!(offset, "constructor function cannot be async");
4624
+ }
4625
+ let ty = match ty.result {
4626
+ Some(result) => result,
4627
+ None => bail!(offset, "function should return one value"),
4628
+ };
4629
+ let resource = match ty {
4630
+ ComponentValType::Primitive(_) => None,
4631
+ ComponentValType::Type(ty) => match &types[ty] {
4632
+ ComponentDefinedType::Own(id) => Some(id),
4633
+ ComponentDefinedType::Result {
4634
+ ok: Some(ComponentValType::Type(ok)),
4635
+ ..
4636
+ } => match &types[*ok] {
4637
+ ComponentDefinedType::Own(id) => Some(id),
4638
+ _ => None,
4639
+ },
4640
+ _ => None,
4641
+ },
4642
+ };
4643
+ let resource = match resource {
4644
+ Some(id) => id,
4645
+ None => bail!(
4646
+ offset,
4647
+ "function should return `(own $T)` or `(result (own $T))`"
4648
+ ),
4649
+ };
4650
+ self.validate_resource_name(*resource, rname, offset)?;
4651
+ }
4652
+
4653
+ // Methods must take `(param "self" (borrow $resource))` as the
4654
+ // first argument where `$resources` matches the name `resource` as
4655
+ // named in this context.
4656
+ ComponentNameKind::Method(name) => {
4657
+ let ty = func()?;
4658
+ if ty.params.len() == 0 {
4659
+ bail!(offset, "function should have at least one argument");
4660
+ }
4661
+ let (pname, pty) = &ty.params[0];
4662
+ if pname.as_str() != "self" {
4663
+ bail!(
4664
+ offset,
4665
+ "function should have a first argument called `self`",
4666
+ );
4667
+ }
4668
+ let id = match pty {
4669
+ ComponentValType::Primitive(_) => None,
4670
+ ComponentValType::Type(ty) => match &types[*ty] {
4671
+ ComponentDefinedType::Borrow(id) => Some(id),
4672
+ _ => None,
4673
+ },
4674
+ };
4675
+ let id = match id {
4676
+ Some(id) => id,
4677
+ None => bail!(
4678
+ offset,
4679
+ "function should take a first argument of `(borrow $T)`"
4680
+ ),
4681
+ };
4682
+ self.validate_resource_name(*id, name.resource(), offset)?;
4683
+ }
4684
+
4685
+ // Static methods don't have much validation beyond that they must
4686
+ // be a function and the resource name referred to must already be
4687
+ // in this context.
4688
+ ComponentNameKind::Static(name) => {
4689
+ func()?;
4690
+ if !self.all_resource_names.contains(name.resource().as_str()) {
4691
+ bail!(offset, "static resource name is not known in this context");
4692
+ }
4693
+ }
4694
+ }
4695
+
4696
+ Ok(())
4697
+ }
4698
+
4699
+ fn validate_resource_name(
4700
+ &self,
4701
+ id: AliasableResourceId,
4702
+ name: &KebabStr,
4703
+ offset: usize,
4704
+ ) -> Result<()> {
4705
+ let expected_name_idx = match self.resource_name_map.get(&id) {
4706
+ Some(idx) => *idx,
4707
+ None => {
4708
+ bail!(
4709
+ offset,
4710
+ "resource used in function does not have a name in this context"
4711
+ )
4712
+ }
4713
+ };
4714
+ let expected_name = &self.all_resource_names[expected_name_idx];
4715
+ if name.as_str() != expected_name {
4716
+ bail!(
4717
+ offset,
4718
+ "function does not match expected \
4719
+ resource name `{expected_name}`"
4720
+ );
4721
+ }
4722
+ Ok(())
4723
+ }
4724
+ }
4725
+
4726
+ use self::append_only::*;
4727
+
4728
+ mod append_only {
4729
+ use crate::prelude::IndexMap;
4730
+ use core::hash::Hash;
4731
+ use core::ops::Deref;
4732
+
4733
+ pub struct IndexMapAppendOnly<K, V>(IndexMap<K, V>);
4734
+
4735
+ impl<K, V> IndexMapAppendOnly<K, V>
4736
+ where
4737
+ K: Hash + Eq + Ord + PartialEq + Clone,
4738
+ {
4739
+ pub fn insert(&mut self, key: K, value: V) {
4740
+ let prev = self.0.insert(key, value);
4741
+ assert!(prev.is_none());
4742
+ }
4743
+ }
4744
+
4745
+ impl<K, V> Deref for IndexMapAppendOnly<K, V> {
4746
+ type Target = IndexMap<K, V>;
4747
+ fn deref(&self) -> &IndexMap<K, V> {
4748
+ &self.0
4749
+ }
4750
+ }
4751
+
4752
+ impl<K, V> Default for IndexMapAppendOnly<K, V> {
4753
+ fn default() -> Self {
4754
+ Self(Default::default())
4755
+ }
4756
+ }
4757
+
4758
+ impl<K, V> IntoIterator for IndexMapAppendOnly<K, V> {
4759
+ type IntoIter = <IndexMap<K, V> as IntoIterator>::IntoIter;
4760
+ type Item = <IndexMap<K, V> as IntoIterator>::Item;
4761
+ fn into_iter(self) -> Self::IntoIter {
4762
+ self.0.into_iter()
4763
+ }
4764
+ }
4765
+ }