rust-lang / rust-lang/rust

Array repeat exprs dont permit non-copy adt ctors as elements

Open
#139,642 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug C-feature-request T-lang T-types
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I tried this code:

fn main() {
  struct Foo;
  [Foo; 2];
}

I expected to see this happen: it works because we attempt to permit paths to const items as repeat expr elements without Copy holding. It's also trivial to just write [const { Foo }; 2] so the lack of expressiveness doesn't really matter here too much but it feels somewhat inconsistent

Instead, this happened: error

Meta

rustc --version --verbose:

latest playground

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by compiling the minimal Rust program shown in the issue and compare it with the const-block form that already works. No source file or test is named; done means the direct array repeat expression accepts the non-Copy ADT constructor without requiring the const-block workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.