From 9ae9930e2fbdb2610843e6dc1ae0fb0759507218 Mon Sep 17 00:00:00 2001 From: Ulrik Sverdrup Date: Thu, 20 Oct 2016 14:07:06 +0200 Subject: [PATCH 1/9] Introduce iterator trait TrustedLen --- src/libcore/iter/mod.rs | 33 +++++++++++++++++++++++++++++++++ src/libcore/iter/range.rs | 5 ++++- src/libcore/iter/traits.rs | 7 +++++++ src/libcore/slice.rs | 6 ++++++ 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index 9eeb2608071c2..9fa950cd94d9e 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -328,6 +328,8 @@ pub use self::traits::{FromIterator, IntoIterator, DoubleEndedIterator, Extend}; pub use self::traits::{ExactSizeIterator, Sum, Product}; #[unstable(feature = "fused", issue = "35602")] pub use self::traits::FusedIterator; +#[unstable(feature = "trusted_len", issue = "0")] +pub use self::traits::TrustedLen; mod iterator; mod range; @@ -372,6 +374,10 @@ impl ExactSizeIterator for Rev impl FusedIterator for Rev where I: FusedIterator + DoubleEndedIterator {} +#[unstable(feature = "trusted_len", issue = "0")] +unsafe impl TrustedLen for Rev + where I: TrustedLen + DoubleEndedIterator {} + /// An iterator that clones the elements of an underlying iterator. /// /// This `struct` is created by the [`cloned()`] method on [`Iterator`]. See its @@ -432,6 +438,12 @@ unsafe impl<'a, I, T: 'a> TrustedRandomAccess for Cloned fn may_have_side_effect() -> bool { true } } +#[unstable(feature = "trusted_len", issue = "0")] +unsafe impl<'a, I, T: 'a> TrustedLen for Cloned + where I: TrustedLen, + T: Clone +{} + /// An iterator that repeats endlessly. /// /// This `struct` is created by the [`cycle()`] method on [`Iterator`]. See its @@ -642,6 +654,11 @@ impl FusedIterator for Chain B: FusedIterator, {} +#[unstable(feature = "trusted_len", issue = "0")] +unsafe impl TrustedLen for Chain + where A: TrustedLen, B: TrustedLen, +{} + /// An iterator that iterates two other iterators simultaneously. /// /// This `struct` is created by the [`zip()`] method on [`Iterator`]. See its @@ -859,6 +876,11 @@ unsafe impl TrustedRandomAccess for Zip impl FusedIterator for Zip where A: FusedIterator, B: FusedIterator, {} +#[unstable(feature = "trusted_len", issue = "0")] +unsafe impl TrustedLen for Zip + where A: TrustedLen, B: TrustedLen, +{} + /// An iterator that maps the values of `iter` with `f`. /// /// This `struct` is created by the [`map()`] method on [`Iterator`]. See its @@ -959,6 +981,11 @@ impl ExactSizeIterator for Map impl FusedIterator for Map where F: FnMut(I::Item) -> B {} +#[unstable(feature = "trusted_len", issue = "0")] +unsafe impl TrustedLen for Map + where I: TrustedLen, + F: FnMut(I::Item) -> B {} + #[doc(hidden)] unsafe impl TrustedRandomAccess for Map where I: TrustedRandomAccess, @@ -1195,6 +1222,12 @@ unsafe impl TrustedRandomAccess for Enumerate #[unstable(feature = "fused", issue = "35602")] impl FusedIterator for Enumerate where I: FusedIterator {} +#[unstable(feature = "trusted_len", issue = "0")] +unsafe impl TrustedLen for Enumerate + where I: TrustedLen, +{} + + /// An iterator with a `peek()` that returns an optional reference to the next /// element. /// diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs index eaa3d50c88ade..39da578d54913 100644 --- a/src/libcore/iter/range.rs +++ b/src/libcore/iter/range.rs @@ -12,7 +12,7 @@ use mem; use ops::{self, Add, Sub}; use usize; -use super::FusedIterator; +use super::{FusedIterator, TrustedLen}; /// Objects that can be stepped over in both directions. /// @@ -533,6 +533,9 @@ impl DoubleEndedIterator for ops::Range where impl FusedIterator for ops::Range where A: Step, for<'a> &'a A: Add<&'a A, Output = A> {} +#[unstable(feature = "trusted_len", issue = "0")] +unsafe impl TrustedLen for ops::Range { } + #[stable(feature = "rust1", since = "1.0.0")] impl Iterator for ops::RangeFrom where for<'a> &'a A: Add<&'a A, Output = A> diff --git a/src/libcore/iter/traits.rs b/src/libcore/iter/traits.rs index b55d6f96af9bf..da150f1d57a63 100644 --- a/src/libcore/iter/traits.rs +++ b/src/libcore/iter/traits.rs @@ -665,3 +665,10 @@ pub trait FusedIterator: Iterator {} #[unstable(feature = "fused", issue = "35602")] impl<'a, I: FusedIterator + ?Sized> FusedIterator for &'a mut I {} + +/// An iterator that has correct length +#[unstable(feature = "trusted_len", issue = "0")] +pub unsafe trait TrustedLen : Iterator {} + +#[unstable(feature = "trusted_len", issue = "0")] +unsafe impl<'a, I: TrustedLen + ?Sized> TrustedLen for &'a mut I {} diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 31be404ba905a..64d38c54c4767 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -988,6 +988,9 @@ impl<'a, T> ExactSizeIterator for Iter<'a, T> {} #[unstable(feature = "fused", issue = "35602")] impl<'a, T> FusedIterator for Iter<'a, T> {} +#[unstable(feature = "trusted_len", issue = "0")] +unsafe impl<'a, T> TrustedLen for Iter<'a, T> {} + #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T> Clone for Iter<'a, T> { fn clone(&self) -> Iter<'a, T> { Iter { ptr: self.ptr, end: self.end, _marker: self._marker } } @@ -1109,6 +1112,9 @@ impl<'a, T> ExactSizeIterator for IterMut<'a, T> {} #[unstable(feature = "fused", issue = "35602")] impl<'a, T> FusedIterator for IterMut<'a, T> {} +#[unstable(feature = "trusted_len", issue = "0")] +unsafe impl<'a, T> TrustedLen for IterMut<'a, T> {} + /// An internal abstraction over the splitting iterators, so that /// splitn, splitn_mut etc can be implemented once. #[doc(hidden)] From 49557112d64f5877093bfe43acaf5dc8d5b947a7 Mon Sep 17 00:00:00 2001 From: Ulrik Sverdrup Date: Thu, 20 Oct 2016 14:07:31 +0200 Subject: [PATCH 2/9] Use TrustedLen for Vec's FromIterator and Extend --- src/libcollections/lib.rs | 1 + src/libcollections/vec.rs | 46 ++++++++++++++++++++++++++++++--------- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index 990de541b6783..23d6edd6d794e 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -50,6 +50,7 @@ #![feature(specialization)] #![feature(staged_api)] #![feature(step_by)] +#![feature(trusted_len)] #![feature(unicode)] #![feature(unique)] #![cfg_attr(test, feature(rand, test))] diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index f3d78c20a4d6b..cd628a39af8b8 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -68,7 +68,7 @@ use core::cmp::Ordering; use core::fmt; use core::hash::{self, Hash}; use core::intrinsics::{arith_offset, assume}; -use core::iter::{FromIterator, FusedIterator}; +use core::iter::{FromIterator, FusedIterator, TrustedLen}; use core::mem; use core::ops::{Index, IndexMut}; use core::ops; @@ -1589,6 +1589,18 @@ impl SpecExtend> for Vec { } } +trait IsTrustedLen : Iterator { + fn trusted_len(&self) -> Option { None } +} +impl IsTrustedLen for I where I: Iterator { } + +impl IsTrustedLen for I where I: TrustedLen +{ + fn trusted_len(&self) -> Option { + self.size_hint().1 + } +} + impl Vec { fn extend_desugared>(&mut self, mut iterator: I) { // This function should be the moral equivalent of: @@ -1596,16 +1608,30 @@ impl Vec { // for item in iterator { // self.push(item); // } - while let Some(element) = iterator.next() { - let len = self.len(); - if len == self.capacity() { - let (lower, _) = iterator.size_hint(); - self.reserve(lower.saturating_add(1)); - } + if let Some(additional) = iterator.trusted_len() { + self.reserve(additional); unsafe { - ptr::write(self.get_unchecked_mut(len), element); - // NB can't overflow since we would have had to alloc the address space - self.set_len(len + 1); + let mut ptr = self.as_mut_ptr().offset(self.len() as isize); + let mut local_len = SetLenOnDrop::new(&mut self.len); + for element in iterator { + ptr::write(ptr, element); + ptr = ptr.offset(1); + // NB can't overflow since we would have had to alloc the address space + local_len.increment_len(1); + } + } + } else { + while let Some(element) = iterator.next() { + let len = self.len(); + if len == self.capacity() { + let (lower, _) = iterator.size_hint(); + self.reserve(lower.saturating_add(1)); + } + unsafe { + ptr::write(self.get_unchecked_mut(len), element); + // NB can't overflow since we would have had to alloc the address space + self.set_len(len + 1); + } } } } From 69b9400b796f545226415feae36b9ea4f8cc70c0 Mon Sep 17 00:00:00 2001 From: Ulrik Sverdrup Date: Thu, 20 Oct 2016 14:34:34 +0200 Subject: [PATCH 3/9] Implement TrustedLen for more iterators --- src/libcore/iter/range.rs | 26 +++++++++++++++++++++++--- src/libcore/option.rs | 11 ++++++++++- src/libcore/result.rs | 11 ++++++++++- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs index 39da578d54913..ab55ee9d9d7b0 100644 --- a/src/libcore/iter/range.rs +++ b/src/libcore/iter/range.rs @@ -480,6 +480,22 @@ macro_rules! range_incl_exact_iter_impl { )*) } +macro_rules! range_trusted_len_impl { + ($($t:ty)*) => ($( + #[unstable(feature = "trusted_len", issue = "0")] + unsafe impl TrustedLen for ops::Range<$t> { } + )*) +} + +macro_rules! range_incl_trusted_len_impl { + ($($t:ty)*) => ($( + #[unstable(feature = "inclusive_range", + reason = "recently added, follows RFC", + issue = "28237")] + unsafe impl TrustedLen for ops::RangeInclusive<$t> { } + )*) +} + #[stable(feature = "rust1", since = "1.0.0")] impl Iterator for ops::Range where for<'a> &'a A: Add<&'a A, Output = A> @@ -513,6 +529,13 @@ impl Iterator for ops::Range where range_exact_iter_impl!(usize u8 u16 u32 isize i8 i16 i32); range_incl_exact_iter_impl!(u8 u16 i8 i16); +// These macros generate `TrustedLen` impls. +// +// They need to guarantee that .size_hint() is either exact, or that +// the upper bound is None when it does not fit the type limits. +range_trusted_len_impl!(usize isize u8 i8 u16 i16 u32 i32 i64 u64); +range_incl_trusted_len_impl!(usize isize u8 i8 u16 i16 u32 i32 i64 u64); + #[stable(feature = "rust1", since = "1.0.0")] impl DoubleEndedIterator for ops::Range where for<'a> &'a A: Add<&'a A, Output = A>, @@ -533,9 +556,6 @@ impl DoubleEndedIterator for ops::Range where impl FusedIterator for ops::Range where A: Step, for<'a> &'a A: Add<&'a A, Output = A> {} -#[unstable(feature = "trusted_len", issue = "0")] -unsafe impl TrustedLen for ops::Range { } - #[stable(feature = "rust1", since = "1.0.0")] impl Iterator for ops::RangeFrom where for<'a> &'a A: Add<&'a A, Output = A> diff --git a/src/libcore/option.rs b/src/libcore/option.rs index cb18feff73422..28845ef5e8c11 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -145,7 +145,7 @@ #![stable(feature = "rust1", since = "1.0.0")] -use iter::{FromIterator, FusedIterator}; +use iter::{FromIterator, FusedIterator, TrustedLen}; use mem; // Note that this is not a lang item per se, but it has a hidden dependency on @@ -803,6 +803,7 @@ impl DoubleEndedIterator for Item { impl ExactSizeIterator for Item {} impl FusedIterator for Item {} +unsafe impl TrustedLen for Item {} /// An iterator over a reference of the contained item in an [`Option`]. /// @@ -833,6 +834,9 @@ impl<'a, A> ExactSizeIterator for Iter<'a, A> {} #[unstable(feature = "fused", issue = "35602")] impl<'a, A> FusedIterator for Iter<'a, A> {} +#[unstable(feature = "trusted_len", issue = "0")] +unsafe impl<'a, A> TrustedLen for Iter<'a, A> {} + #[stable(feature = "rust1", since = "1.0.0")] impl<'a, A> Clone for Iter<'a, A> { fn clone(&self) -> Iter<'a, A> { @@ -868,6 +872,8 @@ impl<'a, A> ExactSizeIterator for IterMut<'a, A> {} #[unstable(feature = "fused", issue = "35602")] impl<'a, A> FusedIterator for IterMut<'a, A> {} +#[unstable(feature = "trusted_len", issue = "0")] +unsafe impl<'a, A> TrustedLen for IterMut<'a, A> {} /// An iterator over the item contained inside an [`Option`]. /// @@ -898,6 +904,9 @@ impl ExactSizeIterator for IntoIter {} #[unstable(feature = "fused", issue = "35602")] impl FusedIterator for IntoIter {} +#[unstable(feature = "trusted_len", issue = "0")] +unsafe impl TrustedLen for IntoIter {} + ///////////////////////////////////////////////////////////////////////////// // FromIterator ///////////////////////////////////////////////////////////////////////////// diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 96845259299be..8985e7c8251e1 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -249,7 +249,7 @@ #![stable(feature = "rust1", since = "1.0.0")] use fmt; -use iter::{FromIterator, FusedIterator}; +use iter::{FromIterator, FusedIterator, TrustedLen}; /// `Result` is a type that represents either success (`Ok`) or failure (`Err`). /// @@ -886,6 +886,9 @@ impl<'a, T> ExactSizeIterator for Iter<'a, T> {} #[unstable(feature = "fused", issue = "35602")] impl<'a, T> FusedIterator for Iter<'a, T> {} +#[unstable(feature = "trusted_len", issue = "0")] +unsafe impl<'a, A> TrustedLen for Iter<'a, A> {} + #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T> Clone for Iter<'a, T> { fn clone(&self) -> Iter<'a, T> { Iter { inner: self.inner } } @@ -924,6 +927,9 @@ impl<'a, T> ExactSizeIterator for IterMut<'a, T> {} #[unstable(feature = "fused", issue = "35602")] impl<'a, T> FusedIterator for IterMut<'a, T> {} +#[unstable(feature = "trusted_len", issue = "0")] +unsafe impl<'a, A> TrustedLen for IterMut<'a, A> {} + /// An iterator over the value in a [`Ok`] variant of a [`Result`]. This struct is /// created by the [`into_iter`] method on [`Result`][`Result`] (provided by /// the [`IntoIterator`] trait). @@ -961,6 +967,9 @@ impl ExactSizeIterator for IntoIter {} #[unstable(feature = "fused", issue = "35602")] impl FusedIterator for IntoIter {} +#[unstable(feature = "trusted_len", issue = "0")] +unsafe impl TrustedLen for IntoIter {} + ///////////////////////////////////////////////////////////////////////////// // FromIterator ///////////////////////////////////////////////////////////////////////////// From a3cab90fda3b1ccfa4eb952dda49677c8d06c1ef Mon Sep 17 00:00:00 2001 From: Ulrik Sverdrup Date: Thu, 20 Oct 2016 14:44:31 +0200 Subject: [PATCH 4/9] =?UTF-8?q?Document=20TrustedLen=E2=80=99s=20contract?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libcore/iter/traits.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/libcore/iter/traits.rs b/src/libcore/iter/traits.rs index da150f1d57a63..a56a864f6180d 100644 --- a/src/libcore/iter/traits.rs +++ b/src/libcore/iter/traits.rs @@ -666,7 +666,19 @@ pub trait FusedIterator: Iterator {} #[unstable(feature = "fused", issue = "35602")] impl<'a, I: FusedIterator + ?Sized> FusedIterator for &'a mut I {} -/// An iterator that has correct length +/// An iterator that reports an accurate length using size_hint. +/// +/// The iterator reports a size hint where it is either exact +/// (lower bound is equal to upper bound), or the upper bound is `None`. +/// The upper bound must only be `None` if the actual iterator length is +/// larger than `usize::MAX`. +/// +/// The iterator must produce exactly the number of elements it reported. +/// +/// # Safety +/// +/// This trait must only be implemented when the contract is upheld. +/// Consumers of this trait must inspect `.size_hint()`’s upper bound. #[unstable(feature = "trusted_len", issue = "0")] pub unsafe trait TrustedLen : Iterator {} From 622f24f6d9cc952ccf2bb4dbe5bf65bb966194d3 Mon Sep 17 00:00:00 2001 From: Ulrik Sverdrup Date: Fri, 21 Oct 2016 13:51:31 +0200 Subject: [PATCH 5/9] vec: Use Vec::extend specializations in extend_from_slice and more The new Vec::extend covers the duties of .extend_from_slice() and some previous specializations. --- src/libcollections/vec.rs | 40 ++------------------------------------- 1 file changed, 2 insertions(+), 38 deletions(-) diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index cd628a39af8b8..50ad48567472c 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -1212,26 +1212,7 @@ impl Vec { /// ``` #[stable(feature = "vec_extend_from_slice", since = "1.6.0")] pub fn extend_from_slice(&mut self, other: &[T]) { - self.reserve(other.len()); - - // Unsafe code so this can be optimised to a memcpy (or something - // similarly fast) when T is Copy. LLVM is easily confused, so any - // extra operations during the loop can prevent this optimisation. - unsafe { - let len = self.len(); - let ptr = self.get_unchecked_mut(len) as *mut T; - // Use SetLenOnDrop to work around bug where compiler - // may not realize the store through `ptr` trough self.set_len() - // don't alias. - let mut local_len = SetLenOnDrop::new(&mut self.len); - - for i in 0..other.len() { - ptr::write(ptr.offset(i as isize), other.get_unchecked(i).clone()); - local_len.increment_len(1); - } - - // len set by scope guard - } + self.extend(other.iter().cloned()) } } @@ -1640,24 +1621,7 @@ impl Vec { #[stable(feature = "extend_ref", since = "1.2.0")] impl<'a, T: 'a + Copy> Extend<&'a T> for Vec { fn extend>(&mut self, iter: I) { - >::extend_vec(iter, self); - } -} - -// helper trait for specialization of Vec's Extend impl -trait SpecExtendVec { - fn extend_vec(self, vec: &mut Vec); -} - -impl <'a, T: 'a + Copy, I: IntoIterator> SpecExtendVec for I { - default fn extend_vec(self, vec: &mut Vec) { - vec.extend(self.into_iter().cloned()); - } -} - -impl<'a, T: Copy> SpecExtendVec for &'a [T] { - fn extend_vec(self, vec: &mut Vec) { - vec.extend_from_slice(self); + self.extend(iter.into_iter().map(|&x| x)) } } From ee84ec1fa183dbfa9ce2e26e6e8c12ded3ffddb6 Mon Sep 17 00:00:00 2001 From: Ulrik Sverdrup Date: Fri, 21 Oct 2016 19:18:08 +0200 Subject: [PATCH 6/9] vec: Add a debug assertion where TrustedLen is used --- src/libcollections/vec.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 50ad48567472c..8bed02c79e0a8 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -1578,7 +1578,13 @@ impl IsTrustedLen for I where I: Iterator { } impl IsTrustedLen for I where I: TrustedLen { fn trusted_len(&self) -> Option { - self.size_hint().1 + let (low, high) = self.size_hint(); + if let Some(high_value) = high { + debug_assert_eq!(low, high_value, + "TrustedLen iterator's size hint is not exact: {:?}", + (low, high)); + } + high } } From 2411be5cae59e2640a9795c7301f66fb47325cce Mon Sep 17 00:00:00 2001 From: Ulrik Sverdrup Date: Thu, 27 Oct 2016 00:18:13 +0200 Subject: [PATCH 7/9] impl TrustedLen for vec::IntoIter --- src/libcollections/vec.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 8bed02c79e0a8..c42926b09526c 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -1944,6 +1944,9 @@ impl ExactSizeIterator for IntoIter {} #[unstable(feature = "fused", issue = "35602")] impl FusedIterator for IntoIter {} +#[unstable(feature = "trusted_len", issue = "0")] +unsafe impl TrustedLen for IntoIter {} + #[stable(feature = "vec_into_iter_clone", since = "1.8.0")] impl Clone for IntoIter { fn clone(&self) -> IntoIter { From 5dc9db541e810839f4193fee43c62ebefbe6f260 Mon Sep 17 00:00:00 2001 From: Ulrik Sverdrup Date: Thu, 27 Oct 2016 00:40:09 +0200 Subject: [PATCH 8/9] vec: Remove the Vec specialization for .extend() This now produces as good code (with optimizations) using the TrustedLen codepath. --- src/libcollections/vec.rs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index c42926b09526c..16331960cc198 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -76,7 +76,6 @@ use core::ptr; use core::ptr::Shared; use core::slice; -use super::SpecExtend; use super::range::RangeArgument; /// A contiguous growable array type, written `Vec` but pronounced 'vector.' @@ -1554,22 +1553,10 @@ impl<'a, T> IntoIterator for &'a mut Vec { impl Extend for Vec { #[inline] fn extend>(&mut self, iter: I) { - >::spec_extend(self, iter); - } -} - -impl SpecExtend for Vec { - default fn spec_extend(&mut self, iter: I) { self.extend_desugared(iter.into_iter()) } } -impl SpecExtend> for Vec { - fn spec_extend(&mut self, ref mut other: Vec) { - self.append(other); - } -} - trait IsTrustedLen : Iterator { fn trusted_len(&self) -> Option { None } } From f0e6b90790da2203f04fa44ee3ed8f24dcc5f4dc Mon Sep 17 00:00:00 2001 From: Ulrik Sverdrup Date: Fri, 4 Nov 2016 00:24:59 +0100 Subject: [PATCH 9/9] Link the tracking issue for TrustedLen --- src/libcollections/vec.rs | 2 +- src/libcore/iter/mod.rs | 14 +++++++------- src/libcore/iter/range.rs | 2 +- src/libcore/iter/traits.rs | 4 ++-- src/libcore/option.rs | 6 +++--- src/libcore/result.rs | 6 +++--- src/libcore/slice.rs | 4 ++-- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 16331960cc198..053dcd8272e29 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -1931,7 +1931,7 @@ impl ExactSizeIterator for IntoIter {} #[unstable(feature = "fused", issue = "35602")] impl FusedIterator for IntoIter {} -#[unstable(feature = "trusted_len", issue = "0")] +#[unstable(feature = "trusted_len", issue = "37572")] unsafe impl TrustedLen for IntoIter {} #[stable(feature = "vec_into_iter_clone", since = "1.8.0")] diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index 9fa950cd94d9e..58d04218e072c 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -328,7 +328,7 @@ pub use self::traits::{FromIterator, IntoIterator, DoubleEndedIterator, Extend}; pub use self::traits::{ExactSizeIterator, Sum, Product}; #[unstable(feature = "fused", issue = "35602")] pub use self::traits::FusedIterator; -#[unstable(feature = "trusted_len", issue = "0")] +#[unstable(feature = "trusted_len", issue = "37572")] pub use self::traits::TrustedLen; mod iterator; @@ -374,7 +374,7 @@ impl ExactSizeIterator for Rev impl FusedIterator for Rev where I: FusedIterator + DoubleEndedIterator {} -#[unstable(feature = "trusted_len", issue = "0")] +#[unstable(feature = "trusted_len", issue = "37572")] unsafe impl TrustedLen for Rev where I: TrustedLen + DoubleEndedIterator {} @@ -438,7 +438,7 @@ unsafe impl<'a, I, T: 'a> TrustedRandomAccess for Cloned fn may_have_side_effect() -> bool { true } } -#[unstable(feature = "trusted_len", issue = "0")] +#[unstable(feature = "trusted_len", issue = "37572")] unsafe impl<'a, I, T: 'a> TrustedLen for Cloned where I: TrustedLen, T: Clone @@ -654,7 +654,7 @@ impl FusedIterator for Chain B: FusedIterator, {} -#[unstable(feature = "trusted_len", issue = "0")] +#[unstable(feature = "trusted_len", issue = "37572")] unsafe impl TrustedLen for Chain where A: TrustedLen, B: TrustedLen, {} @@ -876,7 +876,7 @@ unsafe impl TrustedRandomAccess for Zip impl FusedIterator for Zip where A: FusedIterator, B: FusedIterator, {} -#[unstable(feature = "trusted_len", issue = "0")] +#[unstable(feature = "trusted_len", issue = "37572")] unsafe impl TrustedLen for Zip where A: TrustedLen, B: TrustedLen, {} @@ -981,7 +981,7 @@ impl ExactSizeIterator for Map impl FusedIterator for Map where F: FnMut(I::Item) -> B {} -#[unstable(feature = "trusted_len", issue = "0")] +#[unstable(feature = "trusted_len", issue = "37572")] unsafe impl TrustedLen for Map where I: TrustedLen, F: FnMut(I::Item) -> B {} @@ -1222,7 +1222,7 @@ unsafe impl TrustedRandomAccess for Enumerate #[unstable(feature = "fused", issue = "35602")] impl FusedIterator for Enumerate where I: FusedIterator {} -#[unstable(feature = "trusted_len", issue = "0")] +#[unstable(feature = "trusted_len", issue = "37572")] unsafe impl TrustedLen for Enumerate where I: TrustedLen, {} diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs index ab55ee9d9d7b0..7c96be2facb48 100644 --- a/src/libcore/iter/range.rs +++ b/src/libcore/iter/range.rs @@ -482,7 +482,7 @@ macro_rules! range_incl_exact_iter_impl { macro_rules! range_trusted_len_impl { ($($t:ty)*) => ($( - #[unstable(feature = "trusted_len", issue = "0")] + #[unstable(feature = "trusted_len", issue = "37572")] unsafe impl TrustedLen for ops::Range<$t> { } )*) } diff --git a/src/libcore/iter/traits.rs b/src/libcore/iter/traits.rs index a56a864f6180d..2b0dd63a5714a 100644 --- a/src/libcore/iter/traits.rs +++ b/src/libcore/iter/traits.rs @@ -679,8 +679,8 @@ impl<'a, I: FusedIterator + ?Sized> FusedIterator for &'a mut I {} /// /// This trait must only be implemented when the contract is upheld. /// Consumers of this trait must inspect `.size_hint()`’s upper bound. -#[unstable(feature = "trusted_len", issue = "0")] +#[unstable(feature = "trusted_len", issue = "37572")] pub unsafe trait TrustedLen : Iterator {} -#[unstable(feature = "trusted_len", issue = "0")] +#[unstable(feature = "trusted_len", issue = "37572")] unsafe impl<'a, I: TrustedLen + ?Sized> TrustedLen for &'a mut I {} diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 28845ef5e8c11..063adc2ac9f8a 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -834,7 +834,7 @@ impl<'a, A> ExactSizeIterator for Iter<'a, A> {} #[unstable(feature = "fused", issue = "35602")] impl<'a, A> FusedIterator for Iter<'a, A> {} -#[unstable(feature = "trusted_len", issue = "0")] +#[unstable(feature = "trusted_len", issue = "37572")] unsafe impl<'a, A> TrustedLen for Iter<'a, A> {} #[stable(feature = "rust1", since = "1.0.0")] @@ -872,7 +872,7 @@ impl<'a, A> ExactSizeIterator for IterMut<'a, A> {} #[unstable(feature = "fused", issue = "35602")] impl<'a, A> FusedIterator for IterMut<'a, A> {} -#[unstable(feature = "trusted_len", issue = "0")] +#[unstable(feature = "trusted_len", issue = "37572")] unsafe impl<'a, A> TrustedLen for IterMut<'a, A> {} /// An iterator over the item contained inside an [`Option`]. @@ -904,7 +904,7 @@ impl ExactSizeIterator for IntoIter {} #[unstable(feature = "fused", issue = "35602")] impl FusedIterator for IntoIter {} -#[unstable(feature = "trusted_len", issue = "0")] +#[unstable(feature = "trusted_len", issue = "37572")] unsafe impl TrustedLen for IntoIter {} ///////////////////////////////////////////////////////////////////////////// diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 8985e7c8251e1..bae1eda7c4a9b 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -886,7 +886,7 @@ impl<'a, T> ExactSizeIterator for Iter<'a, T> {} #[unstable(feature = "fused", issue = "35602")] impl<'a, T> FusedIterator for Iter<'a, T> {} -#[unstable(feature = "trusted_len", issue = "0")] +#[unstable(feature = "trusted_len", issue = "37572")] unsafe impl<'a, A> TrustedLen for Iter<'a, A> {} #[stable(feature = "rust1", since = "1.0.0")] @@ -927,7 +927,7 @@ impl<'a, T> ExactSizeIterator for IterMut<'a, T> {} #[unstable(feature = "fused", issue = "35602")] impl<'a, T> FusedIterator for IterMut<'a, T> {} -#[unstable(feature = "trusted_len", issue = "0")] +#[unstable(feature = "trusted_len", issue = "37572")] unsafe impl<'a, A> TrustedLen for IterMut<'a, A> {} /// An iterator over the value in a [`Ok`] variant of a [`Result`]. This struct is @@ -967,7 +967,7 @@ impl ExactSizeIterator for IntoIter {} #[unstable(feature = "fused", issue = "35602")] impl FusedIterator for IntoIter {} -#[unstable(feature = "trusted_len", issue = "0")] +#[unstable(feature = "trusted_len", issue = "37572")] unsafe impl TrustedLen for IntoIter {} ///////////////////////////////////////////////////////////////////////////// diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 64d38c54c4767..871b63145ca6d 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -988,7 +988,7 @@ impl<'a, T> ExactSizeIterator for Iter<'a, T> {} #[unstable(feature = "fused", issue = "35602")] impl<'a, T> FusedIterator for Iter<'a, T> {} -#[unstable(feature = "trusted_len", issue = "0")] +#[unstable(feature = "trusted_len", issue = "37572")] unsafe impl<'a, T> TrustedLen for Iter<'a, T> {} #[stable(feature = "rust1", since = "1.0.0")] @@ -1112,7 +1112,7 @@ impl<'a, T> ExactSizeIterator for IterMut<'a, T> {} #[unstable(feature = "fused", issue = "35602")] impl<'a, T> FusedIterator for IterMut<'a, T> {} -#[unstable(feature = "trusted_len", issue = "0")] +#[unstable(feature = "trusted_len", issue = "37572")] unsafe impl<'a, T> TrustedLen for IterMut<'a, T> {} /// An internal abstraction over the splitting iterators, so that