There is a weak convention in the ecosystem that `IterFoos` is an iterator yielding items of type `Foo` (e.g. `bitflags` `IterNames`, `hashbrown` `IterBuckets`), while `FooIter` is an iterator over `Foo` from an `.iter()` or `.into_iter()` method (e.g. `memchr` `OneIter`, `regex` `SetMatchesIter`). Rename `IterRange`, `IterRangeInclusive`, and `IterRangeFrom` to `RangeIter`, `RangeInclusiveIter`, and `RangeInclusiveIter` to match this. Tracking issue: RUST-125687 (`new_range_api`)
27 lines
1.1 KiB
Rust
27 lines
1.1 KiB
Rust
// With -Coverflow-checks=yes (enabled by default by -Cdebug-assertions=yes) we will produce a
|
|
// runtime check that panics after yielding the maximum value of the range bound type. That is
|
|
// tested for by tests/ui/iterators/rangefrom-overflow-overflow-checks.rs
|
|
//
|
|
// This test ensures that such a runtime check is *not* emitted when debug-assertions are
|
|
// enabled, but overflow-checks are explicitly disabled.
|
|
|
|
//@ revisions: DEBUG NOCHECKS
|
|
//@ compile-flags: -O -Cdebug-assertions=yes
|
|
//@ [NOCHECKS] compile-flags: -Coverflow-checks=no
|
|
|
|
#![crate_type = "lib"]
|
|
#![feature(new_range_api)]
|
|
use std::range::{RangeFrom, RangeFromIter};
|
|
|
|
// CHECK-LABEL: @iterrangefrom_remainder(
|
|
#[no_mangle]
|
|
pub unsafe fn iterrangefrom_remainder(x: RangeFromIter<i32>) -> RangeFrom<i32> {
|
|
// DEBUG: i32 noundef %x
|
|
// NOCHECKS: i32 noundef returned %x
|
|
// DEBUG: br i1
|
|
// DEBUG: call core::panicking::panic_const::panic_const_add_overflow
|
|
// DEBUG: unreachable
|
|
// NOCHECKS-NOT: unreachable
|
|
// NOCHECKS: ret i32 %x
|
|
x.remainder()
|
|
}
|