Add test for suggestion of array_into_iter in for loop.

This commit is contained in:
Mara Bos 2021-05-25 19:15:48 +02:00
parent ef152d9b9f
commit bdeb61437f
2 changed files with 19 additions and 1 deletions

View File

@ -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.

View File

@ -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