GEP not implemented for type struct [_; 0]
未关闭
还没有人认领这个 Issue。
bug
- 主要语言
- Rust
- 星标
- 3.4k
- 派生
- 126
- PR 合并指标
- 30 天内没有已合并 PR
描述
Original issue: https://github.com/EmbarkStudios/rust-gpu/issues/1075
Expected Behaviour
This compiles fine with rustc (I guess this bit is probably eliminated?).
Example & Steps To Reproduce
I was using const generic parameters to determine the length of some arrays. At some point, a base case ended up declaring a zero-length array, like so:
#![cfg_attr(target_arch = "spirv", no_std)]
use spirv_std::spirv;
fn example<const LENGTH: usize>() {
let mut array = [0; LENGTH];
for i in 0..array.len() {
array[i] += i;
}
}
#[spirv(compute(threads(1, 1, 1)))]
pub fn compute() {
example::<0>();
}
Resulting in:
error: GEP not implemented for type struct [usize; 0] { }
--> examples/shaders/compute-shader/src/lib.rs:7:9
|
7 | array[i] += i;
| ^^^^^^^^^^^^^
System Info
* rustc: 1.71.0-nightly (1a5f8bce7 2023-05-26)
* rust-gpu: [b2e5eb7](https://github.com/EmbarkStudios/rust-gpu/commit/b2e5eb75951545782b121665c20f9f1c66fe5bdd)
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先,使用零长度 const 泛型数组重现 examples/shaders/compute-shader/src/lib.rs 中的错误,并确认 GEP 失败。跟踪处理所报告类型 struct [usize; 0] 的索引操作的编译器路径。完成的标准是示例能够在没有 GEP 错误的情况下成功编译,并且该行为由回归测试覆盖。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- rust
- 领域
- compilers
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100