New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Box<[T; N]>: IntoIterator
without any method dispatch hacks
#124108
base: master
Are you sure you want to change the base?
Add Box<[T; N]>: IntoIterator
without any method dispatch hacks
#124108
Conversation
r? @Nilstrieb rustbot has assigned @Nilstrieb. Use |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
why did i rust-timer this -- i plan to use crater lol |
…=<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.
Well -- I guess |
The job Click to see the possible cause of the failure (guessed by this bot)
|
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
@craterbot check |
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
This comment was marked as off-topic.
This comment was marked as off-topic.
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🎉 Experiment
|
The only regression is
This will not be fixed by adding any method dispatch hacks, so I think we should just land this as-is. I don't think we should block landing this impl on the one breakage.1 Nominating this for T-libs-api for confirmation. Footnotes
|
Box<[T; N]>: IntoIterator
without any method dispatch hacksBox<[T; N]>: IntoIterator
without any method dispatch hacks
Discussed this in the libs-api meeting. The breakage looks acceptable, especially since it only occurs in a test. |
@Amanieu: Would you or someone else from @rust-lang/libs-api like to start an FCP then? |
#[stable(feature = "boxed_slice_into_iter", since = "CURRENT_RUSTC_VERSION")] | ||
impl<'a, const N: usize, I, A: Allocator> !Iterator for &'a Box<[I; N], A> {} | ||
|
||
/// `Box` is fundamental, so coherence needs help understanding these impls are okay. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This (and the comment above it) are going to show up in public docs right? If so, could these be elaborated on a bit more? Maybe just a short description of what would happen if these impls didn't exist would be sufficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yeah I will make these less esoteric.
@rfcbot fcp merge |
Team member @BurntSushi has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. 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. |
I'm having trouble parsing this. It starts by saying that the type remains the same before/after this change, but the change is actually changing the type from |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
Sorry, I mean the |
Ah I see now. Makes sense! |
100% agreed that Unlike #124097 (comment), I'm torn on re-using If we did the simpler |
Undigested thought: is there a way that Then we could have |
If we had TAIT I could imagine |
Hmm, I didn't actually mean a TAIT. Let's see if I can digest it further. Suppose we had The idea would be to think of that (I don't know if that would actually work, though.) |
@scottmcm what you are describing is actually quite possible: [playground] (finally, my love for unsizing paid off,,,). Basically what you need is just a I really dig your idea, this sounds nice :) (P.S. to be clear I did not mean you meant TAIT, I just meant that it'd be possible to use TAIT) |
While that's a clever idea, it also seems like a lot of work to avoid a single |
I don't think it's that much work, given that this would replace the existing |
I'm hoping it wouldn't be that bad, actually. Looking at rust/library/alloc/src/vec/into_iter.rs Lines 45 to 61 in e59f2c5
if we can "just" change that libs-api folks, if the code needed to make it happens turned out to not be too bad, might you be interested? Or is it not worth bothering making a sample PR because you'd not want it anyway? |
Unlike
Box<[T]>
(#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. Any breakage would need to be relying specifically on the exprBox::([...]).into_iter()
yielding an iterator specifically of typearray::IntoIter<T; N>
as it currently does.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 #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.