Skip to content

Implement IntoIterator for [&[mut]] Box<[T; N], A>#134021

Open
WaffleLapkin wants to merge 5 commits into
rust-lang:mainfrom
WaffleLapkin:box-arr-into-iter2
Open

Implement IntoIterator for [&[mut]] Box<[T; N], A>#134021
WaffleLapkin wants to merge 5 commits into
rust-lang:mainfrom
WaffleLapkin:box-arr-into-iter2

Conversation

@WaffleLapkin

@WaffleLapkin WaffleLapkin commented Dec 8, 2024

Copy link
Copy Markdown
Member

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Dec 8, 2024
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@tgross35 tgross35 added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Dec 13, 2024
@WaffleLapkin WaffleLapkin marked this pull request as ready for review December 16, 2024 19:24
@tgross35 tgross35 added the needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. label Dec 19, 2024
@bors

bors commented Feb 6, 2025

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #136572) made this pull request unmergeable. Please resolve the merge conflicts.

Comment thread library/alloc/src/boxed/iter.rs
@Dylan-DPC Dylan-DPC added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 6, 2025
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 14, 2025
@WaffleLapkin

Copy link
Copy Markdown
Member Author

@scottmcm anything I can do to move this forward?

@rust-bors

This comment was marked as resolved.

@scottmcm

This comment was marked as resolved.

@rustbot rustbot assigned Mark-Simulacrum and unassigned scottmcm Feb 8, 2026

@Mark-Simulacrum Mark-Simulacrum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this also needs rebasing + FCP, maybe starting with the FCP makes sense since it's not obvious to me this is worth it (especially if it needs an edition change...)

View changes since this review

Comment thread library/alloc/src/boxed/iter.rs Outdated
Comment thread library/alloc/src/boxed/iter.rs Outdated
Comment thread library/alloc/src/boxed/iter.rs Outdated
Comment thread tests/ui/iterators/into-iter-on-arrays-lint.stderr
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 14, 2026
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@WaffleLapkin WaffleLapkin force-pushed the box-arr-into-iter2 branch 2 times, most recently from 33ce55c to a26c96f Compare March 10, 2026 15:10
@WaffleLapkin

WaffleLapkin commented Mar 17, 2026

Copy link
Copy Markdown
Member Author

I guess the current version of this PR proposes neither option and instead has a dedicated new iterator type (BoxedArrayIntoIter). I think that's entirely net-new surface area, right? It also means we're missing a chunk of impls (e.g., DoubleEndedIterator) that we'd get 'for free' with vec::IntoIter.

No, we aren't missing any impls, since I added all of them :)

Also, this PR is compatible with the unsizing idea, with that you would have:

struct AllocatedContinuousIntoIter<T: ?Sized, A: Allocator = Global> { ... } // name bikeshedable

type vec::IntoIter<T, A: Allocator> = AllocatedContinuousIntoIter<[T], A>;
type box::BoxedArrayIntoIter<T, const N: usize, A: Allocator> = AllocatedContinuousIntoIter<[T; N], A>;

Note that vec::IntoIter and box::BoxedArrayIntoIter still normalize to different types, just like in this PR. So we will be able to do this in a follow up.

I.e. one of two follow ups is possible:

  1. Making BoxedArrayIntoIter use custom iterator impls, rather than wrapping vec::IntoIter as it does in this PR
  2. Making vec::IntoIter more generic, so it can support both use cases (unsizing idea)

@Amanieu Amanieu removed the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Mar 17, 2026
@Amanieu

Amanieu commented Mar 17, 2026

Copy link
Copy Markdown
Member

@rfcbot merge libs-api

@rust-rfcbot

rust-rfcbot commented Mar 17, 2026

Copy link
Copy Markdown
Collaborator

@Amanieu has proposed to merge this. The next step is review by the rest of the tagged team members:

Concerns:

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rust-rfcbot rust-rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Mar 17, 2026

@Mark-Simulacrum Mark-Simulacrum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me with FCP done

View changes since this review


fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
self.inner.advance_by(n)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we're missing overrides for next_chunk, try_fold, and probably __iterator_get_unchecked? Those are 'just' perf optimizations though.

I think the best way to fix this long-term is the change to have a common iterator type rather than duplicating all the surface area.

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-fcp Status: PR is in FCP and is awaiting for FCP to complete. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 21, 2026
@rustbot

This comment has been minimized.

/// A by-value `Box<[T; N]>` iterator.
#[stable(feature = "boxed_array_value_iter", since = "CURRENT_RUSTC_VERSION")]
#[rustc_insignificant_dtor]
pub struct BoxedArrayIntoIter<T, const N: usize, A: Allocator = Global> {

@programmerjake programmerjake Apr 21, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add Default for BoxedArrayIntoIter<...> that gives an empty iterator just like vec::IntoIter and array::IntoIter?

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to change what the FCP is about, so maybe this should be left as a follow up?

@BurntSushi

Copy link
Copy Markdown
Member

Given the potential for breaking changes here, it seems prudent to do a crater run. I don't see that one has been done. Thoughts on doing so?

@rfcbot concern crater

@rustbot

rustbot commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@WaffleLapkin

WaffleLapkin commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

@BurntSushi doing a crater run seems reasonable to me. I'll start it once the try build completes.

@bors try

rust-bors Bot pushed a commit that referenced this pull request Jun 9, 2026
Implement `IntoIterator` for `[&[mut]] Box<[T; N], A>`
@rust-bors

This comment has been minimized.

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job x86_64-gnu-tools failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
...............................F.................. (50/144)
.................................................. (100/144)
............................................       (144/144)

======== tests/rustdoc-gui/go-to-collapsed-elem.goml ========

[ERROR] line 40
    at `tests/rustdoc-gui/go-to-collapsed-elem.goml` line 21: Error: Node is detached from document: for command `click: "//*[@id='search']//a[@href='../test_docs/struct.Foo.html#method.must_use']"`
    at <file:///checkout/obj/build/x86_64-unknown-linux-gnu/test/rustdoc-gui/doc/test_docs/struct.Foo.html?search=t_use>


<= doc-ui tests done: 143 succeeded, 1 failed, 0 filtered out

Error: ()

@rust-bors

rust-bors Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: c37f0ee (c37f0eebe7e1f4c42e88bffc7961c6a7aa9c4d00, parent: 057ed8ba87418a77d5758f2d5e13f84b89b197e9)

@WaffleLapkin

Copy link
Copy Markdown
Member Author

@craterbot check

@craterbot

Copy link
Copy Markdown
Collaborator

👌 Experiment pr-134021 created and queued.
🤖 Automatically detected try build c37f0ee
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-fcp Status: PR is in FCP and is awaiting for FCP to complete. labels Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-crater Status: Waiting on a crater run to be completed. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.