WIP: IntoIterator for Box<[T]> + method dispatch mitigation for editions < 2024 by clarfonthey · Pull Request #116607 · rust-lang/rust

@rustbot rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.

T-libs

Relevant to the library team, which will review and decide on the PR/issue.

labels

Oct 10, 2023

@clarfonthey clarfonthey changed the title [NEEDS CRATER] IntoIterator for Box<[T]> IntoIterator for Box<[T]>

Oct 10, 2023

bors added a commit to rust-lang-ci/rust that referenced this pull request

Oct 11, 2023
IntoIterator for Box<[T]>

ACP: rust-lang/libs-team#263

Recommendation per ACP: this should receive a crater run to gauge impact. If there's no impact, it can be merged as-is, but otherwise it will need a similar edition-based workaround to the array implementation.

In addition to what was proposed by the ACP, this also adds `IntoIterator for &Box<[T]>` and `IntoIterator for &mut Box<[T]>` to ensure that those work as expected. I also already had to change at least one line in the compiler to account for this change, which isn't a good sign toward whether edition-specific mitigations may be needed, but we'll see.

WaffleLapkin

@clarfonthey clarfonthey changed the title IntoIterator for Box<[T]> WIP: IntoIterator for Box<[T]>

Nov 3, 2023

@clarfonthey clarfonthey changed the title WIP: IntoIterator for Box<[T]> WIP: IntoIterator for Box<[T]> + method dispatch mitigation for editions < 2024

Nov 3, 2023

@clarfonthey

@clarfonthey

svix-jplatte

compiler-errors

compiler-errors

@tmandry tmandry added T-libs-api

Relevant to the library API team, which will review and decide on the PR/issue.

and removed T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.

T-libs

Relevant to the library team, which will review and decide on the PR/issue.

labels

Apr 17, 2024

This was referenced

Apr 17, 2024

bors added a commit to rust-lang-ci/rust that referenced this pull request

Apr 18, 2024
…=<try>

[crate] Add `Box<[T; N]>: IntoIterator` without any method dispatch hacks

**Unlike** `Box<[T]>` (rust-lang#116607 (comment)), there's a much higher chance that this will not conflict with existing usages since it produces an iterator with the same type before/after this change, but let's test that theory with crater.

Ideally we have fewer migrations that are tangled up in hacks like `rustc_skip_during_method_dispatch`, so if this crater comes back clean, I'd strongly suggest landing this as-is.

As for the rationale for having this impl at all, I agree (as `@clarfonthey` pointed out in rust-lang#124097 (comment)) that it is generally better for any user to not require moving the array *out* of the box just to turn it into an iterator.

bors added a commit to rust-lang-ci/rust that referenced this pull request

May 21, 2024
…fleLapkin

Add `IntoIterator` for `Box<[T]>` + edition 2024-specific lints

* Adds a similar method probe opt-out mechanism to the `[T;N]: IntoIterator` implementation for edition 2021.
* Adjusts the relevant lints (shadowed `.into_iter()` calls, new source of method ambiguity).
* Adds some tests.
* Took the liberty to rework the logic in the `ARRAY_INTO_ITER` lint, since it was kind of confusing.

Based mostly off of rust-lang#116607.

ACP: rust-lang/libs-team#263
References rust-lang#59878
Tracking for Rust 2024: rust-lang#123759

Crater run was done here: rust-lang#116607 (comment)
Consensus afaict was that there is too much breakage, so let's do this in an edition-dependent way much like `[T; N]: IntoIterator`.

RalfJung pushed a commit to RalfJung/miri that referenced this pull request

May 22, 2024
Add `IntoIterator` for `Box<[T]>` + edition 2024-specific lints

* Adds a similar method probe opt-out mechanism to the `[T;N]: IntoIterator` implementation for edition 2021.
* Adjusts the relevant lints (shadowed `.into_iter()` calls, new source of method ambiguity).
* Adds some tests.
* Took the liberty to rework the logic in the `ARRAY_INTO_ITER` lint, since it was kind of confusing.

Based mostly off of #116607.

ACP: rust-lang/libs-team#263
References #59878
Tracking for Rust 2024: rust-lang/rust#123759

Crater run was done here: rust-lang/rust#116607 (comment)
Consensus afaict was that there is too much breakage, so let's do this in an edition-dependent way much like `[T; N]: IntoIterator`.

flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request

May 24, 2024
Add `IntoIterator` for `Box<[T]>` + edition 2024-specific lints

* Adds a similar method probe opt-out mechanism to the `[T;N]: IntoIterator` implementation for edition 2021.
* Adjusts the relevant lints (shadowed `.into_iter()` calls, new source of method ambiguity).
* Adds some tests.
* Took the liberty to rework the logic in the `ARRAY_INTO_ITER` lint, since it was kind of confusing.

Based mostly off of #116607.

ACP: rust-lang/libs-team#263
References #59878
Tracking for Rust 2024: rust-lang/rust#123759

Crater run was done here: rust-lang/rust#116607 (comment)
Consensus afaict was that there is too much breakage, so let's do this in an edition-dependent way much like `[T; N]: IntoIterator`.