-
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
update array missing IntoIterator
msg
#82626
Conversation
I believe https://doc.bccnsoft.com/docs/rust-1.36.0-docs-html/unstable-book/language-features/on-unimplemented.html is still up-to-date. I'm not sure I follow what you are asking for, but it's likely not available (unless you modify |
@@ -81,8 +81,8 @@ fn _assert_is_object_safe(_: &dyn Iterator<Item = ()>) {} | |||
), | |||
on( | |||
_Self = "[]", | |||
label = "borrow the array with `&` or call `.iter()` on it to iterate over it", | |||
note = "arrays are not iterators, but slices like the following are: `&[1, 2, 3]`" |
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.
Any reason not to suggest the &
?
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.
hmm, i wasn't sure how to explain that in a concise way, as adding &
changes the element type.
Do you have an idea for a second label here?
error[E0277]: `[RangeFrom<{integer}>; 1]` is not an iterator | ||
--> $DIR/array-of-ranges.rs:6:14 | ||
| | ||
LL | for _ in [0..] {} | ||
| ^^^^^ borrow the array with `&` or call `.iter()` on it to iterate over it | ||
| ^^^^^ arrays do not yet implement `IntoIterator`; try using `std::array::IntoIter::new(arr)` | ||
| | ||
= help: the trait `Iterator` is not implemented for `[RangeFrom<{integer}>; 1]` | ||
= note: arrays are not iterators, but slices like the following are: `&[1, 2, 3]` | ||
= note: see <https://github.com/rust-lang/rust/pull/65819> for more details | ||
= note: required because of the requirements on the impl of `IntoIterator` for `[RangeFrom<{integer}>; 1]` | ||
= note: required by `into_iter` |
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.
Looking at the array of ranges cases, it might make sense for us to suggest that maybe they didn't want the outer []
, just the range. That seems to be the most likely intent behind the code as written.
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.
It seems like we already had a check for those cases https://github.com/rust-lang/rust/pull/82626/files#diff-c552b2bf18fb3212fe93dd601ce487badf5e50faf9aeed4db7b0f6c22571ef01L28-L33
Maybe at some point inference broke and instead of Idx
we got {integer}
?
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! It broke not because of that, but because of 07e7823 and there being a single RangeInclusive
but multiple Range
structs in the std. rustc_on_unimplemented
has a bug, it should always be using the full path for its filtering.
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.
yeah, fixed that
1156478
to
77bfa69
Compare
☔ The latest upstream changes (presumably #75384) made this pull request unmergeable. Please resolve the merge conflicts. |
r=me after fixing the merge conflict (sorry for not approving earlier) |
77bfa69
to
5ac917d
Compare
@bors r=estebank |
📌 Commit 5ac917d has been approved by |
…bank update array missing `IntoIterator` msg fixes rust-lang#82602 r? `@estebank` do you know whether we can use the expr span in `rustc_on_unimplemented`? The label isn't too great rn
…bank update array missing `IntoIterator` msg fixes rust-lang#82602 r? ``@estebank`` do you know whether we can use the expr span in `rustc_on_unimplemented`? The label isn't too great rn
Rollup of 8 pull requests Successful merges: - rust-lang#81351 (combine: stop eagerly evaluating consts) - rust-lang#82525 (make unaligned_references future-incompat lint warn-by-default) - rust-lang#82626 (update array missing `IntoIterator` msg) - rust-lang#82917 (Add function core::iter::zip) - rust-lang#82993 (rustdoc: Use diagnostics for error when including sources) - rust-lang#83522 (Improve fs error open_from unix) - rust-lang#83548 (Always preserve `None`-delimited groups in a captured `TokenStream`) - rust-lang#83555 (Add #[inline] to io::Error methods) Failed merges: - rust-lang#83130 (escape_ascii take 2) r? `@ghost` `@rustbot` modify labels: rollup
fixes #82602
r? @estebank do you know whether we can use the expr span in
rustc_on_unimplemented
? The label isn't too great rn