Skip to content

Commit 1e99f26

Browse files
Rollup merge of #80470 - SimonSapin:array-intoiter-type, r=m-ou-se
Stabilize by-value `[T; N]` iterator `core::array::IntoIter` Tracking issue: #65798 This is unblocked now that `min_const_generics` has been stabilized in #79135. This PR does *not* include the corresponding `IntoIterator` impl, which is #65819. Instead, an iterator can be constructed through the `new` method. `new` would become unnecessary when `IntoIterator` is implemented and might be deprecated then, although it will stay stable.
2 parents 054c29d + 83d32b0 commit 1e99f26

File tree

11 files changed

+19
-18
lines changed

11 files changed

+19
-18
lines changed

compiler/rustc_arena/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@
1111
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
1212
test(no_crate_inject, attr(deny(warnings)))
1313
)]
14-
#![feature(array_value_iter_slice)]
1514
#![feature(dropck_eyepatch)]
1615
#![feature(new_uninit)]
1716
#![feature(maybe_uninit_slice)]
18-
#![feature(array_value_iter)]
1917
#![cfg_attr(bootstrap, feature(min_const_generics))]
2018
#![feature(min_specialization)]
2119
#![cfg_attr(test, feature(test))]

compiler/rustc_ast_lowering/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
//! get confused if the spans from leaf AST nodes occur in multiple places
3131
//! in the HIR, especially for multiple identifiers.
3232
33-
#![feature(array_value_iter)]
3433
#![feature(crate_visibility_modifier)]
3534
#![feature(or_patterns)]
3635
#![recursion_limit = "256"]

compiler/rustc_hir/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
//!
33
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/hir.html
44
5-
#![feature(array_value_iter)]
65
#![feature(crate_visibility_modifier)]
76
#![feature(const_fn)] // For the unsizing cast on `&[]`
87
#![feature(const_panic)]

compiler/rustc_trait_selection/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
//! This API is completely unstable and subject to change.
1212
1313
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
14-
#![feature(array_value_iter)]
1514
#![feature(bool_to_option)]
1615
#![feature(box_patterns)]
1716
#![feature(drain_filter)]

compiler/rustc_typeck/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ This API is completely unstable and subject to change.
5656
*/
5757

5858
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
59-
#![feature(array_value_iter)]
6059
#![feature(bool_to_option)]
6160
#![feature(box_syntax)]
6261
#![feature(crate_visibility_modifier)]

library/alloc/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
#![feature(allocator_api)]
7979
#![feature(array_chunks)]
8080
#![feature(array_methods)]
81-
#![feature(array_value_iter)]
8281
#![feature(array_windows)]
8382
#![feature(allow_internal_unstable)]
8483
#![feature(arbitrary_self_types)]

library/core/src/array/iter.rs

+18-7
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::{
1111
/// A by-value [array] iterator.
1212
///
1313
/// [array]: ../../std/primitive.array.html
14-
#[unstable(feature = "array_value_iter", issue = "65798")]
14+
#[stable(feature = "array_value_iter", since = "1.51.0")]
1515
pub struct IntoIter<T, const N: usize> {
1616
/// This is the array we are iterating over.
1717
///
@@ -38,10 +38,21 @@ pub struct IntoIter<T, const N: usize> {
3838
impl<T, const N: usize> IntoIter<T, N> {
3939
/// Creates a new iterator over the given `array`.
4040
///
41-
/// *Note*: this method might never get stabilized and/or removed in the
42-
/// future as there will likely be another, preferred way of obtaining this
43-
/// iterator (either via `IntoIterator` for arrays or via another way).
44-
#[unstable(feature = "array_value_iter", issue = "65798")]
41+
/// *Note*: this method might be deprecated in the future,
42+
/// after [`IntoIterator` is implemented for arrays][array-into-iter].
43+
///
44+
/// # Examples
45+
///
46+
/// ```
47+
/// use std::array;
48+
///
49+
/// for value in array::IntoIter::new([1, 2, 3, 4, 5]) {
50+
/// // The type of `value` is a `i32` here, instead of `&i32`
51+
/// let _: i32 = value;
52+
/// }
53+
/// ```
54+
/// [array-into-iter]: https://github.com/rust-lang/rust/pull/65819
55+
#[stable(feature = "array_value_iter", since = "1.51.0")]
4556
pub fn new(array: [T; N]) -> Self {
4657
// SAFETY: The transmute here is actually safe. The docs of `MaybeUninit`
4758
// promise:
@@ -69,7 +80,7 @@ impl<T, const N: usize> IntoIter<T, N> {
6980

7081
/// Returns an immutable slice of all elements that have not been yielded
7182
/// yet.
72-
#[unstable(feature = "array_value_iter_slice", issue = "65798")]
83+
#[stable(feature = "array_value_iter", since = "1.51.0")]
7384
pub fn as_slice(&self) -> &[T] {
7485
// SAFETY: We know that all elements within `alive` are properly initialized.
7586
unsafe {
@@ -79,7 +90,7 @@ impl<T, const N: usize> IntoIter<T, N> {
7990
}
8091

8192
/// Returns a mutable slice of all elements that have not been yielded yet.
82-
#[unstable(feature = "array_value_iter_slice", issue = "65798")]
93+
#[stable(feature = "array_value_iter", since = "1.51.0")]
8394
pub fn as_mut_slice(&mut self) -> &mut [T] {
8495
// SAFETY: We know that all elements within `alive` are properly initialized.
8596
unsafe {

library/core/src/array/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::slice::{Iter, IterMut};
1818

1919
mod iter;
2020

21-
#[unstable(feature = "array_value_iter", issue = "65798")]
21+
#[stable(feature = "array_value_iter", since = "1.51.0")]
2222
pub use iter::IntoIter;
2323

2424
/// Converts a reference to `T` into a reference to an array of length 1 (without copying).

library/core/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
#![feature(slice_internals)]
5151
#![feature(slice_partition_dedup)]
5252
#![feature(int_error_matching)]
53-
#![feature(array_value_iter)]
5453
#![feature(iter_advance_by)]
5554
#![feature(iter_partition_in_place)]
5655
#![feature(iter_intersperse)]

src/test/ui/const-generics/array-impls/into-iter-impls-length-32.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// check-pass
22

3-
#![feature(array_value_iter)]
43
#![feature(trusted_len)]
54

65
use std::{

src/test/ui/const-generics/array-impls/into-iter-impls-length-33.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// check-pass
22

3-
#![feature(array_value_iter)]
43
#![feature(trusted_len)]
54

65
use std::{

0 commit comments

Comments
 (0)