Closed
Description
If you compile this to optimized MIR:
// @compile-flags: -O -C debuginfo=0 --emit=mir -Z inline-mir-threshold=9999 -Z inline-mir-hint-threshold=9999
use std::ops::Range;
#[no_mangle]
pub fn demo(num: &mut Range<usize>) -> Option<usize> {
num.next()
}
https://rust.godbolt.org/z/zsh6b6Y8n
You'll see that it still contains a call to forward_unchecked
:
bb1: {
_3 = copy ((*_1).0: usize);
StorageLive(_4);
_4 = <usize as Step>::forward_unchecked(copy _3, const 1_usize) -> [return: bb2, unwind continue];
}
That's pretty unfortunate, because forward_unchecked(a, 1)
is just AddUnchecked(a, 1)
, a single MIR operator.