2021-04-12 23:07:28 +00:00
|
|
|
// check-pass
|
2021-04-13 19:37:19 +00:00
|
|
|
// edition:2018
|
2021-04-12 23:07:28 +00:00
|
|
|
|
|
|
|
use std::array::IntoIter;
|
2021-04-14 19:05:24 +00:00
|
|
|
use std::ops::Deref;
|
|
|
|
use std::rc::Rc;
|
2021-04-12 23:07:28 +00:00
|
|
|
use std::slice::Iter;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let array = [0; 10];
|
|
|
|
|
2021-04-13 19:37:19 +00:00
|
|
|
// Before 2021, the method dispatched to `IntoIterator for &[T; N]`,
|
2021-04-12 23:07:28 +00:00
|
|
|
// which we continue to support for compatibility.
|
|
|
|
let _: Iter<'_, i32> = array.into_iter();
|
2021-05-25 15:56:19 +00:00
|
|
|
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
|
2021-06-15 15:16:21 +00:00
|
|
|
//~| WARNING this changes meaning
|
2021-04-12 23:07:28 +00:00
|
|
|
|
2021-04-13 19:37:19 +00:00
|
|
|
let _: Iter<'_, i32> = Box::new(array).into_iter();
|
2021-05-25 15:56:19 +00:00
|
|
|
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
|
2021-06-15 15:16:21 +00:00
|
|
|
//~| WARNING this changes meaning
|
2021-04-13 19:37:19 +00:00
|
|
|
|
2021-04-14 19:05:24 +00:00
|
|
|
let _: Iter<'_, i32> = Rc::new(array).into_iter();
|
2021-08-30 21:42:48 +00:00
|
|
|
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
|
|
|
|
//~| WARNING this changes meaning
|
2021-04-14 19:05:24 +00:00
|
|
|
let _: Iter<'_, i32> = Array(array).into_iter();
|
2021-08-30 21:42:48 +00:00
|
|
|
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
|
|
|
|
//~| WARNING this changes meaning
|
2021-04-14 19:05:24 +00:00
|
|
|
|
2021-04-12 23:07:28 +00:00
|
|
|
// But you can always use the trait method explicitly as an array.
|
|
|
|
let _: IntoIter<i32, 10> = IntoIterator::into_iter(array);
|
2021-05-25 17:15:48 +00:00
|
|
|
|
|
|
|
for _ in [1, 2, 3].into_iter() {}
|
|
|
|
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
|
2021-06-25 17:26:31 +00:00
|
|
|
//~| WARNING this changes meaning
|
2021-04-12 23:07:28 +00:00
|
|
|
}
|
2021-04-14 19:05:24 +00:00
|
|
|
|
|
|
|
/// User type that dereferences to an array.
|
|
|
|
struct Array([i32; 10]);
|
|
|
|
|
|
|
|
impl Deref for Array {
|
|
|
|
type Target = [i32; 10];
|
|
|
|
|
|
|
|
fn deref(&self) -> &Self::Target {
|
|
|
|
&self.0
|
|
|
|
}
|
|
|
|
}
|