Skip to content

Commit

Permalink
Make tidy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSapin committed Jul 24, 2017
1 parent eed9884 commit 0a62269
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/libcore/iter/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ impl<A: Step> Iterator for ops::Range<A> {
// For integer types in `RangeInclusive<_>`
// this is the case for types *strictly narrower* than `usize`
// since e.g. `(0...u64::MAX).len()` would be `u64::MAX + 1`.
// * It hurts portability to have APIs (including `impl`s) that are only available on some platforms,
// * It hurts portability to have APIs (including `impl`s)
// that are only available on some platforms,
// so only `impl`s that are always valid should exist, regardless of the current target platform.
// (NOTE: https://github.com/rust-lang/rust/issues/41619 might change this.)
// * Support exists in-tree for MSP430: https://forge.rust-lang.org/platform-support.html#tier-3
Expand Down Expand Up @@ -496,7 +497,8 @@ impl<A: Step> DoubleEndedIterator for ops::RangeInclusive<A> {
last = self.end.clone();
// `start == end`, and `start - 1` underflowed.
// `end + 1` overflowing would imply a type with only one valid value?
self.start = self.start.forward(1).expect("overflow in RangeInclusive::next_back");
self.start =
self.start.forward(1).expect("overflow in RangeInclusive::next_back");
}
Some(last)
},
Expand Down
15 changes: 10 additions & 5 deletions src/libcore/tests/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1324,7 +1324,8 @@ fn test_steps_between() {
}
assert_eq!(Step::steps_between(&20_u128, &0x1_0000_0000_0000_0020_u128), None);
assert_eq!(Step::steps_between(&20_i128, &0x1_0000_0000_0000_0020_i128), None);
assert_eq!(Step::steps_between(&-0x1_0000_0000_0000_0000_i128, &0x1_0000_0000_0000_0000_i128), None);
assert_eq!(Step::steps_between(&-0x1_0000_0000_0000_0000_i128, &0x1_0000_0000_0000_0000_i128),
None);
}

#[test]
Expand All @@ -1346,9 +1347,11 @@ fn test_step_forward() {

assert_eq!((10_u128).forward(70_000_usize), Some(70_010_u128));
assert_eq!((10_i128).forward(70_030_usize), Some(70_020_i128));
assert_eq!((0xffff_ffff_ffff_ffff__ffff_ffff_ffff_ff00_u128).forward(0xff_usize), Some(u128::MAX));
assert_eq!((0xffff_ffff_ffff_ffff__ffff_ffff_ffff_ff00_u128).forward(0xff_usize),
Some(u128::MAX));
assert_eq!((0xffff_ffff_ffff_ffff__ffff_ffff_ffff_ff00_u128).forward(0x100_usize), None);
assert_eq!((0x7fff_ffff_ffff_ffff__ffff_ffff_ffff_ff00_i128).forward(0xff_usize), Some(i128::MAX));
assert_eq!((0x7fff_ffff_ffff_ffff__ffff_ffff_ffff_ff00_i128).forward(0xff_usize),
Some(i128::MAX));
assert_eq!((0x7fff_ffff_ffff_ffff__ffff_ffff_ffff_ff00_i128).forward(0x100_usize), None);
}

Expand All @@ -1373,6 +1376,8 @@ fn test_step_backward() {
assert_eq!((70_020_i128).backward(70_030_usize), Some(10_i128));
assert_eq!((10_u128).backward(7_usize), Some(3_u128));
assert_eq!((10_u128).backward(11_usize), None);
assert_eq!((-0x7fff_ffff_ffff_ffff__ffff_ffff_ffff_ff00_i128).backward(0xfe_usize), Some(i128::MIN));
assert_eq!((-0x7fff_ffff_ffff_ffff__ffff_ffff_ffff_ff00_i128).backward(0xff_usize), Some(i128::MIN));
assert_eq!((-0x7fff_ffff_ffff_ffff__ffff_ffff_ffff_ff00_i128).backward(0xfe_usize),
Some(i128::MIN));
assert_eq!((-0x7fff_ffff_ffff_ffff__ffff_ffff_ffff_ff00_i128).backward(0xff_usize),
Some(i128::MIN));
}

0 comments on commit 0a62269

Please sign in to comment.