Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1121)

Unified Diff: mojom/generators/rust/rustgen/type_translation.go

Issue 2222823002: Rust: Add validation support to code generator (Closed) Base URL: git@github.com:domokit/mojo.git@decoding-test
Patch Set: Double check before land Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojom/generators/rust/rustgen/type_translation.go
diff --git a/mojom/generators/rust/rustgen/type_translation.go b/mojom/generators/rust/rustgen/type_translation.go
index b08d1250efd4fa20c5a10a409c6ac9ac64ff9f4d..1bbc3fb6f0b6c4808786f6923c060e7bf58dacec 100644
--- a/mojom/generators/rust/rustgen/type_translation.go
+++ b/mojom/generators/rust/rustgen/type_translation.go
@@ -232,8 +232,14 @@ func mojomToRustType(t mojom_types.Type, context *Context) string {
len_str := strconv.Itoa(int(array_type.FixedLength))
type_str = "[" + elem_type_str + "; " + len_str + "]"
} else {
+ log.Fatal("Rust doesn't currently support arrays of " +
+ "fixed size greater than 32. The reason for this is " +
+ "the lack of generics over array length in the type " +
+ "system. Since we cannot encode the length in the type " +
+ "there is no way for nested decode routines to know " +
+ "what length it should be. Sorry. :(")
// Fixed length array, but user has to validate the length themselves.
- type_str = "Box<[" + elem_type_str + "]>"
+ //type_str = "Box<[" + elem_type_str + "]>"
}
if array_type.Nullable {
return "Option<" + type_str + ">"

Powered by Google App Engine
This is Rietveld 408576698