rust-lang / rust-lang/rust

`&Box<[T; N]>` doesn't impl `IntoIterator`

Open
#155,577 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-array A-box A-iterators C-enhancement F-negative_impls T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I tried this code:

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=04a2170785a4ddc68cf07d0757f41fb3

pub fn f(v: &Box<[String; 10]>) {
    for i in v {
        println("{i:?}");
    }
}

I expected to see this happen: compiles successfully and iterates over the boxed array.

Instead, this happened:

error[E0277]: `&Box<[String; 10]>` is not an iterator
Meta

rustc --version --verbose: (from playground)

1.97.0-nightly (2026-04-19 e22c616e4e87914135c1)

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 reproducing the linked Rust Playground example with the reported nightly compiler and compare iteration over &Box<[String; 10]> with related array and reference cases. Trace the compiler or standard-library handling of IntoIterator and confirm the fix by making the example compile and iterate over the boxed array.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.