Commit d7f3a73
committed
fix(codegen-rust): correct fixed-size array types and usize indices (#1457)
Second codegen fix after the optimizer removal. Makes the Rust backend emit
correct array types and indices so generated modules compile under rustc.
t27_type_to_rust:
- `[T; N]` (Rust-style, element before `;`) previously took the empty suffix
after `]` and emitted `Vec<>` -> E0107. Now emits `[T; N as usize]`
(element parsed correctly; length cast to usize as arrays require).
- Zig-style `[N]T` still lowers to `Vec<T>`.
expr_to_rust (ExprIndex):
- Array/Vec indices must be `usize`; t27 index expressions are u32. Non-literal
indices now emit `[(idx) as usize]`. Integer literals are left uncast (they
infer usize and casting them would trip clippy::unnecessary_cast).
Verified: t27c suite unchanged at 1494 passed / 1 failed (the remaining failure
is the pre-existing Verilog HIR let-binding test, untouched). Regenerating
gHashTag/tri-net with #1456 + this drops the wired-module error count from
400+ to a handful of genuine SPEC bugs (a bool-vs-u32 return type, a Q8.8
fixed-point 256-in-u8 literal, a couple of `let`-that-should-be-`var`), i.e. the
codegen itself now produces compiling Rust.
FROZEN_HASH re-sealed (M5).
phi^2 + phi^-2 = 31 parent 4a4af13 commit d7f3a73
2 files changed
Lines changed: 27 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8079 | 8079 | | |
8080 | 8080 | | |
8081 | 8081 | | |
8082 | | - | |
8083 | | - | |
8084 | | - | |
8085 | | - | |
| 8082 | + | |
| 8083 | + | |
| 8084 | + | |
| 8085 | + | |
| 8086 | + | |
| 8087 | + | |
| 8088 | + | |
| 8089 | + | |
| 8090 | + | |
| 8091 | + | |
| 8092 | + | |
8086 | 8093 | | |
8087 | | - | |
| 8094 | + | |
| 8095 | + | |
| 8096 | + | |
8088 | 8097 | | |
8089 | 8098 | | |
8090 | 8099 | | |
| |||
8167 | 8176 | | |
8168 | 8177 | | |
8169 | 8178 | | |
8170 | | - | |
8171 | | - | |
8172 | | - | |
8173 | | - | |
8174 | | - | |
| 8179 | + | |
| 8180 | + | |
| 8181 | + | |
| 8182 | + | |
| 8183 | + | |
| 8184 | + | |
| 8185 | + | |
| 8186 | + | |
| 8187 | + | |
| 8188 | + | |
| 8189 | + | |
| 8190 | + | |
8175 | 8191 | | |
8176 | 8192 | | |
8177 | 8193 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
0 commit comments