Support array repeat expressions (Rvalue::Repeat) - #315
Conversation
Type `[x; N]` as a sequence of `N` copies of `x`, expanding it the same way the array literal arm does. The count must evaluate to a concrete constant. Closes #305 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FWDbM7FpNXVukbHmQcGNoH
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a3e133a2f6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for _ in 0..count { | ||
| seq = seq.seq_concat(elem_term.clone().seq_unit()); |
There was a problem hiding this comment.
Avoid expanding repeat expressions one element at a time
For valid repeat arrays with counts in the thousands, this loop creates a deeply nested seq.++ term and crashes Thrust before the solver runs. Using the built thrust-rustc, [7i32; 5000] reliably overflowed rustc's stack, while a count of 1000 already produced an 18 MB SMT file. Compact repeat arrays are common for buffers, so the sequence needs a non-linearly nested representation or explicit handling for large counts.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
i'm merging this for now and I'll follow-up with another (possible more effective?) option
Closes #305
[x; N](Rvalue::Repeat) previously hitunimplemented!("rvalue=..")inrvalue_type. It is now typed as a sequence ofNcopies ofx, expanded the same way theAggregateKind::Arrayarm expands array literals. The count must evaluate to a concrete constant (try_to_target_usize); a non-constant count (e.g. a const generic) panics.Tests:
tests/ui/{pass,fail}/array_repeat.rscheck the length and an element of[7i32; 4].🤖 Generated with Claude Code
https://claude.ai/code/session_01FWDbM7FpNXVukbHmQcGNoH
Generated by Claude Code