Importing rustc-1.52.1
Change-Id: I3598a97301b4b2e71385e5a519f6d2ad946548b6
diff --git a/library/core/src/iter/range.rs b/library/core/src/iter/range.rs
index 9e7055a..cc80e06 100644
--- a/library/core/src/iter/range.rs
+++ b/library/core/src/iter/range.rs
@@ -1,7 +1,7 @@
use crate::char;
use crate::convert::TryFrom;
use crate::mem;
-use crate::ops::{self, Add, Sub, Try};
+use crate::ops::{self, Try};
use super::{FusedIterator, TrustedLen};
@@ -201,11 +201,12 @@
#[inline]
#[allow(arithmetic_overflow)]
+ #[rustc_inherit_overflow_checks]
fn forward(start: Self, n: usize) -> Self {
// In debug builds, trigger a panic on overflow.
// This should optimize completely out in release builds.
if Self::forward_checked(start, n).is_none() {
- let _ = Add::add(Self::MAX, 1);
+ let _ = Self::MAX + 1;
}
// Do wrapping math to allow e.g. `Step::forward(-128i8, 255)`.
start.wrapping_add(n as Self)
@@ -213,11 +214,12 @@
#[inline]
#[allow(arithmetic_overflow)]
+ #[rustc_inherit_overflow_checks]
fn backward(start: Self, n: usize) -> Self {
// In debug builds, trigger a panic on overflow.
// This should optimize completely out in release builds.
if Self::backward_checked(start, n).is_none() {
- let _ = Sub::sub(Self::MIN, 1);
+ let _ = Self::MIN - 1;
}
// Do wrapping math to allow e.g. `Step::backward(127i8, 255)`.
start.wrapping_sub(n as Self)