Skip to content

Commit 4f98e23

Browse files
committed
Skip into_iter() for arrays before 2021
1 parent af27040 commit 4f98e23

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

core/src/array/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ impl<T: fmt::Debug, const N: usize> fmt::Debug for [T; N] {
155155
}
156156
}
157157

158+
// Note: the `#[rustc_skip_array_during_method_dispatch]` on `trait IntoIterator`
159+
// hides this implementation from explicit `.into_iter()` calls on editions < 2021,
160+
// so those calls will still resolve to the slice implementation, by reference.
161+
#[cfg(not(bootstrap))]
158162
#[stable(feature = "array_into_iter_impl", since = "1.53.0")]
159163
impl<T, const N: usize> IntoIterator for [T; N] {
160164
type Item = T;

core/src/iter/traits/collect.rs

+1
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ pub trait FromIterator<A>: Sized {
198198
/// }
199199
/// ```
200200
#[rustc_diagnostic_item = "IntoIterator"]
201+
#[cfg_attr(not(bootstrap), rustc_skip_array_during_method_dispatch)]
201202
#[stable(feature = "rust1", since = "1.0.0")]
202203
pub trait IntoIterator {
203204
/// The type of the elements being iterated over.

0 commit comments

Comments
 (0)