Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

wasmtime: generalize InstanceExportLookup into ExportLookup (#13500)

Pat Hickeyb333e5c20737
diff --git a/crates/component-macro/tests/expanded/char.rs b/crates/component-macro/tests/expanded/char.rs
index 2d3bb179bf..cb32d85fdd 100644
--- a/crates/component-macro/tests/expanded/char.rs
+++ b/crates/component-macro/tests/expanded/char.rs
@@ -290,7 +290,7 @@ pub mod exports {
"no exported instance named `foo:foo/chars`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/char_async.rs b/crates/component-macro/tests/expanded/char_async.rs
index 02e1d66be7..15e3417ede 100644
--- a/crates/component-macro/tests/expanded/char_async.rs
+++ b/crates/component-macro/tests/expanded/char_async.rs
@@ -304,7 +304,7 @@ pub mod exports {
"no exported instance named `foo:foo/chars`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/char_concurrent.rs b/crates/component-macro/tests/expanded/char_concurrent.rs
index fbfe3f050e..7edb465998 100644
--- a/crates/component-macro/tests/expanded/char_concurrent.rs
+++ b/crates/component-macro/tests/expanded/char_concurrent.rs
@@ -283,7 +283,7 @@ pub mod exports {
"no exported instance named `foo:foo/chars`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/char_tracing_async.rs b/crates/component-macro/tests/expanded/char_tracing_async.rs
index 71a3224bca..e8873b8c62 100644
--- a/crates/component-macro/tests/expanded/char_tracing_async.rs
+++ b/crates/component-macro/tests/expanded/char_tracing_async.rs
@@ -333,7 +333,7 @@ pub mod exports {
"no exported instance named `foo:foo/chars`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/conventions.rs b/crates/component-macro/tests/expanded/conventions.rs
index ea9e065fdb..a4dc345632 100644
--- a/crates/component-macro/tests/expanded/conventions.rs
+++ b/crates/component-macro/tests/expanded/conventions.rs
@@ -510,7 +510,7 @@ pub mod exports {
"no exported instance named `foo:foo/conventions`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/conventions_async.rs b/crates/component-macro/tests/expanded/conventions_async.rs
index 0a6a3ae11d..eaffa36717 100644
--- a/crates/component-macro/tests/expanded/conventions_async.rs
+++ b/crates/component-macro/tests/expanded/conventions_async.rs
@@ -568,7 +568,7 @@ pub mod exports {
"no exported instance named `foo:foo/conventions`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/conventions_concurrent.rs b/crates/component-macro/tests/expanded/conventions_concurrent.rs
index 9f92b9cf8c..679e9ec9a3 100644
--- a/crates/component-macro/tests/expanded/conventions_concurrent.rs
+++ b/crates/component-macro/tests/expanded/conventions_concurrent.rs
@@ -516,7 +516,7 @@ pub mod exports {
"no exported instance named `foo:foo/conventions`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/conventions_tracing_async.rs b/crates/component-macro/tests/expanded/conventions_tracing_async.rs
index c8d7f64a43..fa24b1da9b 100644
--- a/crates/component-macro/tests/expanded/conventions_tracing_async.rs
+++ b/crates/component-macro/tests/expanded/conventions_tracing_async.rs
@@ -728,7 +728,7 @@ pub mod exports {
"no exported instance named `foo:foo/conventions`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/flags.rs b/crates/component-macro/tests/expanded/flags.rs
index 249ad2616a..c23a04fe59 100644
--- a/crates/component-macro/tests/expanded/flags.rs
+++ b/crates/component-macro/tests/expanded/flags.rs
@@ -637,7 +637,7 @@ pub mod exports {
"no exported instance named `foo:foo/flegs`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/flags_async.rs b/crates/component-macro/tests/expanded/flags_async.rs
index 275c1768b8..6ba9a2e091 100644
--- a/crates/component-macro/tests/expanded/flags_async.rs
+++ b/crates/component-macro/tests/expanded/flags_async.rs
@@ -693,7 +693,7 @@ pub mod exports {
"no exported instance named `foo:foo/flegs`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/flags_concurrent.rs b/crates/component-macro/tests/expanded/flags_concurrent.rs
index 9b4f3f0608..f81f8886e7 100644
--- a/crates/component-macro/tests/expanded/flags_concurrent.rs
+++ b/crates/component-macro/tests/expanded/flags_concurrent.rs
@@ -632,7 +632,7 @@ pub mod exports {
"no exported instance named `foo:foo/flegs`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/flags_tracing_async.rs b/crates/component-macro/tests/expanded/flags_tracing_async.rs
index 7c2554ce62..16f69506f1 100644
--- a/crates/component-macro/tests/expanded/flags_tracing_async.rs
+++ b/crates/component-macro/tests/expanded/flags_tracing_async.rs
@@ -805,7 +805,7 @@ pub mod exports {
"no exported instance named `foo:foo/flegs`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/floats.rs b/crates/component-macro/tests/expanded/floats.rs
index e77427e60a..a8537cf918 100644
--- a/crates/component-macro/tests/expanded/floats.rs
+++ b/crates/component-macro/tests/expanded/floats.rs
@@ -313,7 +313,7 @@ pub mod exports {
"no exported instance named `foo:foo/floats`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/floats_async.rs b/crates/component-macro/tests/expanded/floats_async.rs
index cd4088936a..fd012d7c5f 100644
--- a/crates/component-macro/tests/expanded/floats_async.rs
+++ b/crates/component-macro/tests/expanded/floats_async.rs
@@ -341,7 +341,7 @@ pub mod exports {
"no exported instance named `foo:foo/floats`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/floats_concurrent.rs b/crates/component-macro/tests/expanded/floats_concurrent.rs
index 12e70930e6..875467d65e 100644
--- a/crates/component-macro/tests/expanded/floats_concurrent.rs
+++ b/crates/component-macro/tests/expanded/floats_concurrent.rs
@@ -314,7 +314,7 @@ pub mod exports {
"no exported instance named `foo:foo/floats`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/floats_tracing_async.rs b/crates/component-macro/tests/expanded/floats_tracing_async.rs
index 763f3d8b52..394c6604a2 100644
--- a/crates/component-macro/tests/expanded/floats_tracing_async.rs
+++ b/crates/component-macro/tests/expanded/floats_tracing_async.rs
@@ -399,7 +399,7 @@ pub mod exports {
"no exported instance named `foo:foo/floats`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/integers.rs b/crates/component-macro/tests/expanded/integers.rs
index a545697899..e2064dd7c7 100644
--- a/crates/component-macro/tests/expanded/integers.rs
+++ b/crates/component-macro/tests/expanded/integers.rs
@@ -551,7 +551,7 @@ pub mod exports {
"no exported instance named `foo:foo/integers`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/integers_async.rs b/crates/component-macro/tests/expanded/integers_async.rs
index 3520a6b773..6558793237 100644
--- a/crates/component-macro/tests/expanded/integers_async.rs
+++ b/crates/component-macro/tests/expanded/integers_async.rs
@@ -640,7 +640,7 @@ pub mod exports {
"no exported instance named `foo:foo/integers`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/integers_concurrent.rs b/crates/component-macro/tests/expanded/integers_concurrent.rs
index e691709d6b..f7b5d3b605 100644
--- a/crates/component-macro/tests/expanded/integers_concurrent.rs
+++ b/crates/component-macro/tests/expanded/integers_concurrent.rs
@@ -561,7 +561,7 @@ pub mod exports {
"no exported instance named `foo:foo/integers`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/integers_tracing_async.rs b/crates/component-macro/tests/expanded/integers_tracing_async.rs
index 1489276ab7..69512271c1 100644
--- a/crates/component-macro/tests/expanded/integers_tracing_async.rs
+++ b/crates/component-macro/tests/expanded/integers_tracing_async.rs
@@ -905,7 +905,7 @@ pub mod exports {
"no exported instance named `foo:foo/integers`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/lists.rs b/crates/component-macro/tests/expanded/lists.rs
index 0c6486b061..e17e62e3a5 100644
--- a/crates/component-macro/tests/expanded/lists.rs
+++ b/crates/component-macro/tests/expanded/lists.rs
@@ -1249,7 +1249,7 @@ pub mod exports {
"no exported instance named `foo:foo/lists`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/lists_async.rs b/crates/component-macro/tests/expanded/lists_async.rs
index 0bf2ccb4a2..b2ef873a2b 100644
--- a/crates/component-macro/tests/expanded/lists_async.rs
+++ b/crates/component-macro/tests/expanded/lists_async.rs
@@ -1415,7 +1415,7 @@ pub mod exports {
"no exported instance named `foo:foo/lists`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/lists_concurrent.rs b/crates/component-macro/tests/expanded/lists_concurrent.rs
index 59c3e495ca..d487bc4c6e 100644
--- a/crates/component-macro/tests/expanded/lists_concurrent.rs
+++ b/crates/component-macro/tests/expanded/lists_concurrent.rs
@@ -1218,7 +1218,7 @@ pub mod exports {
"no exported instance named `foo:foo/lists`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/lists_tracing_async.rs b/crates/component-macro/tests/expanded/lists_tracing_async.rs
index 754cff877d..493824cbca 100644
--- a/crates/component-macro/tests/expanded/lists_tracing_async.rs
+++ b/crates/component-macro/tests/expanded/lists_tracing_async.rs
@@ -1846,7 +1846,7 @@ pub mod exports {
"no exported instance named `foo:foo/lists`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/many-arguments.rs b/crates/component-macro/tests/expanded/many-arguments.rs
index cf3b63a565..9af3a57567 100644
--- a/crates/component-macro/tests/expanded/many-arguments.rs
+++ b/crates/component-macro/tests/expanded/many-arguments.rs
@@ -563,7 +563,7 @@ pub mod exports {
"no exported instance named `foo:foo/manyarg`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/many-arguments_async.rs b/crates/component-macro/tests/expanded/many-arguments_async.rs
index ab25e3d32c..8737073991 100644
--- a/crates/component-macro/tests/expanded/many-arguments_async.rs
+++ b/crates/component-macro/tests/expanded/many-arguments_async.rs
@@ -577,7 +577,7 @@ pub mod exports {
"no exported instance named `foo:foo/manyarg`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/many-arguments_concurrent.rs b/crates/component-macro/tests/expanded/many-arguments_concurrent.rs
index 82aeabe6df..d1cf1d6993 100644
--- a/crates/component-macro/tests/expanded/many-arguments_concurrent.rs
+++ b/crates/component-macro/tests/expanded/many-arguments_concurrent.rs
@@ -524,7 +524,7 @@ pub mod exports {
"no exported instance named `foo:foo/manyarg`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/many-arguments_tracing_async.rs b/crates/component-macro/tests/expanded/many-arguments_tracing_async.rs
index 04b188b86b..db617b7d3e 100644
--- a/crates/component-macro/tests/expanded/many-arguments_tracing_async.rs
+++ b/crates/component-macro/tests/expanded/many-arguments_tracing_async.rs
@@ -620,7 +620,7 @@ pub mod exports {
"no exported instance named `foo:foo/manyarg`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/multiversion.rs b/crates/component-macro/tests/expanded/multiversion.rs
index 63662c243c..61f37ca886 100644
--- a/crates/component-macro/tests/expanded/multiversion.rs
+++ b/crates/component-macro/tests/expanded/multiversion.rs
@@ -331,7 +331,7 @@ pub mod exports {
"no exported instance named `my:dep/[email protected]`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
@@ -410,7 +410,7 @@ pub mod exports {
"no exported instance named `my:dep/[email protected]`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/multiversion_async.rs b/crates/component-macro/tests/expanded/multiversion_async.rs
index 138227ce72..4cd200af19 100644
--- a/crates/component-macro/tests/expanded/multiversion_async.rs
+++ b/crates/component-macro/tests/expanded/multiversion_async.rs
@@ -335,7 +335,7 @@ pub mod exports {
"no exported instance named `my:dep/[email protected]`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
@@ -417,7 +417,7 @@ pub mod exports {
"no exported instance named `my:dep/[email protected]`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/multiversion_concurrent.rs b/crates/component-macro/tests/expanded/multiversion_concurrent.rs
index 3839bc415d..b32c6c4ce8 100644
--- a/crates/component-macro/tests/expanded/multiversion_concurrent.rs
+++ b/crates/component-macro/tests/expanded/multiversion_concurrent.rs
@@ -323,7 +323,7 @@ pub mod exports {
"no exported instance named `my:dep/[email protected]`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
@@ -406,7 +406,7 @@ pub mod exports {
"no exported instance named `my:dep/[email protected]`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/multiversion_tracing_async.rs b/crates/component-macro/tests/expanded/multiversion_tracing_async.rs
index 9e45c4ddd4..b4ee5cea7a 100644
--- a/crates/component-macro/tests/expanded/multiversion_tracing_async.rs
+++ b/crates/component-macro/tests/expanded/multiversion_tracing_async.rs
@@ -361,7 +361,7 @@ pub mod exports {
"no exported instance named `my:dep/[email protected]`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
@@ -451,7 +451,7 @@ pub mod exports {
"no exported instance named `my:dep/[email protected]`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/records.rs b/crates/component-macro/tests/expanded/records.rs
index 3e9c48afcf..01980b5c07 100644
--- a/crates/component-macro/tests/expanded/records.rs
+++ b/crates/component-macro/tests/expanded/records.rs
@@ -855,7 +855,7 @@ pub mod exports {
"no exported instance named `foo:foo/records`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/records_async.rs b/crates/component-macro/tests/expanded/records_async.rs
index 006377295b..71e7a225cf 100644
--- a/crates/component-macro/tests/expanded/records_async.rs
+++ b/crates/component-macro/tests/expanded/records_async.rs
@@ -933,7 +933,7 @@ pub mod exports {
"no exported instance named `foo:foo/records`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/records_concurrent.rs b/crates/component-macro/tests/expanded/records_concurrent.rs
index 3062b9e026..2a2f793f7f 100644
--- a/crates/component-macro/tests/expanded/records_concurrent.rs
+++ b/crates/component-macro/tests/expanded/records_concurrent.rs
@@ -866,7 +866,7 @@ pub mod exports {
"no exported instance named `foo:foo/records`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/records_tracing_async.rs b/crates/component-macro/tests/expanded/records_tracing_async.rs
index a78d5875b0..499fa9a118 100644
--- a/crates/component-macro/tests/expanded/records_tracing_async.rs
+++ b/crates/component-macro/tests/expanded/records_tracing_async.rs
@@ -1094,7 +1094,7 @@ pub mod exports {
"no exported instance named `foo:foo/records`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/resources-export.rs b/crates/component-macro/tests/expanded/resources-export.rs
index 81eafe6d02..2ac0d09fe8 100644
--- a/crates/component-macro/tests/expanded/resources-export.rs
+++ b/crates/component-macro/tests/expanded/resources-export.rs
@@ -338,7 +338,7 @@ pub mod exports {
"no exported instance named `foo:foo/simple-export`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
@@ -481,7 +481,7 @@ pub mod exports {
"no exported instance named `foo:foo/export-using-import`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
@@ -627,7 +627,7 @@ pub mod exports {
"no exported instance named `foo:foo/export-using-export1`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
@@ -719,7 +719,7 @@ pub mod exports {
"no exported instance named `foo:foo/export-using-export2`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/resources-export_async.rs b/crates/component-macro/tests/expanded/resources-export_async.rs
index 4841dd9e46..29eeda6d5e 100644
--- a/crates/component-macro/tests/expanded/resources-export_async.rs
+++ b/crates/component-macro/tests/expanded/resources-export_async.rs
@@ -343,7 +343,7 @@ pub mod exports {
"no exported instance named `foo:foo/simple-export`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
@@ -501,7 +501,7 @@ pub mod exports {
"no exported instance named `foo:foo/export-using-import`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
@@ -662,7 +662,7 @@ pub mod exports {
"no exported instance named `foo:foo/export-using-export1`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
@@ -759,7 +759,7 @@ pub mod exports {
"no exported instance named `foo:foo/export-using-export2`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/resources-export_concurrent.rs b/crates/component-macro/tests/expanded/resources-export_concurrent.rs
index 39719a430f..1be725a1c5 100644
--- a/crates/component-macro/tests/expanded/resources-export_concurrent.rs
+++ b/crates/component-macro/tests/expanded/resources-export_concurrent.rs
@@ -335,7 +335,7 @@ pub mod exports {
"no exported instance named `foo:foo/simple-export`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
@@ -490,7 +490,7 @@ pub mod exports {
"no exported instance named `foo:foo/export-using-import`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
@@ -650,7 +650,7 @@ pub mod exports {
"no exported instance named `foo:foo/export-using-export1`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
@@ -746,7 +746,7 @@ pub mod exports {
"no exported instance named `foo:foo/export-using-export2`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/resources-export_tracing_async.rs b/crates/component-macro/tests/expanded/resources-export_tracing_async.rs
index 21fd692b69..7b69542c17 100644
--- a/crates/component-macro/tests/expanded/resources-export_tracing_async.rs
+++ b/crates/component-macro/tests/expanded/resources-export_tracing_async.rs
@@ -343,7 +343,7 @@ pub mod exports {
"no exported instance named `foo:foo/simple-export`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
@@ -519,7 +519,7 @@ pub mod exports {
"no exported instance named `foo:foo/export-using-import`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
@@ -700,7 +700,7 @@ pub mod exports {
"no exported instance named `foo:foo/export-using-export1`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
@@ -803,7 +803,7 @@ pub mod exports {
"no exported instance named `foo:foo/export-using-export2`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/resources-import.rs b/crates/component-macro/tests/expanded/resources-import.rs
index 189e388a6b..58429f0023 100644
--- a/crates/component-macro/tests/expanded/resources-import.rs
+++ b/crates/component-macro/tests/expanded/resources-import.rs
@@ -1239,7 +1239,7 @@ pub mod exports {
"no exported instance named `foo:foo/uses-resource-transitively`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/resources-import_async.rs b/crates/component-macro/tests/expanded/resources-import_async.rs
index a5f5ae140c..ac93b576f0 100644
--- a/crates/component-macro/tests/expanded/resources-import_async.rs
+++ b/crates/component-macro/tests/expanded/resources-import_async.rs
@@ -1423,7 +1423,7 @@ pub mod exports {
"no exported instance named `foo:foo/uses-resource-transitively`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/resources-import_concurrent.rs b/crates/component-macro/tests/expanded/resources-import_concurrent.rs
index 196fdb1b1b..ec1cc84935 100644
--- a/crates/component-macro/tests/expanded/resources-import_concurrent.rs
+++ b/crates/component-macro/tests/expanded/resources-import_concurrent.rs
@@ -1207,7 +1207,7 @@ pub mod exports {
"no exported instance named `foo:foo/uses-resource-transitively`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/resources-import_tracing_async.rs b/crates/component-macro/tests/expanded/resources-import_tracing_async.rs
index e1ccb9e323..86b570e959 100644
--- a/crates/component-macro/tests/expanded/resources-import_tracing_async.rs
+++ b/crates/component-macro/tests/expanded/resources-import_tracing_async.rs
@@ -1840,7 +1840,7 @@ pub mod exports {
"no exported instance named `foo:foo/uses-resource-transitively`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/share-types.rs b/crates/component-macro/tests/expanded/share-types.rs
index 3ca15f019d..803eaf8278 100644
--- a/crates/component-macro/tests/expanded/share-types.rs
+++ b/crates/component-macro/tests/expanded/share-types.rs
@@ -361,7 +361,7 @@ pub mod exports {
"no exported instance named `http-handler`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/share-types_async.rs b/crates/component-macro/tests/expanded/share-types_async.rs
index f6d394e0c3..5e7a390156 100644
--- a/crates/component-macro/tests/expanded/share-types_async.rs
+++ b/crates/component-macro/tests/expanded/share-types_async.rs
@@ -369,7 +369,7 @@ pub mod exports {
"no exported instance named `http-handler`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/share-types_concurrent.rs b/crates/component-macro/tests/expanded/share-types_concurrent.rs
index fe2f5aeadb..47e208013a 100644
--- a/crates/component-macro/tests/expanded/share-types_concurrent.rs
+++ b/crates/component-macro/tests/expanded/share-types_concurrent.rs
@@ -358,7 +358,7 @@ pub mod exports {
"no exported instance named `http-handler`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/share-types_tracing_async.rs b/crates/component-macro/tests/expanded/share-types_tracing_async.rs
index c272f4f72f..f3921821c3 100644
--- a/crates/component-macro/tests/expanded/share-types_tracing_async.rs
+++ b/crates/component-macro/tests/expanded/share-types_tracing_async.rs
@@ -385,7 +385,7 @@ pub mod exports {
"no exported instance named `http-handler`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/simple-functions.rs b/crates/component-macro/tests/expanded/simple-functions.rs
index 683b082662..e40991e4fe 100644
--- a/crates/component-macro/tests/expanded/simple-functions.rs
+++ b/crates/component-macro/tests/expanded/simple-functions.rs
@@ -347,7 +347,7 @@ pub mod exports {
"no exported instance named `foo:foo/simple`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/simple-functions_async.rs b/crates/component-macro/tests/expanded/simple-functions_async.rs
index c24de7c820..4b2f32568f 100644
--- a/crates/component-macro/tests/expanded/simple-functions_async.rs
+++ b/crates/component-macro/tests/expanded/simple-functions_async.rs
@@ -387,7 +387,7 @@ pub mod exports {
"no exported instance named `foo:foo/simple`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/simple-functions_concurrent.rs b/crates/component-macro/tests/expanded/simple-functions_concurrent.rs
index 801da1d4d6..4b7d4a54b2 100644
--- a/crates/component-macro/tests/expanded/simple-functions_concurrent.rs
+++ b/crates/component-macro/tests/expanded/simple-functions_concurrent.rs
@@ -355,7 +355,7 @@ pub mod exports {
"no exported instance named `foo:foo/simple`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/simple-functions_tracing_async.rs b/crates/component-macro/tests/expanded/simple-functions_tracing_async.rs
index 707a195a2b..b9b1026b75 100644
--- a/crates/component-macro/tests/expanded/simple-functions_tracing_async.rs
+++ b/crates/component-macro/tests/expanded/simple-functions_tracing_async.rs
@@ -475,7 +475,7 @@ pub mod exports {
"no exported instance named `foo:foo/simple`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/simple-lists.rs b/crates/component-macro/tests/expanded/simple-lists.rs
index f67ef23c27..54e9f0767e 100644
--- a/crates/component-macro/tests/expanded/simple-lists.rs
+++ b/crates/component-macro/tests/expanded/simple-lists.rs
@@ -368,7 +368,7 @@ pub mod exports {
"no exported instance named `foo:foo/simple-lists`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/simple-lists_async.rs b/crates/component-macro/tests/expanded/simple-lists_async.rs
index ac63fe24ba..afd6a81005 100644
--- a/crates/component-macro/tests/expanded/simple-lists_async.rs
+++ b/crates/component-macro/tests/expanded/simple-lists_async.rs
@@ -392,7 +392,7 @@ pub mod exports {
"no exported instance named `foo:foo/simple-lists`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/simple-lists_concurrent.rs b/crates/component-macro/tests/expanded/simple-lists_concurrent.rs
index 6837bf9dd2..bd73e4d82a 100644
--- a/crates/component-macro/tests/expanded/simple-lists_concurrent.rs
+++ b/crates/component-macro/tests/expanded/simple-lists_concurrent.rs
@@ -351,7 +351,7 @@ pub mod exports {
"no exported instance named `foo:foo/simple-lists`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/simple-lists_tracing_async.rs b/crates/component-macro/tests/expanded/simple-lists_tracing_async.rs
index dd06367496..7b4c2a2675 100644
--- a/crates/component-macro/tests/expanded/simple-lists_tracing_async.rs
+++ b/crates/component-macro/tests/expanded/simple-lists_tracing_async.rs
@@ -453,7 +453,7 @@ pub mod exports {
"no exported instance named `foo:foo/simple-lists`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/small-anonymous.rs b/crates/component-macro/tests/expanded/small-anonymous.rs
index a2c06d0999..d3f09f8837 100644
--- a/crates/component-macro/tests/expanded/small-anonymous.rs
+++ b/crates/component-macro/tests/expanded/small-anonymous.rs
@@ -373,7 +373,7 @@ pub mod exports {
"no exported instance named `foo:foo/anon`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/small-anonymous_async.rs b/crates/component-macro/tests/expanded/small-anonymous_async.rs
index cba4b3308f..914c8a90eb 100644
--- a/crates/component-macro/tests/expanded/small-anonymous_async.rs
+++ b/crates/component-macro/tests/expanded/small-anonymous_async.rs
@@ -385,7 +385,7 @@ pub mod exports {
"no exported instance named `foo:foo/anon`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/small-anonymous_concurrent.rs b/crates/component-macro/tests/expanded/small-anonymous_concurrent.rs
index 90bead0194..6c97370b71 100644
--- a/crates/component-macro/tests/expanded/small-anonymous_concurrent.rs
+++ b/crates/component-macro/tests/expanded/small-anonymous_concurrent.rs
@@ -370,7 +370,7 @@ pub mod exports {
"no exported instance named `foo:foo/anon`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/small-anonymous_tracing_async.rs b/crates/component-macro/tests/expanded/small-anonymous_tracing_async.rs
index edb50ba2fc..d238fa7551 100644
--- a/crates/component-macro/tests/expanded/small-anonymous_tracing_async.rs
+++ b/crates/component-macro/tests/expanded/small-anonymous_tracing_async.rs
@@ -398,7 +398,7 @@ pub mod exports {
"no exported instance named `foo:foo/anon`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/smoke-export.rs b/crates/component-macro/tests/expanded/smoke-export.rs
index 677cc4a8e2..b5459c5a0a 100644
--- a/crates/component-macro/tests/expanded/smoke-export.rs
+++ b/crates/component-macro/tests/expanded/smoke-export.rs
@@ -200,7 +200,7 @@ pub mod exports {
.ok_or_else(|| {
wasmtime::format_err!("no exported instance named `the-name`")
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/smoke-export_async.rs b/crates/component-macro/tests/expanded/smoke-export_async.rs
index c58e52ffab..98857b4e90 100644
--- a/crates/component-macro/tests/expanded/smoke-export_async.rs
+++ b/crates/component-macro/tests/expanded/smoke-export_async.rs
@@ -200,7 +200,7 @@ pub mod exports {
.ok_or_else(|| {
wasmtime::format_err!("no exported instance named `the-name`")
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/smoke-export_concurrent.rs b/crates/component-macro/tests/expanded/smoke-export_concurrent.rs
index e9a1a229be..0d19ddb295 100644
--- a/crates/component-macro/tests/expanded/smoke-export_concurrent.rs
+++ b/crates/component-macro/tests/expanded/smoke-export_concurrent.rs
@@ -200,7 +200,7 @@ pub mod exports {
.ok_or_else(|| {
wasmtime::format_err!("no exported instance named `the-name`")
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/smoke-export_tracing_async.rs b/crates/component-macro/tests/expanded/smoke-export_tracing_async.rs
index 7cfb00cff9..bc4a5f1a76 100644
--- a/crates/component-macro/tests/expanded/smoke-export_tracing_async.rs
+++ b/crates/component-macro/tests/expanded/smoke-export_tracing_async.rs
@@ -200,7 +200,7 @@ pub mod exports {
.ok_or_else(|| {
wasmtime::format_err!("no exported instance named `the-name`")
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/strings.rs b/crates/component-macro/tests/expanded/strings.rs
index 892ef471b4..1b0844bb99 100644
--- a/crates/component-macro/tests/expanded/strings.rs
+++ b/crates/component-macro/tests/expanded/strings.rs
@@ -319,7 +319,7 @@ pub mod exports {
"no exported instance named `foo:foo/strings`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/strings_async.rs b/crates/component-macro/tests/expanded/strings_async.rs
index 7fa81e9309..46d3f21685 100644
--- a/crates/component-macro/tests/expanded/strings_async.rs
+++ b/crates/component-macro/tests/expanded/strings_async.rs
@@ -343,7 +343,7 @@ pub mod exports {
"no exported instance named `foo:foo/strings`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/strings_concurrent.rs b/crates/component-macro/tests/expanded/strings_concurrent.rs
index 5a1b8c26d5..dfc9e36155 100644
--- a/crates/component-macro/tests/expanded/strings_concurrent.rs
+++ b/crates/component-macro/tests/expanded/strings_concurrent.rs
@@ -316,7 +316,7 @@ pub mod exports {
"no exported instance named `foo:foo/strings`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/strings_tracing_async.rs b/crates/component-macro/tests/expanded/strings_tracing_async.rs
index d98979af2d..ab31650af5 100644
--- a/crates/component-macro/tests/expanded/strings_tracing_async.rs
+++ b/crates/component-macro/tests/expanded/strings_tracing_async.rs
@@ -388,7 +388,7 @@ pub mod exports {
"no exported instance named `foo:foo/strings`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/variants.rs b/crates/component-macro/tests/expanded/variants.rs
index 926e9f987e..11e5fc3d57 100644
--- a/crates/component-macro/tests/expanded/variants.rs
+++ b/crates/component-macro/tests/expanded/variants.rs
@@ -1318,7 +1318,7 @@ pub mod exports {
"no exported instance named `foo:foo/variants`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/variants_async.rs b/crates/component-macro/tests/expanded/variants_async.rs
index 110a48a1cd..c853488fe5 100644
--- a/crates/component-macro/tests/expanded/variants_async.rs
+++ b/crates/component-macro/tests/expanded/variants_async.rs
@@ -1449,7 +1449,7 @@ pub mod exports {
"no exported instance named `foo:foo/variants`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/variants_concurrent.rs b/crates/component-macro/tests/expanded/variants_concurrent.rs
index 7d46b40352..1d311478d1 100644
--- a/crates/component-macro/tests/expanded/variants_concurrent.rs
+++ b/crates/component-macro/tests/expanded/variants_concurrent.rs
@@ -1303,7 +1303,7 @@ pub mod exports {
"no exported instance named `foo:foo/variants`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/variants_tracing_async.rs b/crates/component-macro/tests/expanded/variants_tracing_async.rs
index 08c730eb5e..0f408b2bf0 100644
--- a/crates/component-macro/tests/expanded/variants_tracing_async.rs
+++ b/crates/component-macro/tests/expanded/variants_tracing_async.rs
@@ -1747,7 +1747,7 @@ pub mod exports {
"no exported instance named `foo:foo/variants`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/wat.rs b/crates/component-macro/tests/expanded/wat.rs
index 9eb5a50e79..9711aadccb 100644
--- a/crates/component-macro/tests/expanded/wat.rs
+++ b/crates/component-macro/tests/expanded/wat.rs
@@ -208,7 +208,7 @@ pub mod exports {
"no exported instance named `same:name/this-name-is-duplicated`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/wat_async.rs b/crates/component-macro/tests/expanded/wat_async.rs
index 9eb5a50e79..9711aadccb 100644
--- a/crates/component-macro/tests/expanded/wat_async.rs
+++ b/crates/component-macro/tests/expanded/wat_async.rs
@@ -208,7 +208,7 @@ pub mod exports {
"no exported instance named `same:name/this-name-is-duplicated`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/wat_concurrent.rs b/crates/component-macro/tests/expanded/wat_concurrent.rs
index 9eb5a50e79..9711aadccb 100644
--- a/crates/component-macro/tests/expanded/wat_concurrent.rs
+++ b/crates/component-macro/tests/expanded/wat_concurrent.rs
@@ -208,7 +208,7 @@ pub mod exports {
"no exported instance named `same:name/this-name-is-duplicated`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/component-macro/tests/expanded/wat_tracing_async.rs b/crates/component-macro/tests/expanded/wat_tracing_async.rs
index 9eb5a50e79..9711aadccb 100644
--- a/crates/component-macro/tests/expanded/wat_tracing_async.rs
+++ b/crates/component-macro/tests/expanded/wat_tracing_async.rs
@@ -208,7 +208,7 @@ pub mod exports {
"no exported instance named `same:name/this-name-is-duplicated`"
)
})?;
- let mut lookup = move |name| {
+ let mut lookup = move |name: &str| {
_instance_pre
.component()
.get_export_index(Some(&instance), name)
diff --git a/crates/wasmtime/src/runtime/component/component.rs b/crates/wasmtime/src/runtime/component/component.rs
index 7b4f66cee6..3b1859b050 100644
--- a/crates/wasmtime/src/runtime/component/component.rs
+++ b/crates/wasmtime/src/runtime/component/component.rs
@@ -1,4 +1,3 @@
-use crate::component::InstanceExportLookup;
use crate::component::matching::InstanceType;
use crate::component::types;
use crate::prelude::*;
@@ -773,7 +772,7 @@ impl Component {
pub fn get_export_index(
&self,
instance: Option<&ComponentExportIndex>,
- name: &str,
+ name: impl ExportLookup,
) -> Option<ComponentExportIndex> {
let index = self.lookup_export_index(instance, name)?;
Some(ComponentExportIndex {
@@ -804,8 +803,8 @@ impl Component {
/// If the export is located then two values are returned: a
/// [`types::ComponentItem`] which enables introspection about the type of
/// the export and a [`ComponentExportIndex`]. The index returned notably
- /// implements the [`InstanceExportLookup`] trait which enables using it
- /// with [`Instance::get_func`](crate::component::Instance::get_func) for
+ /// implements the [`ExportLookup`] trait which enables using it with
+ /// [`Instance::get_func`](crate::component::Instance::get_func) for
/// example.
///
/// The returned [`types::ComponentItem`] is more expensive to calculate
@@ -855,7 +854,7 @@ impl Component {
pub fn get_export(
&self,
instance: Option<&ComponentExportIndex>,
- name: &str,
+ name: impl ExportLookup,
) -> Option<(types::ComponentItem, ComponentExportIndex)> {
let info = self.env_component();
let index = self.lookup_export_index(instance, name)?;
@@ -878,22 +877,14 @@ impl Component {
pub(crate) fn lookup_export_index(
&self,
instance: Option<&ComponentExportIndex>,
- name: &str,
+ name: impl ExportLookup,
) -> Option<ExportIndex> {
- let info = self.env_component();
- let exports = match instance {
- Some(idx) => {
- if idx.id != self.inner.id {
- return None;
- }
- match &info.export_items[idx.index] {
- Export::Instance { exports, .. } => exports,
- _ => return None,
- }
+ if let Some(idx) = instance {
+ if idx.id != self.inner.id {
+ return None;
}
- None => &info.exports,
- };
- exports.get(name, &NameMapNoIntern).map(|pair| pair.0)
+ }
+ name.lookup(self, instance.map(|idx| &idx.index))
}
pub(crate) fn id(&self) -> CompiledModuleId {
@@ -942,7 +933,7 @@ impl Component {
/// A value which represents a known export of a component.
///
/// This is the return value of [`Component::get_export`] and implements the
-/// [`InstanceExportLookup`] trait to work with lookups like
+/// [`ExportLookup`] trait to work with lookups like
/// [`Instance::get_func`](crate::component::Instance::get_func).
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
pub struct ComponentExportIndex {
@@ -950,8 +941,60 @@ pub struct ComponentExportIndex {
pub(crate) index: ExportIndex,
}
-impl InstanceExportLookup for ComponentExportIndex {
- fn lookup(&self, component: &Component) -> Option<ExportIndex> {
+/// Trait used to lookup the export of a component or instance.
+///
+/// This trait is used as an implementation detail of
+/// [`Instance::get_func`](crate::component::Instance::get_func).
+/// and related `get_*` methods, as well as [`Component::get_export`] and
+/// related `get_*` methods. Notable implementors of this trait are:
+///
+/// * `str`
+/// * `String`
+/// * [`ComponentExportIndex`]
+///
+/// Note that this is intended to be a `wasmtime`-sealed trait so it shouldn't
+/// need to be implemented externally.
+pub trait ExportLookup {
+ #[doc(hidden)]
+ fn lookup(&self, component: &Component, instance: Option<&ExportIndex>) -> Option<ExportIndex>;
+}
+
+impl<T> ExportLookup for &T
+where
+ T: ExportLookup + ?Sized,
+{
+ fn lookup(&self, component: &Component, instance: Option<&ExportIndex>) -> Option<ExportIndex> {
+ T::lookup(self, component, instance)
+ }
+}
+
+impl ExportLookup for str {
+ fn lookup(&self, component: &Component, instance: Option<&ExportIndex>) -> Option<ExportIndex> {
+ let info = component.env_component();
+ let exports = match instance {
+ Some(idx) => match &info.export_items[*idx] {
+ Export::Instance { exports, .. } => exports,
+ _ => return None,
+ },
+ None => &info.exports,
+ };
+ let (index, _) = exports.get(self, &NameMapNoIntern)?;
+ Some(*index)
+ }
+}
+
+impl ExportLookup for String {
+ fn lookup(&self, component: &Component, instance: Option<&ExportIndex>) -> Option<ExportIndex> {
+ str::lookup(self, component, instance)
+ }
+}
+
+impl ExportLookup for ComponentExportIndex {
+ fn lookup(
+ &self,
+ component: &Component,
+ _instance: Option<&ExportIndex>,
+ ) -> Option<ExportIndex> {
if component.inner.id == self.id {
Some(self.index)
} else {
diff --git a/crates/wasmtime/src/runtime/component/instance.rs b/crates/wasmtime/src/runtime/component/instance.rs
index f099d2674f..262d181f98 100644
--- a/crates/wasmtime/src/runtime/component/instance.rs
+++ b/crates/wasmtime/src/runtime/component/instance.rs
@@ -1,4 +1,3 @@
-use crate::component::RuntimeInstance;
use crate::component::func::HostFunc;
use crate::component::matching::InstanceType;
use crate::component::store::{ComponentInstanceId, StoreComponentInstanceId};
@@ -6,6 +5,7 @@ use crate::component::{
Component, ComponentExportIndex, ComponentNamedList, Func, Lift, Lower, ResourceType,
TypedFunc, types::ComponentItem,
};
+use crate::component::{ExportLookup, RuntimeInstance};
use crate::instance::OwnedImports;
use crate::linker::DefinitionType;
use crate::prelude::*;
@@ -152,17 +152,13 @@ impl Instance {
/// # Ok(())
/// # }
/// ```
- pub fn get_func(
- &self,
- mut store: impl AsContextMut,
- name: impl InstanceExportLookup,
- ) -> Option<Func> {
+ pub fn get_func(&self, mut store: impl AsContextMut, name: impl ExportLookup) -> Option<Func> {
let store = store.as_context_mut().0;
let instance = self.id.get(store);
let component = instance.component();
// Validate that `name` exists within `self.`
- let index = name.lookup(component)?;
+ let index = name.lookup(component, None)?;
// Validate that `index` is indeed a lifted function.
match &component.env_component().export_items[index] {
@@ -192,7 +188,7 @@ impl Instance {
pub fn get_typed_func<Params, Results>(
&self,
mut store: impl AsContextMut,
- name: impl InstanceExportLookup,
+ name: impl ExportLookup,
) -> Result<TypedFunc<Params, Results>>
where
Params: ComponentNamedList + Lower,
@@ -224,7 +220,7 @@ impl Instance {
pub fn get_module(
&self,
mut store: impl AsContextMut,
- name: impl InstanceExportLookup,
+ name: impl ExportLookup,
) -> Option<Module> {
let store = store.as_context_mut().0;
let (instance, export) = self.lookup_export(store, name)?;
@@ -259,7 +255,7 @@ impl Instance {
pub fn get_resource(
&self,
mut store: impl AsContextMut,
- name: impl InstanceExportLookup,
+ name: impl ExportLookup,
) -> Option<ResourceType> {
let store = store.as_context_mut().0;
let (instance, export) = self.lookup_export(store, name)?;
@@ -352,10 +348,10 @@ impl Instance {
fn lookup_export<'a>(
&self,
store: &'a StoreOpaque,
- name: impl InstanceExportLookup,
+ name: impl ExportLookup,
) -> Option<(&'a ComponentInstance, &'a Export)> {
let data = self.id().get(store);
- let index = name.lookup(data.component())?;
+ let index = name.lookup(data.component(), None)?;
Some((data, &data.component().env_component().export_items[index]))
}
@@ -654,47 +650,6 @@ where
unsafe { instance.get_export_by_index_mut(registry, store_id, idx) }
}
-/// Trait used to lookup the export of a component instance.
-///
-/// This trait is used as an implementation detail of [`Instance::get_func`]
-/// and related `get_*` methods. Notable implementors of this trait are:
-///
-/// * `str`
-/// * `String`
-/// * [`ComponentExportIndex`]
-///
-/// Note that this is intended to be a `wasmtime`-sealed trait so it shouldn't
-/// need to be implemented externally.
-pub trait InstanceExportLookup {
- #[doc(hidden)]
- fn lookup(&self, component: &Component) -> Option<ExportIndex>;
-}
-
-impl<T> InstanceExportLookup for &T
-where
- T: InstanceExportLookup + ?Sized,
-{
- fn lookup(&self, component: &Component) -> Option<ExportIndex> {
- T::lookup(self, component)
- }
-}
-
-impl InstanceExportLookup for str {
- fn lookup(&self, component: &Component) -> Option<ExportIndex> {
- let (index, _) = component
- .env_component()
- .exports
- .get(self, &NameMapNoIntern)?;
- Some(*index)
- }
-}
-
-impl InstanceExportLookup for String {
- fn lookup(&self, component: &Component) -> Option<ExportIndex> {
- str::lookup(self, component)
- }
-}
-
struct Instantiator<'a> {
component: &'a Component,
id: ComponentInstanceId,
diff --git a/crates/wasmtime/src/runtime/component/mod.rs b/crates/wasmtime/src/runtime/component/mod.rs
index d2a12a500c..fec5fb5abf 100644
--- a/crates/wasmtime/src/runtime/component/mod.rs
+++ b/crates/wasmtime/src/runtime/component/mod.rs
@@ -116,7 +116,7 @@ mod storage;
pub(crate) mod store;
pub mod types;
mod values;
-pub use self::component::{Component, ComponentExportIndex};
+pub use self::component::{Component, ComponentExportIndex, ExportLookup};
#[cfg(feature = "component-model-async")]
pub use self::concurrent::{
Access, Accessor, AccessorTask, AsAccessor, Destination, DirectDestination, DirectSource,
@@ -128,7 +128,7 @@ pub use self::func::{
ComponentNamedList, ComponentType, Func, Lift, Lower, TypedFunc, WasmList, WasmStr,
};
pub use self::has_data::*;
-pub use self::instance::{Instance, InstanceExportLookup, InstancePre};
+pub use self::instance::{Instance, InstancePre};
pub use self::linker::{Linker, LinkerInstance};
pub use self::resource_table::{ResourceTable, ResourceTableError};
pub use self::resources::{Resource, ResourceAny, ResourceDynamic};
diff --git a/crates/wit-bindgen/src/lib.rs b/crates/wit-bindgen/src/lib.rs
index 72c50c8586..b7add61260 100644
--- a/crates/wit-bindgen/src/lib.rs
+++ b/crates/wit-bindgen/src/lib.rs
@@ -606,7 +606,7 @@ pub fn new<_T>(
) -> {wt}::Result<{struct_name}Indices> {{
let instance = _instance_pre.component().get_export_index(None, \"{instance_name}\")
.ok_or_else(|| {wt}::format_err!(\"no exported instance named `{instance_name}`\"))?;
- let mut lookup = move |name| {{
+ let mut lookup = move |name: &str| {{
_instance_pre.component().get_export_index(Some(&instance), name).ok_or_else(|| {{
{wt}::format_err!(
\"instance export `{instance_name}` does \\