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