Commit cd3b63f
fix(lowering): sanitize Rust-keyword crate names (async.rss -> rss-async)
A source file named after a Rust keyword (e.g. `async.rss`, `match.rss`) derived
a keyword crate/lib name, so the generated harness emitted `async::main()` — a
Rust parse error surfaced as RS1102, and both Cargo and rustc reject keyword
crate names. The checker accepted such programs; only the backend failed,
violating the "valid RSScript -> valid Rust" contract.
`cargo_package_name` now prefixes a keyword result with `rss-` (`async` ->
`rss-async`), which flows through to the lib name and the `<crate>::main()`
reference (`rss_async::main()`), all valid. Extracted the keyword set shared with
`rust_ident` into `is_rust_keyword`. Regression test in checker_lowering.
Third "valid RSScript -> invalid Rust" bug found while building rss-testgen (the
async tier surfaced it via a keyword-named scratch file).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 253f342 commit cd3b63f
2 files changed
Lines changed: 42 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1558 | 1558 | | |
1559 | 1559 | | |
1560 | 1560 | | |
1561 | | - | |
1562 | | - | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
1563 | 1565 | | |
1564 | 1566 | | |
1565 | 1567 | | |
1566 | 1568 | | |
1567 | 1569 | | |
1568 | | - | |
1569 | | - | |
1570 | | - | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
1571 | 1573 | | |
1572 | | - | |
| 1574 | + | |
| 1575 | + | |
1573 | 1576 | | |
1574 | 1577 | | |
1575 | 1578 | | |
| |||
1620 | 1623 | | |
1621 | 1624 | | |
1622 | 1625 | | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
1623 | 1632 | | |
1624 | 1633 | | |
1625 | 1634 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
5 | 32 | | |
6 | 33 | | |
7 | 34 | | |
| |||
0 commit comments