-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
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 |
This comment has been minimized.
This comment has been minimized.
☀️ 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
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? |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
78d9b1e
to
83ad5bf
Compare
I believe this is ready for review. I don't think it's worth complicating the implementation by adding a new unsizeable iterator just to get rid of the r? libs-api |
83ad5bf
to
bc77b58
Compare
That would be a breaking change to a stable feature, so I don't think it can be a follow-up PR. Once the trait impl exists returning |
It's effectively equally as breaking as introducing this implementation, and we have until the end of the beta bump to decide whether we want this custom implementation in practice. The only code that would break is code that relies on
I don't think this is possible given the current rules for how |
I did some explorations of the unsizing version, and unfortunately it looks like the checker for what unsizing is allowed to do doesn't normalize associated types, so even if the source and target types share the same generic parameter as the not-being-unsized field, the compiler still doesn't let you do it. So the clever version appears not currently feasible, but the simpler version of just having a "static capacity or runtime capacity" would be easy. |
We discussed this in the libs-api meeting today. In the end we concluded that we would prefer for |
☔ The latest upstream changes (presumably #124097) made this pull request unmergeable. Please resolve the merge conflicts. |
ping from triage - can you post your status on this PR? This PR has not received an update in a few months. |
Since compiler-errors took over the larger compiler change, I can take over this one if you need to offload some of the work. Shouldn't be too hard to write up a simple boxed version of (Only if you want, though; just an offer.) |
ack, @clarfonthey: I totally missed your message 😭. Go ahead, I probably will not be able to get around to this one... but it also seems to not require any T-compiler involvement. |
Right ack at you, will work on my own version of this change. Not sure whether I want to base it off of |
Note: this removes warnings as this breackage was deemed acceptable, see <rust-lang#124108 (comment)>
Note: this removes warnings, as this breakage was deemed acceptable, see <rust-lang#124108 (comment)>
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.