From c62f0977a0474c2d85b1823969e8ce8399d60953 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 30 Oct 2024 19:23:13 +0000 Subject: [PATCH] Remove do_not_const_check from Iterator methods --- library/core/src/iter/traits/iterator.rs | 76 ------------------------ 1 file changed, 76 deletions(-) diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index 302720eddef..ffaf1bc56e9 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -106,7 +106,6 @@ pub trait Iterator { /// ``` #[inline] #[unstable(feature = "iter_next_chunk", reason = "recently added", issue = "98326")] - #[rustc_do_not_const_check] fn next_chunk( &mut self, ) -> Result<[Self::Item; N], array::IntoIter> @@ -184,7 +183,6 @@ fn next_chunk( /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn size_hint(&self) -> (usize, Option) { (0, None) } @@ -220,7 +218,6 @@ fn size_hint(&self) -> (usize, Option) { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn count(self) -> usize where Self: Sized, @@ -249,7 +246,6 @@ fn count(self) -> usize /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn last(self) -> Option where Self: Sized, @@ -297,7 +293,6 @@ fn some(_: Option, x: T) -> Option { /// ``` #[inline] #[unstable(feature = "iter_advance_by", reason = "recently added", issue = "77404")] - #[rustc_do_not_const_check] fn advance_by(&mut self, n: usize) -> Result<(), NonZero> { for i in 0..n { if self.next().is_none() { @@ -349,7 +344,6 @@ fn advance_by(&mut self, n: usize) -> Result<(), NonZero> { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn nth(&mut self, n: usize) -> Option { self.advance_by(n).ok()?; self.next() @@ -400,7 +394,6 @@ fn nth(&mut self, n: usize) -> Option { /// ``` #[inline] #[stable(feature = "iterator_step_by", since = "1.28.0")] - #[rustc_do_not_const_check] fn step_by(self, step: usize) -> StepBy where Self: Sized, @@ -472,7 +465,6 @@ fn step_by(self, step: usize) -> StepBy /// [`OsStr`]: ../../std/ffi/struct.OsStr.html #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn chain(self, other: U) -> Chain where Self: Sized, @@ -591,7 +583,6 @@ fn chain(self, other: U) -> Chain /// [`zip`]: crate::iter::zip #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn zip(self, other: U) -> Zip where Self: Sized, @@ -634,7 +625,6 @@ fn zip(self, other: U) -> Zip /// [`intersperse_with`]: Iterator::intersperse_with #[inline] #[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")] - #[rustc_do_not_const_check] fn intersperse(self, separator: Self::Item) -> Intersperse where Self: Sized, @@ -693,7 +683,6 @@ fn intersperse(self, separator: Self::Item) -> Intersperse /// [`intersperse`]: Iterator::intersperse #[inline] #[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")] - #[rustc_do_not_const_check] fn intersperse_with(self, separator: G) -> IntersperseWith where Self: Sized, @@ -753,7 +742,6 @@ fn intersperse_with(self, separator: G) -> IntersperseWith #[rustc_diagnostic_item = "IteratorMap"] #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn map(self, f: F) -> Map where Self: Sized, @@ -799,7 +787,6 @@ fn map(self, f: F) -> Map /// ``` #[inline] #[stable(feature = "iterator_for_each", since = "1.21.0")] - #[rustc_do_not_const_check] fn for_each(self, f: F) where Self: Sized, @@ -875,7 +862,6 @@ fn call(mut f: impl FnMut(T)) -> impl FnMut((), T) { /// Note that `iter.filter(f).next()` is equivalent to `iter.find(f)`. #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] #[cfg_attr(not(test), rustc_diagnostic_item = "iter_filter")] fn filter

(self, predicate: P) -> Filter where @@ -922,7 +908,6 @@ fn filter

(self, predicate: P) -> Filter /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn filter_map(self, f: F) -> FilterMap where Self: Sized, @@ -969,7 +954,6 @@ fn filter_map(self, f: F) -> FilterMap /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] #[cfg_attr(not(test), rustc_diagnostic_item = "enumerate_method")] fn enumerate(self) -> Enumerate where @@ -1042,7 +1026,6 @@ fn enumerate(self) -> Enumerate /// [`next`]: Iterator::next #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn peekable(self) -> Peekable where Self: Sized, @@ -1108,7 +1091,6 @@ fn peekable(self) -> Peekable #[inline] #[doc(alias = "drop_while")] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn skip_while

