From e39a46f8256dd92e784a7f0cb391ad0ea1379424 Mon Sep 17 00:00:00 2001 From: voodookiidoo Date: Sat, 21 Nov 2026 19:44:14 +0500 Subject: [PATCH] rustc_diagnostic_item macros added on some iter functions --- library/core/src/iter/sources/once.rs | 1 + library/core/src/iter/sources/once_with.rs | 1 + library/core/src/iter/sources/repeat_n.rs | 1 + library/core/src/iter/traits/iterator.rs | 27 ++++++++++++++++++++++ 4 files changed, 30 insertions(+) diff --git a/library/core/src/iter/sources/once.rs b/library/core/src/iter/sources/once.rs index c4a9860bdd76c..6640f1220b5f6 100644 --- a/library/core/src/iter/sources/once.rs +++ b/library/core/src/iter/sources/once.rs @@ -53,6 +53,7 @@ use crate::iter::{FusedIterator, TrustedLen}; /// # std::io::Result::Ok(()) /// ``` #[stable(feature = "iter_once", since = "1.2.0")] +#[rustc_diagnostic_item = "iter_once"] pub fn once(value: T) -> Once { Once { inner: Some(value).into_iter() } } diff --git a/library/core/src/iter/sources/once_with.rs b/library/core/src/iter/sources/once_with.rs index c9698b4fd431b..da21d11b9aa72 100644 --- a/library/core/src/iter/sources/once_with.rs +++ b/library/core/src/iter/sources/once_with.rs @@ -58,6 +58,7 @@ use crate::iter::{FusedIterator, TrustedLen}; /// ``` #[inline] #[stable(feature = "iter_once_with", since = "1.43.0")] +#[rustc_diagnostic_item = "iter_once_with"] pub fn once_with A>(make: F) -> OnceWith { OnceWith { make: Some(make) } } diff --git a/library/core/src/iter/sources/repeat_n.rs b/library/core/src/iter/sources/repeat_n.rs index d19ff6b7e024f..5c1e401dc58c0 100644 --- a/library/core/src/iter/sources/repeat_n.rs +++ b/library/core/src/iter/sources/repeat_n.rs @@ -56,6 +56,7 @@ use crate::ops::Try; /// ``` #[inline] #[stable(feature = "iter_repeat_n", since = "1.82.0")] +#[rustc_diagnostic_item = "iter_repeat_n"] pub fn repeat_n(element: T, count: usize) -> RepeatN { RepeatN { inner: RepeatNInner::new(element, count) } } diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index a5165217aca43..98c65efc4e58e 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -396,6 +396,7 @@ pub const trait Iterator { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_diagnostic_item = "iter_nth"] fn nth(&mut self, n: usize) -> Option where Self::Item: [const] Destruct, @@ -450,6 +451,7 @@ pub const trait Iterator { #[inline] #[stable(feature = "iterator_step_by", since = "1.28.0")] #[rustc_non_const_trait_method] + #[rustc_diagnostic_item = "iter_step_by"] fn step_by(self, step: usize) -> StepBy where Self: Sized, @@ -521,6 +523,7 @@ pub const trait Iterator { /// [`OsStr`]: ../../std/ffi/struct.OsStr.html #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_diagnostic_item = "iter_chain"] fn chain(self, other: U) -> Chain where Self: Sized, @@ -640,6 +643,7 @@ pub const trait Iterator { #[inline] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_non_const_trait_method] + #[rustc_diagnostic_item = "iter_zip"] fn zip(self, other: U) -> Zip where Self: Sized, @@ -888,6 +892,7 @@ pub const trait Iterator { #[inline] #[stable(feature = "iterator_for_each", since = "1.21.0")] #[rustc_non_const_trait_method] + #[rustc_diagnostic_item = "iter_for_each"] fn for_each(self, f: F) where Self: Sized, @@ -1008,6 +1013,7 @@ pub const trait Iterator { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_diagnostic_item = "iter_filter_map"] fn filter_map(self, f: F) -> FilterMap where Self: Sized, @@ -1191,6 +1197,7 @@ pub const trait Iterator { #[inline] #[doc(alias = "drop_while")] #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_diagnostic_item = "iter_skip_while"] fn skip_while

