From 9271df97f516be29819afbd31d717789769b1d81 Mon Sep 17 00:00:00 2001 From: bendn Date: Tue, 11 Nov 2025 13:46:52 +0700 Subject: [PATCH 1/2] stabilize [T]::array_windows --- compiler/rustc_ast/src/lib.rs | 2 +- compiler/rustc_data_structures/src/lib.rs | 2 +- compiler/rustc_errors/src/lib.rs | 2 +- compiler/rustc_expand/src/lib.rs | 2 +- compiler/rustc_lint/src/lib.rs | 2 +- compiler/rustc_middle/src/lib.rs | 2 +- compiler/rustc_mir_transform/src/lib.rs | 2 +- compiler/rustc_monomorphize/src/lib.rs | 2 +- compiler/rustc_span/src/lib.rs | 2 +- library/alloc/src/lib.rs | 1 - library/alloc/src/slice.rs | 2 +- library/core/src/slice/iter.rs | 10 ++++------ library/core/src/slice/mod.rs | 5 ++--- library/coretests/tests/lib.rs | 1 - src/tools/clippy/clippy_lints/src/lib.rs | 2 +- src/tools/clippy/clippy_utils/src/lib.rs | 2 +- 16 files changed, 18 insertions(+), 23 deletions(-) diff --git a/compiler/rustc_ast/src/lib.rs b/compiler/rustc_ast/src/lib.rs index e19dccbce02ae..cbdc89f9deedc 100644 --- a/compiler/rustc_ast/src/lib.rs +++ b/compiler/rustc_ast/src/lib.rs @@ -5,8 +5,8 @@ //! This API is completely unstable and subject to change. // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(array_windows))] #![doc(test(attr(deny(warnings), allow(internal_features))))] -#![feature(array_windows)] #![feature(associated_type_defaults)] #![feature(box_patterns)] #![feature(if_let_guard)] diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs index b4031973fbc25..41f6292e740bd 100644 --- a/compiler/rustc_data_structures/src/lib.rs +++ b/compiler/rustc_data_structures/src/lib.rs @@ -10,9 +10,9 @@ #![allow(internal_features)] #![allow(rustc::default_hash_types)] #![allow(rustc::potential_query_instability)] +#![cfg_attr(bootstrap, feature(array_windows))] #![deny(unsafe_op_in_unsafe_fn)] #![feature(allocator_api)] -#![feature(array_windows)] #![feature(ascii_char)] #![feature(ascii_char_variants)] #![feature(assert_matches)] diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 2f88e587ae9f7..abacab636fe85 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -7,7 +7,7 @@ #![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::direct_use_of_rustc_type_ir)] #![allow(rustc::untranslatable_diagnostic)] -#![feature(array_windows)] +#![cfg_attr(bootstrap, feature(array_windows))] #![feature(assert_matches)] #![feature(associated_type_defaults)] #![feature(box_patterns)] diff --git a/compiler/rustc_expand/src/lib.rs b/compiler/rustc_expand/src/lib.rs index e76fca92c5861..5eefa4bcdf6be 100644 --- a/compiler/rustc_expand/src/lib.rs +++ b/compiler/rustc_expand/src/lib.rs @@ -1,7 +1,7 @@ // tidy-alphabetical-start #![allow(internal_features)] #![allow(rustc::diagnostic_outside_of_impl)] -#![feature(array_windows)] +#![cfg_attr(bootstrap, feature(array_windows))] #![feature(associated_type_defaults)] #![feature(if_let_guard)] #![feature(macro_metavar_expr)] diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 8a83434e10c15..d552d64e5ccaa 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -21,7 +21,7 @@ // tidy-alphabetical-start #![allow(internal_features)] -#![feature(array_windows)] +#![cfg_attr(bootstrap, feature(array_windows))] #![feature(assert_matches)] #![feature(box_patterns)] #![feature(if_let_guard)] diff --git a/compiler/rustc_middle/src/lib.rs b/compiler/rustc_middle/src/lib.rs index 8d4385a2fd32c..0b6512fadf291 100644 --- a/compiler/rustc_middle/src/lib.rs +++ b/compiler/rustc_middle/src/lib.rs @@ -29,8 +29,8 @@ #![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::direct_use_of_rustc_type_ir)] #![allow(rustc::untranslatable_diagnostic)] +#![cfg_attr(bootstrap, feature(array_windows))] #![feature(allocator_api)] -#![feature(array_windows)] #![feature(assert_matches)] #![feature(associated_type_defaults)] #![feature(box_as_ptr)] diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 18b798c01faab..1f6cc2700592b 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -1,5 +1,5 @@ // tidy-alphabetical-start -#![feature(array_windows)] +#![cfg_attr(bootstrap, feature(array_windows))] #![feature(assert_matches)] #![feature(box_patterns)] #![feature(const_type_name)] diff --git a/compiler/rustc_monomorphize/src/lib.rs b/compiler/rustc_monomorphize/src/lib.rs index 05683940cba4f..8b48cf5a6501d 100644 --- a/compiler/rustc_monomorphize/src/lib.rs +++ b/compiler/rustc_monomorphize/src/lib.rs @@ -1,5 +1,5 @@ // tidy-alphabetical-start -#![feature(array_windows)] +#![cfg_attr(bootstrap, feature(array_windows))] #![feature(file_buffered)] #![feature(if_let_guard)] #![feature(impl_trait_in_assoc_type)] diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index afd4564f1b6fd..d7228afa41a1b 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -17,8 +17,8 @@ // tidy-alphabetical-start #![allow(internal_features)] +#![cfg_attr(bootstrap, feature(array_windows))] #![cfg_attr(target_arch = "loongarch64", feature(stdarch_loongarch))] -#![feature(array_windows)] #![feature(cfg_select)] #![feature(core_io_borrowed_buf)] #![feature(if_let_guard)] diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index 666ae27fb8634..4b698a9256fc6 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -89,7 +89,6 @@ #![feature(alloc_layout_extra)] #![feature(allocator_api)] #![feature(array_into_iter_constructors)] -#![feature(array_windows)] #![feature(ascii_char)] #![feature(assert_matches)] #![feature(async_fn_traits)] diff --git a/library/alloc/src/slice.rs b/library/alloc/src/slice.rs index a83b51ccb60c3..e7d0fc3454eeb 100644 --- a/library/alloc/src/slice.rs +++ b/library/alloc/src/slice.rs @@ -18,7 +18,7 @@ use core::cmp::Ordering::{self, Less}; use core::mem::MaybeUninit; #[cfg(not(no_global_oom_handling))] use core::ptr; -#[unstable(feature = "array_windows", issue = "75027")] +#[stable(feature = "array_windows", since = "CURRENT_RUSTC_VERSION")] pub use core::slice::ArrayWindows; #[stable(feature = "inherent_ascii_escape", since = "1.60.0")] pub use core::slice::EscapeAscii; diff --git a/library/core/src/slice/iter.rs b/library/core/src/slice/iter.rs index 7053ae86e732f..2145e50484456 100644 --- a/library/core/src/slice/iter.rs +++ b/library/core/src/slice/iter.rs @@ -2187,8 +2187,6 @@ unsafe impl Sync for ChunksExactMut<'_, T> where T: Sync {} /// # Example /// /// ``` -/// #![feature(array_windows)] -/// /// let slice = [0, 1, 2, 3]; /// let mut iter = slice.array_windows::<2>(); /// assert_eq!(iter.next(), Some(&[0, 1])); @@ -2200,7 +2198,7 @@ unsafe impl Sync for ChunksExactMut<'_, T> where T: Sync {} /// [`array_windows`]: slice::array_windows /// [slices]: slice #[derive(Debug, Clone, Copy)] -#[unstable(feature = "array_windows", issue = "75027")] +#[stable(feature = "array_windows", since = "CURRENT_RUSTC_VERSION")] #[must_use = "iterators are lazy and do nothing unless consumed"] pub struct ArrayWindows<'a, T: 'a, const N: usize> { v: &'a [T], @@ -2213,7 +2211,7 @@ impl<'a, T: 'a, const N: usize> ArrayWindows<'a, T, N> { } } -#[unstable(feature = "array_windows", issue = "75027")] +#[stable(feature = "array_windows", since = "CURRENT_RUSTC_VERSION")] impl<'a, T, const N: usize> Iterator for ArrayWindows<'a, T, N> { type Item = &'a [T; N]; @@ -2250,7 +2248,7 @@ impl<'a, T, const N: usize> Iterator for ArrayWindows<'a, T, N> { } } -#[unstable(feature = "array_windows", issue = "75027")] +#[stable(feature = "array_windows", since = "CURRENT_RUSTC_VERSION")] impl<'a, T, const N: usize> DoubleEndedIterator for ArrayWindows<'a, T, N> { #[inline] fn next_back(&mut self) -> Option<&'a [T; N]> { @@ -2269,7 +2267,7 @@ impl<'a, T, const N: usize> DoubleEndedIterator for ArrayWindows<'a, T, N> { } } -#[unstable(feature = "array_windows", issue = "75027")] +#[stable(feature = "array_windows", since = "CURRENT_RUSTC_VERSION")] impl ExactSizeIterator for ArrayWindows<'_, T, N> { fn is_empty(&self) -> bool { self.v.len() < N diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index f03f2045444df..8b32f00bc861d 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -51,7 +51,7 @@ pub use ascii::is_ascii_simple; pub use index::SliceIndex; #[unstable(feature = "slice_range", issue = "76393")] pub use index::{range, try_range}; -#[unstable(feature = "array_windows", issue = "75027")] +#[stable(feature = "array_windows", since = "CURRENT_RUSTC_VERSION")] pub use iter::ArrayWindows; #[stable(feature = "slice_group_by", since = "1.77.0")] pub use iter::{ChunkBy, ChunkByMut}; @@ -1626,7 +1626,6 @@ impl [T] { /// # Examples /// /// ``` - /// #![feature(array_windows)] /// let slice = [0, 1, 2, 3]; /// let mut iter = slice.array_windows(); /// assert_eq!(iter.next().unwrap(), &[0, 1]); @@ -1636,7 +1635,7 @@ impl [T] { /// ``` /// /// [`windows`]: slice::windows - #[unstable(feature = "array_windows", issue = "75027")] + #[stable(feature = "array_windows", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")] #[inline] #[track_caller] diff --git a/library/coretests/tests/lib.rs b/library/coretests/tests/lib.rs index 80b62038c40ec..78df4fcb541c7 100644 --- a/library/coretests/tests/lib.rs +++ b/library/coretests/tests/lib.rs @@ -4,7 +4,6 @@ #![feature(alloc_layout_extra)] #![feature(array_ptr_get)] #![feature(array_try_from_fn)] -#![feature(array_windows)] #![feature(ascii_char)] #![feature(ascii_char_variants)] #![feature(async_iter_from_iter)] diff --git a/src/tools/clippy/clippy_lints/src/lib.rs b/src/tools/clippy/clippy_lints/src/lib.rs index 99cafc7fc6d89..ac0926e89d7eb 100644 --- a/src/tools/clippy/clippy_lints/src/lib.rs +++ b/src/tools/clippy/clippy_lints/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(array_windows)] +#![cfg_attr(bootstrap, feature(array_windows))] #![feature(box_patterns)] #![feature(macro_metavar_expr_concat)] #![feature(f128)] diff --git a/src/tools/clippy/clippy_utils/src/lib.rs b/src/tools/clippy/clippy_utils/src/lib.rs index d98e3073b41d1..baed709823cf1 100644 --- a/src/tools/clippy/clippy_utils/src/lib.rs +++ b/src/tools/clippy/clippy_utils/src/lib.rs @@ -5,7 +5,7 @@ #![feature(rustc_private)] #![feature(assert_matches)] #![feature(unwrap_infallible)] -#![feature(array_windows)] +#![cfg_attr(bootstrap, feature(array_windows))] #![recursion_limit = "512"] #![allow( clippy::missing_errors_doc, From 806c043ae5d55928cdcecbde006ceadf921bc402 Mon Sep 17 00:00:00 2001 From: bendn Date: Tue, 11 Nov 2025 14:02:18 +0700 Subject: [PATCH 2/2] document --- library/core/src/slice/mod.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 8b32f00bc861d..dc34d2a21ee96 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -1620,8 +1620,11 @@ impl [T] { /// /// # Panics /// - /// Panics if `N` is zero. This check will most probably get changed to a compile time - /// error before this method gets stabilized. + /// Panics if `N` is zero. + /// + /// Note that this check is against a const generic parameter, not a runtime + /// value, and thus a particular monomorphization will either always panic + /// or it will never panic. /// /// # Examples ///