(self, predicate: P) -> SkipWhile where Self: Sized, @@ -1190,7 +1172,6 @@ fn skip_while

(self, predicate: P) -> SkipWhile /// the iteration should stop, but wasn't placed back into the iterator. #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn take_while

(self, predicate: P) -> TakeWhile where Self: Sized, @@ -1279,7 +1260,6 @@ fn take_while

(self, predicate: P) -> TakeWhile /// [`fuse`]: Iterator::fuse #[inline] #[stable(feature = "iter_map_while", since = "1.57.0")] - #[rustc_do_not_const_check] fn map_while(self, predicate: P) -> MapWhile where Self: Sized, @@ -1309,7 +1289,6 @@ fn map_while(self, predicate: P) -> MapWhile /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn skip(self, n: usize) -> Skip where Self: Sized, @@ -1363,7 +1342,6 @@ fn skip(self, n: usize) -> Skip /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn take(self, n: usize) -> Take where Self: Sized, @@ -1411,7 +1389,6 @@ fn take(self, n: usize) -> Take /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn scan(self, initial_state: St, f: F) -> Scan where Self: Sized, @@ -1450,7 +1427,6 @@ fn scan(self, initial_state: St, f: F) -> Scan /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn flat_map(self, f: F) -> FlatMap where Self: Sized, @@ -1535,7 +1511,6 @@ fn flat_map(self, f: F) -> FlatMap /// [`flat_map()`]: Iterator::flat_map #[inline] #[stable(feature = "iterator_flatten", since = "1.29.0")] - #[rustc_do_not_const_check] fn flatten(self) -> Flatten where Self: Sized, @@ -1692,7 +1667,6 @@ fn flatten(self) -> Flatten /// ``` #[inline] #[unstable(feature = "iter_map_windows", reason = "recently added", issue = "87155")] - #[rustc_do_not_const_check] fn map_windows(self, f: F) -> MapWindows where Self: Sized, @@ -1759,7 +1733,6 @@ fn map_windows(self, f: F) -> MapWindows /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn fuse(self) -> Fuse where Self: Sized, @@ -1844,7 +1817,6 @@ fn fuse(self) -> Fuse /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn inspect(self, f: F) -> Inspect where Self: Sized, @@ -1873,7 +1845,6 @@ fn inspect(self, f: F) -> Inspect /// assert_eq!(of_rust, vec!["of", "Rust"]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn by_ref(&mut self) -> &mut Self where Self: Sized, @@ -1993,7 +1964,6 @@ fn by_ref(&mut self) -> &mut Self #[stable(feature = "rust1", since = "1.0.0")] #[must_use = "if you really need to exhaust the iterator, consider `.for_each(drop)` instead"] #[cfg_attr(not(test), rustc_diagnostic_item = "iterator_collect_fn")] - #[rustc_do_not_const_check] fn collect>(self) -> B where Self: Sized, @@ -2072,7 +2042,6 @@ fn collect>(self) -> B /// [`collect`]: Iterator::collect #[inline] #[unstable(feature = "iterator_try_collect", issue = "94047")] - #[rustc_do_not_const_check] fn try_collect(&mut self) -> ChangeOutputType where Self: Sized, @@ -2145,7 +2114,6 @@ fn try_collect(&mut self) -> ChangeOutputType /// ``` #[inline] #[unstable(feature = "iter_collect_into", reason = "new API", issue = "94780")] - #[rustc_do_not_const_check] fn collect_into>(self, collection: &mut E) -> &mut E where Self: Sized, @@ -2178,7 +2146,6 @@ fn collect_into>(self, collection: &mut E) -> &mut E /// assert_eq!(odd, vec![1, 3]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn partition(self, f: F) -> (B, B) where Self: Sized, @@ -2241,7 +2208,6 @@ fn extend<'a, T, B: Extend>( /// assert!(a[i..].iter().all(|&n| n % 2 == 1)); // odds /// ``` #[unstable(feature = "iter_partition_in_place", reason = "new API", issue = "62543")] - #[rustc_do_not_const_check] fn partition_in_place<'a, T: 'a, P>(mut self, ref mut predicate: P) -> usize where Self: Sized + DoubleEndedIterator, @@ -2299,7 +2265,6 @@ fn is_true(predicate: &mut impl FnMut(&T) -> bool) -> impl FnMut(&&mut T) -> /// assert!(!"IntoIterator".chars().is_partitioned(char::is_uppercase)); /// ``` #[unstable(feature = "iter_is_partitioned", reason = "new API", issue = "62544")] - #[rustc_do_not_const_check] fn is_partitioned

