]> git.lizzy.rs Git - rust.git/blob - src/test/ui/iterators/iter-position-overflow-debug.rs
Auto merge of #95295 - CAD97:layout-isize, r=scottmcm
[rust.git] / src / test / ui / iterators / iter-position-overflow-debug.rs
1 // run-pass
2 // only-32bit too impatient for 2⁶⁴ items
3 // needs-unwind
4 // ignore-wasm32-bare compiled with panic=abort by default
5 // compile-flags: -C debug_assertions=yes -C opt-level=3
6
7 use std::panic;
8
9 fn main() {
10     let n = usize::MAX as u64;
11     assert_eq!((0..).by_ref().position(|i| i >= n), Some(usize::MAX));
12
13     let r = panic::catch_unwind(|| {
14         (0..).by_ref().position(|i| i > n)
15     });
16     assert!(r.is_err());
17
18     let r = panic::catch_unwind(|| {
19         (0..=n + 1).by_ref().position(|_| false)
20     });
21     assert!(r.is_err());
22 }