From ec63378418d99f677962afdadf001d8fb24605b6 Mon Sep 17 00:00:00 2001 From: Lukas Kalbertodt Date: Fri, 8 Nov 2019 00:32:40 +0100 Subject: [PATCH] [DO NOT MERGE] deny `array_into_iter` by default --- src/librustc_lint/array_into_iter.rs | 2 +- .../iterators/into-iter-on-arrays-lint.fixed | 33 ----------------- .../ui/iterators/into-iter-on-arrays-lint.rs | 33 ----------------- .../iterators/into-iter-on-arrays-lint.stderr | 37 ------------------- 4 files changed, 1 insertion(+), 104 deletions(-) delete mode 100644 src/test/ui/iterators/into-iter-on-arrays-lint.fixed delete mode 100644 src/test/ui/iterators/into-iter-on-arrays-lint.rs delete mode 100644 src/test/ui/iterators/into-iter-on-arrays-lint.stderr diff --git a/src/librustc_lint/array_into_iter.rs b/src/librustc_lint/array_into_iter.rs index e73414174fb35..31d237b9da7ba 100644 --- a/src/librustc_lint/array_into_iter.rs +++ b/src/librustc_lint/array_into_iter.rs @@ -15,7 +15,7 @@ use syntax::{ declare_lint! { pub ARRAY_INTO_ITER, - Warn, + Deny, "detects calling `into_iter` on arrays", @future_incompatible = FutureIncompatibleInfo { reference: "issue #66145 ", diff --git a/src/test/ui/iterators/into-iter-on-arrays-lint.fixed b/src/test/ui/iterators/into-iter-on-arrays-lint.fixed deleted file mode 100644 index f88a52d315918..0000000000000 --- a/src/test/ui/iterators/into-iter-on-arrays-lint.fixed +++ /dev/null @@ -1,33 +0,0 @@ -// run-pass -// run-rustfix - -fn main() { - let small = [1, 2]; - let big = [0u8; 33]; - - // Expressions that should trigger the lint - small.iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out - [1, 2].iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out - big.iter(); - //~^ WARNING this method call currently resolves to `<&[T] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out - [0u8; 33].iter(); - //~^ WARNING this method call currently resolves to `<&[T] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out - - - // 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]); -} diff --git a/src/test/ui/iterators/into-iter-on-arrays-lint.rs b/src/test/ui/iterators/into-iter-on-arrays-lint.rs deleted file mode 100644 index e1a4b535f3832..0000000000000 --- a/src/test/ui/iterators/into-iter-on-arrays-lint.rs +++ /dev/null @@ -1,33 +0,0 @@ -// run-pass -// run-rustfix - -fn main() { - let small = [1, 2]; - let big = [0u8; 33]; - - // Expressions that should trigger the lint - small.into_iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out - [1, 2].into_iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out - big.into_iter(); - //~^ WARNING this method call currently resolves to `<&[T] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out - [0u8; 33].into_iter(); - //~^ WARNING this method call currently resolves to `<&[T] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out - - - // 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]); -} diff --git a/src/test/ui/iterators/into-iter-on-arrays-lint.stderr b/src/test/ui/iterators/into-iter-on-arrays-lint.stderr deleted file mode 100644 index b5964bd44bff7..0000000000000 --- a/src/test/ui/iterators/into-iter-on-arrays-lint.stderr +++ /dev/null @@ -1,37 +0,0 @@ -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:9:11 - | -LL | small.into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` - | - = note: `#[warn(array_into_iter)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 - -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:12:12 - | -LL | [1, 2].into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 - -warning: this method call currently resolves to `<&[T] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:15:9 - | -LL | big.into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 - -warning: this method call currently resolves to `<&[T] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:18:15 - | -LL | [0u8; 33].into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 -