From 50236d869fbc0d286b71eed7c42adbf7ed023b53 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Tue, 25 May 2021 17:12:45 +0200 Subject: [PATCH 1/6] Change wording on array_into_iter lint for 1.53 and edition changes. --- compiler/rustc_lint/src/array_into_iter.rs | 36 +++++++--------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/compiler/rustc_lint/src/array_into_iter.rs b/compiler/rustc_lint/src/array_into_iter.rs index 0b5bd39f7f98..c947ef25b781 100644 --- a/compiler/rustc_lint/src/array_into_iter.rs +++ b/compiler/rustc_lint/src/array_into_iter.rs @@ -3,7 +3,6 @@ use rustc_errors::Applicability; use rustc_hir as hir; use rustc_middle::ty; use rustc_middle::ty::adjustment::{Adjust, Adjustment}; -use rustc_session::lint::FutureBreakage; use rustc_span::symbol::sym; declare_lint! { @@ -20,28 +19,15 @@ declare_lint! { /// /// ### Explanation /// - /// In the future, it is planned to add an `IntoIter` implementation for - /// arrays such that it will iterate over *values* of the array instead of - /// references. Due to how method resolution works, this will change - /// existing code that uses `into_iter` on arrays. The solution to avoid - /// this warning is to use `iter()` instead of `into_iter()`. - /// - /// This is a [future-incompatible] lint to transition this to a hard error - /// in the future. See [issue #66145] for more details and a more thorough - /// description of the lint. - /// - /// [issue #66145]: https://github.com/rust-lang/rust/issues/66145 - /// [future-incompatible]: ../index.md#future-incompatible-lints + /// Since Rust 1.53, arrays implement `IntoIterator`. However, to avoid + /// breakage, `array.into_iter()` in Rust 2015 and 2018 code will still + /// behave as `(&array).into_iter()`, returning an iterator over + /// references, just like in Rust 1.52 and earlier. + /// This only applies to the method call syntax `array.into_iter()`, not to + /// any other syntax such as `for _ in array` or `IntoIterator::into_iter(array)`. pub ARRAY_INTO_ITER, Warn, - "detects calling `into_iter` on arrays", - @future_incompatible = FutureIncompatibleInfo { - reference: "issue #66145 ", - edition: None, - future_breakage: Some(FutureBreakage { - date: None - }) - }; + "detects calling `into_iter` on arrays in Rust 2015 and 2018", } declare_lint_pass!( @@ -107,10 +93,10 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter { }; cx.struct_span_lint(ARRAY_INTO_ITER, *span, |lint| { lint.build(&format!( - "this method call currently resolves to `<&{} as IntoIterator>::into_iter` (due \ - to autoref coercions), but that might change in the future when \ - `IntoIterator` impls for arrays are added.", - target, + "this method call resolves to `<&{} as IntoIterator>::into_iter` \ + (due to backwards compatibility), \ + but will resolve to <{} as IntoIterator>::into_iter in Rust 2021.", + target, target, )) .span_suggestion( call.ident.span, From 1e89954beef0ac46b2ef43fa5cf183c844c0a582 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Tue, 25 May 2021 17:13:15 +0200 Subject: [PATCH 2/6] Add new suggestion to array_into_iter lint. --- compiler/rustc_lint/src/array_into_iter.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/compiler/rustc_lint/src/array_into_iter.rs b/compiler/rustc_lint/src/array_into_iter.rs index c947ef25b781..6d95d8d77be5 100644 --- a/compiler/rustc_lint/src/array_into_iter.rs +++ b/compiler/rustc_lint/src/array_into_iter.rs @@ -104,6 +104,14 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter { "iter".into(), Applicability::MachineApplicable, ) + .multipart_suggestion( + "or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value", + vec![ + (expr.span.shrink_to_lo(), "IntoIterator::into_iter(".into()), + (receiver_arg.span.shrink_to_hi().to(expr.span.shrink_to_hi()), ")".into()), + ], + Applicability::MaybeIncorrect, + ) .emit(); }) } From fae41690c4c5cc2e25d44fc317a8ee35073655d4 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Tue, 25 May 2021 17:56:19 +0200 Subject: [PATCH 3/6] Update tests for updated array_into_iter lint. --- .../ui/iterators/into-iter-on-arrays-2018.rs | 6 +- .../iterators/into-iter-on-arrays-2018.stderr | 49 ++- .../iterators/into-iter-on-arrays-lint.fixed | 36 +-- .../ui/iterators/into-iter-on-arrays-lint.rs | 36 +-- .../iterators/into-iter-on-arrays-lint.stderr | 302 +++++++----------- 5 files changed, 165 insertions(+), 264 deletions(-) diff --git a/src/test/ui/iterators/into-iter-on-arrays-2018.rs b/src/test/ui/iterators/into-iter-on-arrays-2018.rs index 5661397b3c17..609bc2345536 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-2018.rs +++ b/src/test/ui/iterators/into-iter-on-arrays-2018.rs @@ -12,12 +12,10 @@ fn main() { // Before 2021, the method dispatched to `IntoIterator for &[T; N]`, // which we continue to support for compatibility. let _: Iter<'_, i32> = array.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 + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` let _: Iter<'_, i32> = Box::new(array).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 + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` // The `array_into_iter` lint doesn't cover other wrappers that deref to an array. let _: Iter<'_, i32> = Rc::new(array).into_iter(); diff --git a/src/test/ui/iterators/into-iter-on-arrays-2018.stderr b/src/test/ui/iterators/into-iter-on-arrays-2018.stderr index b43338382f20..c9489c2b743d 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-2018.stderr +++ b/src/test/ui/iterators/into-iter-on-arrays-2018.stderr @@ -1,42 +1,33 @@ -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. +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:14:34 | LL | let _: Iter<'_, i32> = array.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-2018.rs:18:44 +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | -LL | let _: Iter<'_, i32> = Box::new(array).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | let _: Iter<'_, i32> = array.iter(); + | ^^^^ +help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value | - = 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: 2 warnings emitted +LL | let _: Iter<'_, i32> = IntoIterator::into_iter(array); + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ -Future incompatibility report: Future breakage date: None, diagnostic: -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-2018.rs:14:34 +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:17:44 | -LL | let _: Iter<'_, i32> = array.into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | let _: Iter<'_, i32> = Box::new(array).into_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 - -Future breakage date: None, diagnostic: -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-2018.rs:18:44 +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | -LL | let _: Iter<'_, i32> = Box::new(array).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | let _: Iter<'_, i32> = Box::new(array).iter(); + | ^^^^ +help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value | - = 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 +LL | let _: Iter<'_, i32> = IntoIterator::into_iter(Box::new(array)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ + +warning: 2 warnings emitted diff --git a/src/test/ui/iterators/into-iter-on-arrays-lint.fixed b/src/test/ui/iterators/into-iter-on-arrays-lint.fixed index 7f511bde3cbf..d0346bc5efac 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-lint.fixed +++ b/src/test/ui/iterators/into-iter-on-arrays-lint.fixed @@ -7,43 +7,31 @@ fn main() { // 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 + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` [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 + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` big.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 + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` [0u8; 33].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 + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new(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 + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new([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 + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new(big).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 + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new([0u8; 33]).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 + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new(Box::new(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 + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new(Box::new([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 + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new(Box::new(big)).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 + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new(Box::new([0u8; 33])).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 + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` // Expressions that should not (&[1, 2]).into_iter(); diff --git a/src/test/ui/iterators/into-iter-on-arrays-lint.rs b/src/test/ui/iterators/into-iter-on-arrays-lint.rs index d5fe83a7834b..d7b0032abdd7 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-lint.rs +++ b/src/test/ui/iterators/into-iter-on-arrays-lint.rs @@ -7,43 +7,31 @@ fn main() { // 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 + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` [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 + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` big.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 + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` [0u8; 33].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 + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new(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 + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new([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 + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new(big).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 + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new([0u8; 33]).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 + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new(Box::new(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 + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new(Box::new([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 + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new(Box::new(big)).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 + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new(Box::new([0u8; 33])).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 + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` // Expressions that should not (&[1, 2]).into_iter(); diff --git a/src/test/ui/iterators/into-iter-on-arrays-lint.stderr b/src/test/ui/iterators/into-iter-on-arrays-lint.stderr index 211315c3fcf0..ca21bc508724 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-lint.stderr +++ b/src/test/ui/iterators/into-iter-on-arrays-lint.stderr @@ -1,247 +1,183 @@ -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. +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-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 +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | -LL | [1, 2].into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | small.iter(); + | ^^^^ +help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value | - = 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 +LL | IntoIterator::into_iter(small); + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ -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:15:9 - | -LL | big.into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +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-lint.rs:11:12 | - = 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:18:15 - | -LL | [0u8; 33].into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | [1, 2].into_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; 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:22:21 +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | -LL | Box::new(small).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | [1, 2].iter(); + | ^^^^ +help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value | - = 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 +LL | IntoIterator::into_iter([1, 2]); + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ -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:25:22 +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-lint.rs:13:9 | -LL | Box::new([1, 2]).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | big.into_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; 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:28:19 +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | -LL | Box::new(big).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | big.iter(); + | ^^^^ +help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value | - = 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 +LL | IntoIterator::into_iter(big); + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ -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:31:25 +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-lint.rs:15:15 | -LL | Box::new([0u8; 33]).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | [0u8; 33].into_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; 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:35:31 +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | -LL | Box::new(Box::new(small)).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | [0u8; 33].iter(); + | ^^^^ +help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value | - = 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 +LL | IntoIterator::into_iter([0u8; 33]); + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ -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:38:32 +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-lint.rs:18:21 | -LL | Box::new(Box::new([1, 2])).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | Box::new(small).into_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; 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:41:29 +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | -LL | Box::new(Box::new(big)).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | Box::new(small).iter(); + | ^^^^ +help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value | - = 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 +LL | IntoIterator::into_iter(Box::new(small)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ -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:44:35 +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-lint.rs:20:22 | -LL | Box::new(Box::new([0u8; 33])).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | Box::new([1, 2]).into_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: 12 warnings emitted - -Future incompatibility report: Future breakage date: None, diagnostic: -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 +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | -LL | small.into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | Box::new([1, 2]).iter(); + | ^^^^ +help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value | - = 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 +LL | IntoIterator::into_iter(Box::new([1, 2])); + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ -Future breakage date: None, diagnostic: -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 +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-lint.rs:22:19 | -LL | [1, 2].into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | Box::new(big).into_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 - -Future breakage date: None, diagnostic: -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:15:9 +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | -LL | big.into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | Box::new(big).iter(); + | ^^^^ +help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value | - = 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 +LL | IntoIterator::into_iter(Box::new(big)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ -Future breakage date: None, diagnostic: -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:18:15 +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-lint.rs:24:25 | -LL | [0u8; 33].into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | Box::new([0u8; 33]).into_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 - -Future breakage date: None, diagnostic: -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:22:21 +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | -LL | Box::new(small).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | Box::new([0u8; 33]).iter(); + | ^^^^ +help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value | - = 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 +LL | IntoIterator::into_iter(Box::new([0u8; 33])); + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ -Future breakage date: None, diagnostic: -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:25:22 +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-lint.rs:27:31 | -LL | Box::new([1, 2]).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | Box::new(Box::new(small)).into_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 - -Future breakage date: None, diagnostic: -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:28:19 +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | -LL | Box::new(big).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | Box::new(Box::new(small)).iter(); + | ^^^^ +help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value | - = 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 +LL | IntoIterator::into_iter(Box::new(Box::new(small))); + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ -Future breakage date: None, diagnostic: -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:31:25 +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-lint.rs:29:32 | -LL | Box::new([0u8; 33]).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | Box::new(Box::new([1, 2])).into_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 - -Future breakage date: None, diagnostic: -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:35:31 +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | -LL | Box::new(Box::new(small)).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | Box::new(Box::new([1, 2])).iter(); + | ^^^^ +help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value | - = 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 +LL | IntoIterator::into_iter(Box::new(Box::new([1, 2]))); + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ -Future breakage date: None, diagnostic: -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:38:32 +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-lint.rs:31:29 | -LL | Box::new(Box::new([1, 2])).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | Box::new(Box::new(big)).into_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 - -Future breakage date: None, diagnostic: -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:41:29 +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | -LL | Box::new(Box::new(big)).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | Box::new(Box::new(big)).iter(); + | ^^^^ +help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value | - = 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 +LL | IntoIterator::into_iter(Box::new(Box::new(big))); + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ -Future breakage date: None, diagnostic: -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:44:35 +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-lint.rs:33:35 | LL | Box::new(Box::new([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 - -Future breakage date: None, diagnostic: -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:60:12 + | ^^^^^^^^^ | -LL | [0, 1].into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | -note: the lint level is defined here - --> $DIR/into-iter-on-arrays-lint.rs:59:13 +LL | Box::new(Box::new([0u8; 33])).iter(); + | ^^^^ +help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value | -LL | #[allow(array_into_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 +LL | IntoIterator::into_iter(Box::new(Box::new([0u8; 33]))); + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ + +warning: 12 warnings emitted From 612f97426a3e4c215b7c5cc42dbb02e603c54ae3 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Tue, 25 May 2021 19:15:27 +0200 Subject: [PATCH 4/6] Better suggestion for array_into_iter in for loop. --- compiler/rustc_lint/src/array_into_iter.rs | 61 ++++++++++++++++------ compiler/rustc_lint/src/lib.rs | 2 +- 2 files changed, 45 insertions(+), 18 deletions(-) diff --git a/compiler/rustc_lint/src/array_into_iter.rs b/compiler/rustc_lint/src/array_into_iter.rs index 6d95d8d77be5..727d9ea35319 100644 --- a/compiler/rustc_lint/src/array_into_iter.rs +++ b/compiler/rustc_lint/src/array_into_iter.rs @@ -4,6 +4,7 @@ use rustc_hir as hir; use rustc_middle::ty; use rustc_middle::ty::adjustment::{Adjust, Adjustment}; use rustc_span::symbol::sym; +use rustc_span::Span; declare_lint! { /// The `array_into_iter` lint detects calling `into_iter` on arrays. @@ -30,13 +31,29 @@ declare_lint! { "detects calling `into_iter` on arrays in Rust 2015 and 2018", } -declare_lint_pass!( - /// Checks for instances of calling `into_iter` on arrays. - ArrayIntoIter => [ARRAY_INTO_ITER] -); +#[derive(Copy, Clone, Default)] +pub struct ArrayIntoIter { + for_expr_span: Span, +} + +impl_lint_pass!(ArrayIntoIter => [ARRAY_INTO_ITER]); impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) { + // Save the span of expressions in `for _ in expr` syntax, + // so we can give a better suggestion for those later. + if let hir::ExprKind::Match(arg, [_], hir::MatchSource::ForLoopDesugar) = &expr.kind { + if let hir::ExprKind::Call(path, [arg]) = &arg.kind { + if let hir::ExprKind::Path(hir::QPath::LangItem( + hir::LangItem::IntoIterIntoIter, + _, + )) = &path.kind + { + self.for_expr_span = arg.span; + } + } + } + // We only care about method call expressions. if let hir::ExprKind::MethodCall(call, span, args, _) = &expr.kind { if call.ident.name != sym::into_iter { @@ -92,27 +109,37 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter { _ => bug!("array type coerced to something other than array or slice"), }; cx.struct_span_lint(ARRAY_INTO_ITER, *span, |lint| { - lint.build(&format!( + let mut diag = lint.build(&format!( "this method call resolves to `<&{} as IntoIterator>::into_iter` \ (due to backwards compatibility), \ but will resolve to <{} as IntoIterator>::into_iter in Rust 2021.", target, target, - )) - .span_suggestion( + )); + diag.span_suggestion( call.ident.span, "use `.iter()` instead of `.into_iter()` to avoid ambiguity", "iter".into(), Applicability::MachineApplicable, - ) - .multipart_suggestion( - "or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value", - vec![ - (expr.span.shrink_to_lo(), "IntoIterator::into_iter(".into()), - (receiver_arg.span.shrink_to_hi().to(expr.span.shrink_to_hi()), ")".into()), - ], - Applicability::MaybeIncorrect, - ) - .emit(); + ); + if self.for_expr_span == expr.span { + let expr_span = expr.span.ctxt().outer_expn_data().call_site; + diag.span_suggestion( + receiver_arg.span.shrink_to_hi().to(expr_span.shrink_to_hi()), + "or remove `.into_iter()` to iterate by value", + String::new(), + Applicability::MaybeIncorrect, + ); + } else { + diag.multipart_suggestion( + "or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value", + vec![ + (expr.span.shrink_to_lo(), "IntoIterator::into_iter(".into()), + (receiver_arg.span.shrink_to_hi().to(expr.span.shrink_to_hi()), ")".into()), + ], + Applicability::MaybeIncorrect, + ); + } + diag.emit(); }) } } diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 4f59460aa82a..89f9809d643e 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -163,7 +163,7 @@ macro_rules! late_lint_passes { // FIXME: Turn the computation of types which implement Debug into a query // and change this to a module lint pass MissingDebugImplementations: MissingDebugImplementations::default(), - ArrayIntoIter: ArrayIntoIter, + ArrayIntoIter: ArrayIntoIter::default(), ClashingExternDeclarations: ClashingExternDeclarations::new(), DropTraitConstraints: DropTraitConstraints, TemporaryCStringAsPtr: TemporaryCStringAsPtr, From 8789117a53683e857e8660632a3688c47b1f616f Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Tue, 25 May 2021 19:15:48 +0200 Subject: [PATCH 5/6] Add test for suggestion of array_into_iter in for loop. --- .../ui/iterators/into-iter-on-arrays-2018.rs | 3 +++ .../iterators/into-iter-on-arrays-2018.stderr | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/test/ui/iterators/into-iter-on-arrays-2018.rs b/src/test/ui/iterators/into-iter-on-arrays-2018.rs index 609bc2345536..9f28e9353012 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-2018.rs +++ b/src/test/ui/iterators/into-iter-on-arrays-2018.rs @@ -23,6 +23,9 @@ fn main() { // But you can always use the trait method explicitly as an array. let _: IntoIter = 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. diff --git a/src/test/ui/iterators/into-iter-on-arrays-2018.stderr b/src/test/ui/iterators/into-iter-on-arrays-2018.stderr index c9489c2b743d..c1d0e08d933d 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-2018.stderr +++ b/src/test/ui/iterators/into-iter-on-arrays-2018.stderr @@ -29,5 +29,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 From a8614bc0f3348d582bfc1e668e2861431fdec691 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Thu, 10 Jun 2021 14:48:26 +0000 Subject: [PATCH 6/6] Remove issue-78660-cap-lints-future-compat test. --- .../ui/lint/issue-78660-cap-lints-future-compat.rs | 10 ---------- .../lint/issue-78660-cap-lints-future-compat.stderr | 11 ----------- 2 files changed, 21 deletions(-) delete mode 100644 src/test/ui/lint/issue-78660-cap-lints-future-compat.rs delete mode 100644 src/test/ui/lint/issue-78660-cap-lints-future-compat.stderr diff --git a/src/test/ui/lint/issue-78660-cap-lints-future-compat.rs b/src/test/ui/lint/issue-78660-cap-lints-future-compat.rs deleted file mode 100644 index 4d98f0ad62d4..000000000000 --- a/src/test/ui/lint/issue-78660-cap-lints-future-compat.rs +++ /dev/null @@ -1,10 +0,0 @@ -// compile-flags: -D warnings --cap-lints allow -// check-pass - -// Regression test for issue #78660 -// Tests that we don't ICE when a future-incompat-report lint has -// has a command-line source, but is capped to allow - -fn main() { - ["hi"].into_iter(); -} diff --git a/src/test/ui/lint/issue-78660-cap-lints-future-compat.stderr b/src/test/ui/lint/issue-78660-cap-lints-future-compat.stderr deleted file mode 100644 index 79958ba90d40..000000000000 --- a/src/test/ui/lint/issue-78660-cap-lints-future-compat.stderr +++ /dev/null @@ -1,11 +0,0 @@ -Future incompatibility report: Future breakage date: None, diagnostic: -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/issue-78660-cap-lints-future-compat.rs:9:12 - | -LL | ["hi"].into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` - | - = note: `-D array-into-iter` implied by `-D warnings` - = 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 -