You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Iterator not found for referenced box array item #164751
#[derive(Clone,Copy)]pubstructWrapper<T>(T);impl<T>IntoIteratorforWrapper<T>{typeItem = T;typeIntoIter = std::option::IntoIter<T>;fninto_iter(self) -> Self::IntoIter{Some(self.0).into_iter()}}#[unsafe(no_mangle)]fntest(v:&Box<[Wrapper<usize>;2]>){for v in v.into_iter().flatten(){
std::hint::black_box(v);}}
I expected to see this happen: code compiles
Instead, this happened: compile error
error[E0277]: `&Wrapper<usize>` is not an iterator
--> <source>:14:28
|
14 | for v in v.into_iter().flatten() {
| ^^^^^^^ `&Wrapper<usize>` is not an iterator
|
= help: the trait `Iterator` is not implemented for `&Wrapper<usize>`
help: the trait `IntoIterator` is implemented for `Wrapper<T>`
Version it worked on
It most recently worked on: 1.98
Version with regression
Compile errors on all the following: 1.99.0, 1.99.1, beta, nightly
Notes
It seems to only occer when the type is &Box<[Wrapper<_>; _]>.
The following all errors on 1.98: &[Wrapper<_>], &[Wrapper<_>; _], &Box<[Wrapper<_>]>.
Bug does not occur (compile succeeds) if the Box isnt behind a reference.
Activity
rustbot commentedon Oct 22, 2026
Error: Unknown labels: regression-from-stable-to-{channel}
Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #triagebot on Zulip.
theemathas commentedon Oct 22, 2026
Presumably caused by #134021
The
v.into_iter()is now calling theIntoIterimplementation on the&Box<[_; _]>instead of on the[_; _]chokomancarr commentedon Oct 22, 2026
nevermind, looks like this is caused by the stabilized IntoIterator for boxed array
theemathas commentedon Oct 22, 2026
A crater run for that PR was done, and the small amount of breakage was accepted.
theemathas commentedon Oct 22, 2026
@chokomancarr I believe the relevant impl is on
&Box<[_; _]>, not onBox<[_; _]>