Skip to content

Commit 020983c

Browse files
committed
typechecking not works???
1 parent ca390ab commit 020983c

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

crates/wit-bindgen/src/lib.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -707,25 +707,24 @@ pub fn new(
707707
) -> {wt}::Result<{struct_name}Indices> {{
708708
let instance = component.get_export_index(None, \"{instance_name}\")
709709
.ok_or_else(|| anyhow::anyhow!(\"no exported instance named `{instance_name}`\"))?;
710-
let instancetype = ctype.instance_type();
711-
Self::_new(instancetype, |name| component.get_export_index(Some(&instance), name))
710+
let instance_type = ctype.instance_type();
711+
Self::_new(&instance_type, |name| component.get_export_index(Some(&instance), name))
712712
}}
713713
714714
/// This constructor is similar to [`{struct_name}Indices::new`] except that it
715715
/// performs string lookups after instantiation time.
716-
pub fn new_instance<T>(
717-
store: &{wt}::Store<T>,
716+
pub fn new_instance(
717+
mut store: impl {wt}::AsContextMut,
718718
instance: &{wt}::component::Instance,
719719
) -> {wt}::Result<{struct_name}Indices> {{
720-
let store = &store;
721-
let instance_export = instance.get_export_index(store, None, \"{instance_name}\")
720+
let instance_export = instance.get_export_index(&mut store, None, \"{instance_name}\")
722721
.ok_or_else(|| anyhow::anyhow!(\"no exported instance named `{instance_name}`\"))?;
723-
let instancetype = instance.instance_type(store);
724-
Self::_new(instancetype, |name| instance.get_export_index(store, Some(&instance_export), name))
722+
let instance_type = instance.instance_type(&mut store);
723+
Self::_new(&instance_type, |name| instance.get_export_index(&mut store, Some(&instance_export), name))
725724
}}
726725
727726
fn _new(
728-
_instancetype: {wt}::component::__internal::InstanceType<'_>,
727+
_instance_type: &{wt}::component::__internal::InstanceType,
729728
mut lookup: impl FnMut (&str) -> Option<{wt}::component::ComponentExportIndex>,
730729
) -> {wt}::Result<{struct_name}Indices> {{
731730
let mut lookup = move |name| {{
@@ -763,7 +762,7 @@ fn _new(
763762
let mut store = store.as_context_mut();
764763
let _ = &mut store;
765764
let _instance = instance;
766-
let _instance_type = _instance.instance_type(&store);
765+
let _instance_type = _instance.instance_type(&mut store);
767766
"
768767
);
769768
let mut fields = Vec::new();
@@ -1070,6 +1069,7 @@ impl<_T> {camel}Pre<_T> {{
10701069
instance: &{wt}::component::Instance,
10711070
) -> {wt}::Result<Self> {{
10721071
let _instance = instance;
1072+
let _instance_type = _instance.instance_type(&mut store);
10731073
",
10741074
);
10751075
for (name, field) in self.exports.fields.iter() {
@@ -1131,8 +1131,8 @@ impl<_T> {camel}Pre<_T> {{
11311131
mut store: impl {wt}::AsContextMut,
11321132
instance: &{wt}::component::Instance,
11331133
) -> {wt}::Result<{camel}> {{
1134-
let indices = {camel}Indices::new_instance(store, instance)?;
1135-
indices.load(store, instance)
1134+
let indices = {camel}Indices::new_instance(&mut store, instance)?;
1135+
indices.load(&mut store, instance)
11361136
}}
11371137
",
11381138
);

0 commit comments

Comments
 (0)