Skip to content

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

Adjust depth calculation of `map<K, V>` type (#12760)

Alex Crichton554dc0045310
diff --git a/crates/environ/src/component/types_builder.rs b/crates/environ/src/component/types_builder.rs
index ae60bda8d1..10422028a3 100644
--- a/crates/environ/src/component/types_builder.rs
+++ b/crates/environ/src/component/types_builder.rs
@@ -1228,8 +1228,8 @@ impl TypeInformation {
*self = TypeInformation::string();
let key_info = types.type_information(&ty.key);
let value_info = types.type_information(&ty.value);
- // Depth is max of key/value depths, plus 1 for tuple, plus 1 for list
- self.depth = key_info.depth.max(value_info.depth) + 2;
+ // Depth is max of key/value depths, plus 1 for the extra map layer.
+ self.depth = key_info.depth.max(value_info.depth) + 1;
self.has_borrow = key_info.has_borrow || value_info.has_borrow;
}
}