Closed
Description
The standard wishlist
fn main() {
let mut it = 255u8..;
println!("{:?}", it.next());
}
no longer panics, but AFAICT from the code this is not due to any deliberate change. The Iterator implementation is start.add_one()/swap, and add_one() is self + 1. This sounds like some overflow checks are being lost somehow.
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
TimNN commentedon Aug 29, 2016
related: #35589
durka commentedon Aug 31, 2016
This was indeed caused by MIR:
cc @eddyb
eddyb commentedon Aug 31, 2016
Missing
#[rustc_inherit_overflow_checks]
on theStep
methods that do arithmetic (add_one
andsub_one
), introduced in #34530.ashrwin commentedon Sep 1, 2016
Can I work on this ?
eddyb commentedon Sep 1, 2016
@ashrko619 Sure! The only change needed here is adding
#[rustc_inherit_overflow_checks]
before those 2 methods in all 3 implementations ofStep
and writing a test (not sure if it can be#[test]
- cc @rust-lang/libs).ashrwin commentedon Sep 1, 2016
@eddyb Thanks. About the test - why shouldn't it be
#[test]
?eddyb commentedon Sep 1, 2016
I don't know where we can put a
#[test]
for this, that's all. Also, it's dependent on having it in a separate crate, so#[test]
might invalidate that requirement (i.e. it would have a local copy ofStep
).However, it looks like
libcoretest
has the tests and it's a separate crate, so you should be able to add a test in that file.Step
impls #36365matthew-piziak commentedon Sep 9, 2016
@ashrko619 Any update on this issue? If not I might like to work on it.
ashrwin commentedon Sep 11, 2016
@matthew-piziak Feel free to work on it. I have been caught up at work this week :)
Auto merge of #36365 - matthew-piziak:silent-overflow, r=eddyb
4 remaining items