]> git.proxmox.com Git - rustc.git/blame - src/test/ui/iterators/iter-position-overflow-debug.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / src / test / ui / iterators / iter-position-overflow-debug.rs
CommitLineData
e1599b0c
XL
1// run-pass
2// only-32bit too impatient for 2⁶⁴ items
a2a8927a 3// needs-unwind
e1599b0c
XL
4// compile-flags: -C debug_assertions=yes -C opt-level=3
5
6use std::panic;
e1599b0c
XL
7
8fn main() {
fc512014
XL
9 let n = usize::MAX as u64;
10 assert_eq!((0..).by_ref().position(|i| i >= n), Some(usize::MAX));
e1599b0c
XL
11
12 let r = panic::catch_unwind(|| {
13 (0..).by_ref().position(|i| i > n)
14 });
15 assert!(r.is_err());
16
17 let r = panic::catch_unwind(|| {
18 (0..=n + 1).by_ref().position(|_| false)
19 });
20 assert!(r.is_err());
21}