(self, predicate: P) -> SkipWhile where Self: Sized, @@ -1269,6 +1276,7 @@ pub const trait Iterator { /// the iteration should stop, but wasn't placed back into the iterator. #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_diagnostic_item = "take_while"] fn take_while

(self, predicate: P) -> TakeWhile where Self: Sized, @@ -1357,6 +1365,7 @@ pub const trait Iterator { /// [`fuse`]: Iterator::fuse #[inline] #[stable(feature = "iter_map_while", since = "1.57.0")] + #[rustc_diagnostic_item = "iter_map_while"] fn map_while(self, predicate: P) -> MapWhile where Self: Sized, @@ -1386,6 +1395,7 @@ pub const trait Iterator { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_diagnostic_item = "iter_skip"] fn skip(self, n: usize) -> Skip where Self: Sized, @@ -1458,6 +1468,7 @@ pub const trait Iterator { #[doc(alias = "limit")] #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_diagnostic_item = "iter_take"] fn take(self, n: usize) -> Take where Self: Sized, @@ -1505,6 +1516,7 @@ pub const trait Iterator { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_diagnostic_item = "iter_scan"] fn scan(self, initial_state: St, f: F) -> Scan where Self: Sized, @@ -1544,6 +1556,7 @@ pub const trait Iterator { #[inline] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_non_const_trait_method] + #[rustc_diagnostic_item = "iter_flat_map"] fn flat_map(self, f: F) -> FlatMap where Self: Sized, @@ -1628,6 +1641,7 @@ pub const trait Iterator { /// [`flat_map()`]: Iterator::flat_map #[inline] #[stable(feature = "iterator_flatten", since = "1.29.0")] + #[rustc_diagnostic_item = "iter_flatten"] fn flatten(self) -> Flatten where Self: Sized, @@ -1840,6 +1854,7 @@ pub const trait Iterator { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_diagnostic_item = "iter_fuse"] fn fuse(self) -> Fuse where Self: Sized, @@ -1924,6 +1939,7 @@ pub const trait Iterator { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_diagnostic_item = "inspect"] fn inspect(self, f: F) -> Inspect where Self: Sized, @@ -2278,6 +2294,7 @@ pub const trait Iterator { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_non_const_trait_method] + #[rustc_diagnostic_item = "iter_partition"] fn partition(self, f: F) -> (B, B) where Self: Sized, @@ -2493,6 +2510,7 @@ pub const trait Iterator { /// ``` #[inline] #[stable(feature = "iterator_try_fold", since = "1.27.0")] + #[rustc_diagnostic_item = "iter_try_fold"] fn try_fold(&mut self, init: B, mut f: F) -> R where Self: Sized, @@ -2552,6 +2570,7 @@ pub const trait Iterator { #[inline] #[stable(feature = "iterator_try_fold", since = "1.27.0")] #[rustc_non_const_trait_method] + #[rustc_diagnostic_item = "iter_try_for_each"] fn try_for_each(&mut self, f: F) -> R where Self: Sized, @@ -2671,6 +2690,7 @@ pub const trait Iterator { #[doc(alias = "inject", alias = "foldl")] #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_diagnostic_item = "iter_fold"] fn fold(mut self, init: B, mut f: F) -> B where Self: Sized + [const] Destruct, @@ -2708,6 +2728,7 @@ pub const trait Iterator { /// ``` #[inline] #[stable(feature = "iterator_fold_self", since = "1.51.0")] + #[rustc_diagnostic_item = "iter_reduce"] fn reduce(mut self, f: F) -> Option where Self: Sized + [const] Destruct, @@ -2837,6 +2858,7 @@ pub const trait Iterator { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_diagnostic_item = "iter_all"] fn all(&mut self, f: F) -> bool where Self: Sized, @@ -2894,6 +2916,7 @@ pub const trait Iterator { #[inline] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_non_const_trait_method] + #[rustc_diagnostic_item = "iter_any"] fn any(&mut self, f: F) -> bool where Self: Sized, @@ -3607,6 +3630,7 @@ pub const trait Iterator { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] + #[rustc_diagnostic_item = "iter_cycle"] fn cycle(self) -> Cycle where Self: Sized + [const] Clone, @@ -3650,6 +3674,7 @@ pub const trait Iterator { /// ``` #[track_caller] #[unstable(feature = "iter_array_chunks", issue = "100450")] + #[rustc_diagnostic_item = "iter_array_chunks"] fn array_chunks<#[rustc_panics_when_zero] const N: usize>(self) -> ArrayChunks where Self: Sized, @@ -3686,6 +3711,7 @@ pub const trait Iterator { /// assert_eq!(sum, -0.0_f32); /// ``` #[stable(feature = "iter_arith", since = "1.11.0")] + #[rustc_diagnostic_item = "iter_sum"] fn sum(self) -> S where Self: Sized, @@ -3718,6 +3744,7 @@ pub const trait Iterator { /// assert_eq!(factorial(5), 120); /// ``` #[stable(feature = "iter_arith", since = "1.11.0")] + #[rustc_diagnostic_item = "iter_product"] fn product

(self) -> P where Self: Sized,