rust/tests/ui/iterators/iter-sum-overflow-ndebug.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

15 lines
487 B
Rust
Raw Normal View History

// run-pass
// compile-flags: -C debug_assertions=no
fn main() {
2020-06-02 07:59:11 +00:00
assert_eq!([1i32, i32::MAX].iter().sum::<i32>(),
1i32.wrapping_add(i32::MAX));
assert_eq!([2i32, i32::MAX].iter().product::<i32>(),
2i32.wrapping_mul(i32::MAX));
2020-06-02 07:59:11 +00:00
assert_eq!([1i32, i32::MAX].iter().cloned().sum::<i32>(),
1i32.wrapping_add(i32::MAX));
assert_eq!([2i32, i32::MAX].iter().cloned().product::<i32>(),
2i32.wrapping_mul(i32::MAX));
}