2019-07-08 19:10:58 +00:00
|
|
|
// run-pass
|
|
|
|
// only-32bit too impatient for 2⁶⁴ items
|
2021-12-03 15:32:51 +00:00
|
|
|
// needs-unwind
|
2019-08-13 00:29:34 +00:00
|
|
|
// compile-flags: -C debug_assertions=yes -C opt-level=3
|
2019-07-08 19:10:58 +00:00
|
|
|
|
|
|
|
use std::panic;
|
|
|
|
|
|
|
|
fn main() {
|
2020-10-24 23:21:40 +00:00
|
|
|
let n = usize::MAX as u64;
|
|
|
|
assert_eq!((0..).by_ref().position(|i| i >= n), Some(usize::MAX));
|
2019-07-08 19:10:58 +00:00
|
|
|
|
|
|
|
let r = panic::catch_unwind(|| {
|
|
|
|
(0..).by_ref().position(|i| i > n)
|
|
|
|
});
|
|
|
|
assert!(r.is_err());
|
|
|
|
|
|
|
|
let r = panic::catch_unwind(|| {
|
|
|
|
(0..=n + 1).by_ref().position(|_| false)
|
|
|
|
});
|
|
|
|
assert!(r.is_err());
|
|
|
|
}
|