From 7b40bf988ccaabf171178e024fca847c81027872 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 29 Mar 2023 11:48:15 -0700 Subject: [PATCH] Relax an assertion in Rust type emission I forgot a context where the assertion would trip, so implement the code necessary to avoid the need for the assertion. Closes #551 --- crates/rust-lib/src/lib.rs | 5 ++++- tests/codegen/issue551.wit | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 tests/codegen/issue551.wit diff --git a/crates/rust-lib/src/lib.rs b/crates/rust-lib/src/lib.rs index 93ae37a4d..b4a901afa 100644 --- a/crates/rust-lib/src/lib.rs +++ b/crates/rust-lib/src/lib.rs @@ -242,8 +242,11 @@ pub trait RustGenerator<'a> { // the API level, ownership isn't required. if info.has_list && lt.is_none() { if let TypeMode::AllBorrowed(lt) | TypeMode::LeafBorrowed(lt) = mode { - assert_eq!(lt, "'_"); self.push_str("&"); + if lt != "'_" { + self.push_str(lt); + self.push_str(" "); + } } } let name = self.type_path(id, lt.is_none()); diff --git a/tests/codegen/issue551.wit b/tests/codegen/issue551.wit new file mode 100644 index 000000000..28033c823 --- /dev/null +++ b/tests/codegen/issue551.wit @@ -0,0 +1,11 @@ +default world bindings { + import component: self.component +} + +interface component { + type value = list> + type entity = list> + + add-components: func(entity: u64, data: entity) + query-eval: func(q: u64) -> list>> +}