2019-11-01 11:04:31 +00:00
|
|
|
//@ run-pass
|
|
|
|
//@ run-rustfix
|
2021-06-25 17:26:31 +00:00
|
|
|
//@ rustfix-only-machine-applicable
|
2019-11-01 11:04:31 +00:00
|
|
|
|
2022-11-13 17:31:58 +00:00
|
|
|
#[allow(unused_must_use, unused_allocation)]
|
2019-11-01 11:04:31 +00:00
|
|
|
fn main() {
|
|
|
|
let small = [1, 2];
|
|
|
|
let big = [0u8; 33];
|
|
|
|
|
|
|
|
// Expressions that should trigger the lint
|
|
|
|
small.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
|
2019-11-01 11:04:31 +00:00
|
|
|
[1, 2].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
|
2019-11-01 11:04:31 +00:00
|
|
|
big.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
|
2019-11-01 11:04:31 +00:00
|
|
|
[0u8; 33].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
|
2019-11-01 11:04:31 +00:00
|
|
|
|
2019-12-22 13:26:28 +00:00
|
|
|
Box::new(small).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
|
2019-12-22 13:26:28 +00:00
|
|
|
Box::new([1, 2]).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
|
2019-12-22 13:26:28 +00:00
|
|
|
Box::new(big).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
|
2019-12-22 13:26:28 +00:00
|
|
|
Box::new([0u8; 33]).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
|
2019-12-22 13:26:28 +00:00
|
|
|
|
|
|
|
Box::new(Box::new(small)).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
|
2019-12-22 13:26:28 +00:00
|
|
|
Box::new(Box::new([1, 2])).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
|
2019-12-22 13:26:28 +00:00
|
|
|
Box::new(Box::new(big)).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
|
2019-12-22 13:26:28 +00:00
|
|
|
Box::new(Box::new([0u8; 33])).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
|
2019-11-01 11:04:31 +00:00
|
|
|
|
|
|
|
// Expressions that should not
|
|
|
|
(&[1, 2]).into_iter();
|
|
|
|
(&small).into_iter();
|
|
|
|
(&[0u8; 33]).into_iter();
|
|
|
|
(&big).into_iter();
|
|
|
|
|
|
|
|
for _ in &[1, 2] {}
|
|
|
|
(&small as &[_]).into_iter();
|
|
|
|
small[..].into_iter();
|
|
|
|
std::iter::IntoIterator::into_iter(&[1, 2]);
|
2020-10-19 15:50:36 +00:00
|
|
|
|
|
|
|
#[allow(array_into_iter)]
|
|
|
|
[0, 1].into_iter();
|
2019-11-01 11:04:31 +00:00
|
|
|
}
|