(mut self, mut predicate: P) -> bool where Self: Sized, @@ -2394,7 +2359,6 @@ fn is_partitioned

(mut self, mut predicate: P) -> bool /// ``` #[inline] #[stable(feature = "iterator_try_fold", since = "1.27.0")] - #[rustc_do_not_const_check] fn try_fold(&mut self, init: B, mut f: F) -> R where Self: Sized, @@ -2453,7 +2417,6 @@ fn try_fold(&mut self, init: B, mut f: F) -> R /// ``` #[inline] #[stable(feature = "iterator_try_fold", since = "1.27.0")] - #[rustc_do_not_const_check] fn try_for_each(&mut self, f: F) -> R where Self: Sized, @@ -2573,7 +2536,6 @@ fn call(mut f: impl FnMut(T) -> R) -> impl FnMut((), T) -> R { #[doc(alias = "inject", alias = "foldl")] #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn fold(mut self, init: B, mut f: F) -> B where Self: Sized, @@ -2611,7 +2573,6 @@ fn fold(mut self, init: B, mut f: F) -> B /// ``` #[inline] #[stable(feature = "iterator_fold_self", since = "1.51.0")] - #[rustc_do_not_const_check] fn reduce(mut self, f: F) -> Option where Self: Sized, @@ -2683,7 +2644,6 @@ fn reduce(mut self, f: F) -> Option /// ``` #[inline] #[unstable(feature = "iterator_try_reduce", reason = "new API", issue = "87053")] - #[rustc_do_not_const_check] fn try_reduce( &mut self, f: impl FnMut(Self::Item, Self::Item) -> R, @@ -2742,7 +2702,6 @@ fn try_reduce( /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn all(&mut self, f: F) -> bool where Self: Sized, @@ -2796,7 +2755,6 @@ fn check(mut f: impl FnMut(T) -> bool) -> impl FnMut((), T) -> ControlFlow<() /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn any(&mut self, f: F) -> bool where Self: Sized, @@ -2860,7 +2818,6 @@ fn check(mut f: impl FnMut(T) -> bool) -> impl FnMut((), T) -> ControlFlow<() /// Note that `iter.find(f)` is equivalent to `iter.filter(f).next()`. #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn find

(&mut self, predicate: P) -> Option where Self: Sized, @@ -2892,7 +2849,6 @@ fn check(mut predicate: impl FnMut(&T) -> bool) -> impl FnMut((), T) -> Contr /// ``` #[inline] #[stable(feature = "iterator_find_map", since = "1.30.0")] - #[rustc_do_not_const_check] fn find_map(&mut self, f: F) -> Option where Self: Sized, @@ -2951,7 +2907,6 @@ fn check(mut f: impl FnMut(T) -> Option) -> impl FnMut((), T) -> Contro /// ``` #[inline] #[unstable(feature = "try_find", reason = "new API", issue = "63178")] - #[rustc_do_not_const_check] fn try_find( &mut self, f: impl FnMut(&Self::Item) -> R, @@ -3035,7 +2990,6 @@ fn check( /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn position

(&mut self, predicate: P) -> Option where Self: Sized, @@ -3100,7 +3054,6 @@ fn check<'a, T>( /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn rposition

