Rust codegen: RustType.rustNestedBorrowedType produces uncompilable Option<&str> for nested nullable strings
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 83/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- rust, typescript
- 领域
- backend
调研方向
从 compiler/compiler/Compiler/Sources/Generation/Rust/RustTypes.swift 开始,阅读 RustType.rustNestedBorrowedType,然后检查它对 nullable 类型的处理方式。使用包含可选字符串的数组,或包含可选字符串的泛型模型来复现问题,并编译生成的 Rust。完成标准是生成的类型使用 Option<valdi_core_rust::StringRef<'_>>,且编译时没有报告的 trait bound 错误。
由索引模型根据 Issue 内容生成。
描述
Found while reviewing https://github.com/Snapchat/Valdi/pull/211 (native Rust code generation). Not blocking that PR.
RustType.rustNestedBorrowedType produces uncompilable Option<&str> for nested nullable strings
File: compiler/compiler/Compiler/Sources/Generation/Rust/RustTypes.swift
When a TypeScript signature uses an array of optional strings ((string | undefined)[]) or passes an optional string to a generic model (Boxed<string | undefined>), the generated Rust code fails to compile with unsatisfied trait bounds on &str. RustType.rustNestedBorrowedType only converts .string to valdi_core_rust::StringRef<'_> and falls through to rustBorrowedType for all other cases.
For .nullable(.string), rustBorrowedType returns Option<&str>, so ArrayRef<'_, Option<&str>> and BoxedRef<'_, Option<&str>> are emitted instead of Option<valdi_core_rust::StringRef<'_>>. Because &str does not implement ValdiDeserialize or ValdiToOwned in valdi_core_rust, ArrayRef::get, ArrayRef::to_vec, and generic BoxedRef::to_owned all fail trait-bound checks in rustc.
Add a case .nullable(let inner): branch in RustType.rustNestedBorrowedType that returns "Option<\(inner.rustNestedBorrowedType)>".
- 主要语言
- C++
- 星标
- 16.4k
- 派生
- 539
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Snapchat/Valdi 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 79/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 83/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
相似的 Issue
-
RTL-SDR: re-enumerating while streaming removes the in-use entry from the device selection dialog可能已有人在做 @dpc00 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 64/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 3 天内回复
-
难度 1/5 1 小时以内 新手友好度 92/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
throneproj/Throne#2227 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
deepseek-ai/DeepGEMM-Ascend#49 ·
维护者通常 1 天内回复