-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Tracking Issue for edition-dependent IntoIterator for arrays #84513
Comments
I think it would be great if that could produce
|
I'd like to tackle the standard library changes first! |
Since |
I could work on updating the |
I'm going to break this issue apart into sub-issues to help in people signing up for specific bits! |
@mominul Which changes specifically do you mean? Have you started working on these? |
@m-ou-se I haven't started yet, but I intend to work on the
|
Thanks! Since we're running a bit short on time for the edition changes, I'm implementing the most important ones today. Hope you don't mind. I'll add the PR numbers in the first comment above, so take a look there before you start implementing anything to avoid doing work twice. |
Remove arrays/IntoIterator message from Iterator trait. Arrays implement IntoIterator since 1.53. cc rust-lang#84513
@m-ou-se Thanks, I will! 😊 |
Remove Iterator #[rustc_on_unimplemented]s that no longer apply. Now that `IntoIterator` is implemented for arrays, all the `rustc_on_unimplemented` for arrays of ranges (e.g. `for _ in [1..3] {}`) no longer apply, since they are now valid Rust. Separated these from rust-lang#85670, because we should discuss a potential new (clippy?) lint for these. Until Rust 1.52, `for _ in [1..3] {}` produced: ``` error[E0277]: `[std::ops::Range<{integer}>; 1]` is not an iterator --> src/main.rs:2:14 | 2 | for _ in [1..3] {} | ^^^^^^ if you meant to iterate between two values, remove the square brackets | = help: the trait `std::iter::Iterator` is not implemented for `[std::ops::Range<{integer}>; 1]` = note: `[start..end]` is an array of one `Range`; you might have meant to have a `Range` without the brackets: `start..end` = note: required by `std::iter::IntoIterator::into_iter` ``` But in Rust 1.53 and later, it compiles fine. It iterates over the array by value, for one iteration with the element `1..3`. This is probably a mistake, which is no longer caught. Should we have a lint for it? Should Clippy have a lint for it? cc `@estebank` `@flip1995` cc rust-lang#84513
Remove Iterator #[rustc_on_unimplemented]s that no longer apply. Now that `IntoIterator` is implemented for arrays, all the `rustc_on_unimplemented` for arrays of ranges (e.g. `for _ in [1..3] {}`) no longer apply, since they are now valid Rust. Separated these from rust-lang#85670, because we should discuss a potential new (clippy?) lint for these. Until Rust 1.52, `for _ in [1..3] {}` produced: ``` error[E0277]: `[std::ops::Range<{integer}>; 1]` is not an iterator --> src/main.rs:2:14 | 2 | for _ in [1..3] {} | ^^^^^^ if you meant to iterate between two values, remove the square brackets | = help: the trait `std::iter::Iterator` is not implemented for `[std::ops::Range<{integer}>; 1]` = note: `[start..end]` is an array of one `Range`; you might have meant to have a `Range` without the brackets: `start..end` = note: required by `std::iter::IntoIterator::into_iter` ``` But in Rust 1.53 and later, it compiles fine. It iterates over the array by value, for one iteration with the element `1..3`. This is probably a mistake, which is no longer caught. Should we have a lint for it? Should Clippy have a lint for it? cc ``@estebank`` ``@flip1995`` cc rust-lang#84513
Remove Iterator #[rustc_on_unimplemented]s that no longer apply. Now that `IntoIterator` is implemented for arrays, all the `rustc_on_unimplemented` for arrays of ranges (e.g. `for _ in [1..3] {}`) no longer apply, since they are now valid Rust. Separated these from rust-lang#85670, because we should discuss a potential new (clippy?) lint for these. Until Rust 1.52, `for _ in [1..3] {}` produced: ``` error[E0277]: `[std::ops::Range<{integer}>; 1]` is not an iterator --> src/main.rs:2:14 | 2 | for _ in [1..3] {} | ^^^^^^ if you meant to iterate between two values, remove the square brackets | = help: the trait `std::iter::Iterator` is not implemented for `[std::ops::Range<{integer}>; 1]` = note: `[start..end]` is an array of one `Range`; you might have meant to have a `Range` without the brackets: `start..end` = note: required by `std::iter::IntoIterator::into_iter` ``` But in Rust 1.53 and later, it compiles fine. It iterates over the array by value, for one iteration with the element `1..3`. This is probably a mistake, which is no longer caught. Should we have a lint for it? Should Clippy have a lint for it? cc ```@estebank``` ```@flip1995``` cc rust-lang#84513
Update standard library for IntoIterator implementation of arrays This PR partially resolves issue rust-lang#84513 of updating the standard library part. I haven't found any remaining doctest examples which are using iterators over e.g. &i32 instead of just i32 in the standard library. Can anyone point me to them if there's remaining any? Thanks! r? `@m-ou-se`
Update standard library for IntoIterator implementation of arrays This PR partially resolves issue rust-lang#84513 of updating the standard library part. I haven't found any remaining doctest examples which are using iterators over e.g. &i32 instead of just i32 in the standard library. Can anyone point me to them if there's remaining any? Thanks! r? ``@m-ou-se``
Update standard library for IntoIterator implementation of arrays This PR partially resolves issue rust-lang#84513 of updating the standard library part. I haven't found any remaining doctest examples which are using iterators over e.g. &i32 instead of just i32 in the standard library. Can anyone point me to them if there's remaining any? Thanks! r? ```@m-ou-se```
…tsakis Update array_into_iter lint for 1.53 and edition changes. This updates the array_into_iter lint for Rust 1.53 and the edition changes. See rust-lang#84513 r? `@estebank`
…akis Update array_into_iter lint for 1.53 and edition changes. This updates the array_into_iter lint for Rust 1.53 and the edition changes. See rust-lang#84513 r? `@estebank`
The lang portion of this has stabilized and shipped, so un-tagging lang. libs-api may wish to continue tracking this for the proposed documentation changes. |
array::IntoIter
type: Tracking issue for by-value array iterator (featurearray_value_iter
) #65798.into_iter()
resolution edition dependent: exploration: ignoring arrays in method dispatch #84133AddIncluded in Cautiously add IntoIterator for arrays by value #84147IntoIterator
impl for arrays by value (for [T; N]
) #65819.into_iter()
in method resolution on Rust 2015 and Rust 2018: Cautiously add IntoIterator for arrays by value #84147array_into_iter
lint.a.into_iter()
syntax for backwards compatibility): Update array_into_iter lint for 1.53 and edition changes. #85682.into_iter()
infor a in [1, 2, 3].into_iter()
, since that now works on all editions: Update array_into_iter lint for 1.53 and edition changes. #85682IntoIterator::into_iter(array)
: Update array_into_iter lint for 1.53 and edition changes. #85682array::IntoIter::new
(the ".. in the future, after .." part): Update outdated docs of array::IntoIter::new. #88610array
primitive type - Update primitive docs for rust 2021. #88613array::IntoIter::new
: Update standard library for IntoIterator implementation of arrays #85930.chain(array.iter().cloned())
to just.chain(array)
since that now works on all editions. (Same forzip
,extend
etc.): Update standard library for IntoIterator implementation of arrays #85930.extend(array)
andfrom_iter(array)
wherever that simplifies things.arrays do not yet implement IntoIterator
message from Iterator trait: Remove arrays/IntoIterator message from Iterator trait. #85670for _ in [start..end]
messages from Iterator trait. (Could use a new clippy lint?): Remove Iterator #[rustc_on_unimplemented]s that no longer apply. #85689array::IntoIter::new
(IntoIterator::into_iter([1,2,3])
now works too on all editions.): Deprecate array::IntoIter::new. #88611Once edition 2021 is stable:
Some(&1)
→Some(1)
etc.)&i32
instead of justi32
.).iter().copied()
and.iter().cloned()
from examples and tests.Unresolved questions:
IntoIterator
implementation forBox<[T; N]>
etc? Add lint about big copies?)The text was updated successfully, but these errors were encountered: