diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2021-05-25 19:15:48 +0200 |
|---|---|---|
| committer | Mara Bos <m-ou.se@m-ou.se> | 2021-06-26 12:14:22 +0000 |
| commit | bdeb61437fe3cdbf96d84b48116ab113a38c417c (patch) | |
| tree | cebb699dce7577135aba3f4a9708f1b739fd3db2 | |
| parent | ef152d9b9fe9899a8e0ba14d11fa1d75ef56b1d6 (diff) | |
| download | rust-bdeb61437fe3cdbf96d84b48116ab113a38c417c.tar.gz rust-bdeb61437fe3cdbf96d84b48116ab113a38c417c.zip | |
Add test for suggestion of array_into_iter in for loop.
| -rw-r--r-- | src/test/ui/iterators/into-iter-on-arrays-2018.rs | 3 | ||||
| -rw-r--r-- | src/test/ui/iterators/into-iter-on-arrays-2018.stderr | 17 |
2 files changed, 19 insertions, 1 deletions
diff --git a/src/test/ui/iterators/into-iter-on-arrays-2018.rs b/src/test/ui/iterators/into-iter-on-arrays-2018.rs index 255ebfbd8f9..e2b75610fef 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-2018.rs +++ b/src/test/ui/iterators/into-iter-on-arrays-2018.rs @@ -25,6 +25,9 @@ fn main() { // But you can always use the trait method explicitly as an array. let _: IntoIter<i32, 10> = IntoIterator::into_iter(array); + + for _ in [1, 2, 3].into_iter() {} + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` } /// User type that dereferences to an array. diff --git a/src/test/ui/iterators/into-iter-on-arrays-2018.stderr b/src/test/ui/iterators/into-iter-on-arrays-2018.stderr index b6ca4ba2283..daa8a388366 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-2018.stderr +++ b/src/test/ui/iterators/into-iter-on-arrays-2018.stderr @@ -33,5 +33,20 @@ help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicit LL | let _: Iter<'_, i32> = IntoIterator::into_iter(Box::new(array)); | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ -warning: 2 warnings emitted +warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to <[T; N] as IntoIterator>::into_iter in Rust 2021. + --> $DIR/into-iter-on-arrays-2018.rs:27:24 + | +LL | for _ in [1, 2, 3].into_iter() {} + | ^^^^^^^^^ + | +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity + | +LL | for _ in [1, 2, 3].iter() {} + | ^^^^ +help: or remove `.into_iter()` to iterate by value + | +LL | for _ in [1, 2, 3] {} + | -- + +warning: 3 warnings emitted |
