diff options
| author | Eduard Burtescu <edy.burt@gmail.com> | 2016-05-26 19:02:26 +0300 |
|---|---|---|
| committer | Eduard Burtescu <edy.burt@gmail.com> | 2016-06-05 14:41:03 +0300 |
| commit | 702c47baae8e417d5ca377acb886893e902f2afa (patch) | |
| tree | 3c959c5283aea249f63f36b48f8a4f2fc6fcd761 /src/libcore/iter | |
| parent | 4adc967ed168d5469e39267d4ac81383434830b4 (diff) | |
core: mark relevant functions with #[rustc_inherit_overflow_checks].
Diffstat (limited to 'src/libcore/iter')
| -rw-r--r-- | src/libcore/iter/iterator.rs | 1 | ||||
| -rw-r--r-- | src/libcore/iter/mod.rs | 4 |
2 files changed, 5 insertions, 0 deletions
diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs index b80f77c0d25..71ca5ccdc8d 100644 --- a/src/libcore/iter/iterator.rs +++ b/src/libcore/iter/iterator.rs @@ -172,6 +172,7 @@ pub trait Iterator { /// assert_eq!(a.iter().count(), 5); /// ``` #[inline] + #[rustc_inherit_overflow_checks] #[stable(feature = "rust1", since = "1.0.0")] fn count(self) -> usize where Self: Sized { // Might overflow. diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index f964527b4b4..ae1e3116826 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -510,6 +510,7 @@ impl<A, B> Iterator for Chain<A, B> where } #[inline] + #[rustc_inherit_overflow_checks] fn count(self) -> usize { match self.state { ChainState::Both => self.a.count() + self.b.count(), @@ -932,6 +933,7 @@ impl<I> Iterator for Enumerate<I> where I: Iterator { /// /// Might panic if the index of the element overflows a `usize`. #[inline] + #[rustc_inherit_overflow_checks] fn next(&mut self) -> Option<(usize, <I as Iterator>::Item)> { self.iter.next().map(|a| { let ret = (self.count, a); @@ -947,6 +949,7 @@ impl<I> Iterator for Enumerate<I> where I: Iterator { } #[inline] + #[rustc_inherit_overflow_checks] fn nth(&mut self, n: usize) -> Option<(usize, I::Item)> { self.iter.nth(n).map(|a| { let i = self.count + n; @@ -1008,6 +1011,7 @@ impl<I: Iterator> Iterator for Peekable<I> { } #[inline] + #[rustc_inherit_overflow_checks] fn count(self) -> usize { (if self.peeked.is_some() { 1 } else { 0 }) + self.iter.count() } |
