mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-29 20:46:07 +03:00
79d765ed38
Use `overflow_checks` intrinsic so `IterRangeFrom` yields MAX before panicking in debug Based on rust-lang/rust#128666. For your convenience, here is the [diff from that PR](https://github.com/pitaj/rust/compare/intrinsic-overflow_checks...pitaj:rust:rangefrom-overflow_checks). When `overflow_checks` are enabled, the following code will output as shown ```rust for n in std::range::RangeFrom::from(253_u8..) { println!("{n}"); } // 253 // 254 // 255 // panic ``` Which is a change from the current behavior, where it will panic after printing 254. This behavior was [requested by the libs team](https://github.com/rust-lang/rust/issues/125687#issuecomment-2151118208) r? `@Mark-Simulacrum`