Array repeat expression evaluate only once
Open
@scrabsha is already working on this.
Since Sep 24, 2024.
A-content
C-bug
S-waiting-on-author
- Dominant language
- reStructuredText
- Stars
- 497
- Forks
- 41
- Avg merge
- 3h 52m
- Merged PRs (30d)
- 4
Description
Let's consider the following code snippet:
fn id() -> i32 {
dbg!();
42
}
fn main() {
[id(); 9];
}
Playground link
The value of the repeat expression is not a constant, so (according to 6.8:18) the repeat expression should be evaluated 9 times, leading to nine debug traces being printed on the program output.
However, rustc prints only one debug trace:
Compiling playground v0.0.1 (/playground)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.94s
Running `target/debug/playground`
[src/main.rs:2:5]
<END OF OUTPUT>
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.