(&mut self, predicate: P) -> Option where P: FnMut(Self::Item) -> bool, @@ -3150,7 +3103,6 @@ fn check( /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn max(self) -> Option where Self: Sized, @@ -3187,7 +3139,6 @@ fn max(self) -> Option /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn min(self) -> Option where Self: Sized, @@ -3210,7 +3161,6 @@ fn min(self) -> Option /// ``` #[inline] #[stable(feature = "iter_cmp_by_key", since = "1.6.0")] - #[rustc_do_not_const_check] fn max_by_key(self, f: F) -> Option where Self: Sized, @@ -3244,7 +3194,6 @@ fn compare((x_p, _): &(B, T), (y_p, _): &(B, T)) -> Ordering { /// ``` #[inline] #[stable(feature = "iter_max_by", since = "1.15.0")] - #[rustc_do_not_const_check] fn max_by(self, compare: F) -> Option where Self: Sized, @@ -3272,7 +3221,6 @@ fn fold(mut compare: impl FnMut(&T, &T) -> Ordering) -> impl FnMut(T, T) -> T /// ``` #[inline] #[stable(feature = "iter_cmp_by_key", since = "1.6.0")] - #[rustc_do_not_const_check] fn min_by_key(self, f: F) -> Option where Self: Sized, @@ -3306,7 +3254,6 @@ fn compare((x_p, _): &(B, T), (y_p, _): &(B, T)) -> Ordering { /// ``` #[inline] #[stable(feature = "iter_min_by", since = "1.15.0")] - #[rustc_do_not_const_check] fn min_by(self, compare: F) -> Option where Self: Sized, @@ -3344,7 +3291,6 @@ fn fold(mut compare: impl FnMut(&T, &T) -> Ordering) -> impl FnMut(T, T) -> T #[inline] #[doc(alias = "reverse")] #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn rev(self) -> Rev where Self: Sized + DoubleEndedIterator, @@ -3381,7 +3327,6 @@ fn rev(self) -> Rev /// assert_eq!(z, [3, 6]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] fn unzip(self) -> (FromA, FromB) where FromA: Default + Extend, @@ -3412,7 +3357,6 @@ fn unzip(self) -> (FromA, FromB) /// assert_eq!(v_map, vec![1, 2, 3]); /// ``` #[stable(feature = "iter_copied", since = "1.36.0")] - #[rustc_do_not_const_check] #[cfg_attr(not(test), rustc_diagnostic_item = "iter_copied")] fn copied<'a, T: 'a>(self) -> Copied where @@ -3461,7 +3405,6 @@ fn copied<'a, T: 'a>(self) -> Copied /// assert_eq!(&[vec![23]], &faster[..]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_do_not_const_check] #[cfg_attr(not(test), rustc_diagnostic_item = "iter_cloned")] fn cloned<'a, T: 'a>(self) -> Cloned where @@ -3495,7 +3438,6 @@ fn cloned<'a, T: 'a>(self) -> Cloned /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - #[rustc_do_not_const_check] fn cycle(self) -> Cycle where Self: Sized + Clone, @@ -3539,7 +3481,6 @@ fn cycle(self) -> Cycle /// ``` #[track_caller] #[unstable(feature = "iter_array_chunks", reason = "recently added", issue = "100450")] - #[rustc_do_not_const_check] fn array_chunks(self) -> ArrayChunks where Self: Sized, @@ -3571,7 +3512,6 @@ fn array_chunks(self) -> ArrayChunks /// assert_eq!(sum, 6); /// ``` #[stable(feature = "iter_arith", since = "1.11.0")] - #[rustc_do_not_const_check] fn sum(self) -> S where Self: Sized, @@ -3604,7 +3544,6 @@ fn sum(self) -> S /// assert_eq!(factorial(5), 120); /// ``` #[stable(feature = "iter_arith", since = "1.11.0")] - #[rustc_do_not_const_check] fn product

(self) -> P where Self: Sized, @@ -3626,7 +3565,6 @@ fn product

(self) -> P /// assert_eq!([1, 2].iter().cmp([1].iter()), Ordering::Greater); /// ``` #[stable(feature = "iter_order", since = "1.5.0")] - #[rustc_do_not_const_check] fn cmp(self, other: I) -> Ordering where I: IntoIterator, @@ -3654,7 +3592,6 @@ fn cmp(self, other: I) -> Ordering /// assert_eq!(xs.iter().cmp_by(&ys, |&x, &y| (2 * x).cmp(&y)), Ordering::Greater); /// ``` #[unstable(feature = "iter_order_by", issue = "64295")] - #[rustc_do_not_const_check] fn cmp_by(self, other: I, cmp: F) -> Ordering where Self: Sized, @@ -3711,7 +3648,6 @@ fn compare(mut cmp: F) -> impl FnMut(X, Y) -> ControlFlow /// ``` /// #[stable(feature = "iter_order", since = "1.5.0")] - #[rustc_do_not_const_check] fn partial_cmp(self, other: I) -> Option where I: IntoIterator, @@ -3748,7 +3684,6 @@ fn partial_cmp(self, other: I) -> Option /// ); /// ``` #[unstable(feature = "iter_order_by", issue = "64295")] - #[rustc_do_not_const_check] fn partial_cmp_by(self, other: I, partial_cmp: F) -> Option where Self: Sized, @@ -3782,7 +3717,6 @@ fn compare(mut partial_cmp: F) -> impl FnMut(X, Y) -> ControlFlow(self, other: I) -> bool where I: IntoIterator, @@ -3806,7 +3740,6 @@ fn eq(self, other: I) -> bool /// assert!(xs.iter().eq_by(&ys, |&x, &y| x * x == y)); /// ``` #[unstable(feature = "iter_order_by", issue = "64295")] - #[rustc_do_not_const_check] fn eq_by(self, other: I, eq: F) -> bool where Self: Sized, @@ -3839,7 +3772,6 @@ fn compare(mut eq: F) -> impl FnMut(X, Y) -> ControlFlow<()> /// assert_eq!([1].iter().ne([1, 2].iter()), true); /// ``` #[stable(feature = "iter_order", since = "1.5.0")] - #[rustc_do_not_const_check] fn ne(self, other: I) -> bool where I: IntoIterator, @@ -3861,7 +3793,6 @@ fn ne(self, other: I) -> bool /// assert_eq!([1, 2].iter().lt([1, 2].iter()), false); /// ``` #[stable(feature = "iter_order", since = "1.5.0")] - #[rustc_do_not_const_check] fn lt(self, other: I) -> bool where I: IntoIterator, @@ -3883,7 +3814,6 @@ fn lt(self, other: I) -> bool /// assert_eq!([1, 2].iter().le([1, 2].iter()), true); /// ``` #[stable(feature = "iter_order", since = "1.5.0")] - #[rustc_do_not_const_check] fn le(self, other: I) -> bool where I: IntoIterator, @@ -3905,7 +3835,6 @@ fn le(self, other: I) -> bool /// assert_eq!([1, 2].iter().gt([1, 2].iter()), false); /// ``` #[stable(feature = "iter_order", since = "1.5.0")] - #[rustc_do_not_const_check] fn gt(self, other: I) -> bool where I: IntoIterator, @@ -3927,7 +3856,6 @@ fn gt(self, other: I) -> bool /// assert_eq!([1, 2].iter().ge([1, 2].iter()), true); /// ``` #[stable(feature = "iter_order", since = "1.5.0")] - #[rustc_do_not_const_check] fn ge(self, other: I) -> bool where I: IntoIterator, @@ -3957,7 +3885,6 @@ fn ge(self, other: I) -> bool /// ``` #[inline] #[stable(feature = "is_sorted", since = "1.82.0")] - #[rustc_do_not_const_check] fn is_sorted(self) -> bool where Self: Sized, @@ -3984,7 +3911,6 @@ fn is_sorted(self) -> bool /// assert!(std::iter::empty::().is_sorted_by(|a, b| true)); /// ``` #[stable(feature = "is_sorted", since = "1.82.0")] - #[rustc_do_not_const_check] fn is_sorted_by(mut self, compare: F) -> bool where Self: Sized, @@ -4029,7 +3955,6 @@ fn check<'a, T>( /// ``` #[inline] #[stable(feature = "is_sorted", since = "1.82.0")] - #[rustc_do_not_const_check] fn is_sorted_by_key(self, f: F) -> bool where Self: Sized, @@ -4045,7 +3970,6 @@ fn is_sorted_by_key(self, f: F) -> bool #[inline] #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] - #[rustc_do_not_const_check] unsafe fn __iterator_get_unchecked(&mut self, _idx: usize) -> Self::Item where Self: TrustedRandomAccessNoCoerce,