-
-
Notifications
You must be signed in to change notification settings - Fork 15.6k
fix silent overflows on Step impls
#36365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
f6c4fcf
19fd7fc
065bf4b
dc607de
a802ec1
dba6678
db1e85d
cb26d55
2b4c778
dd6e8c5
8f19d5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -915,6 +915,20 @@ fn test_range_step() { | |
| assert_eq!((isize::MIN..isize::MAX).step_by(1).size_hint(), (usize::MAX, Some(usize::MAX))); | ||
| } | ||
|
|
||
| #[test] | ||
| #[should_panic] | ||
| fn test_range_overflow_unsigned() { | ||
| let mut it = u8::MAX..; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Won't these tests fail if compiled in release mode?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh, that's a good point. Then these have to be run-fail with the overflow checking forced on (see
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #36372 for reference on making these tests. |
||
| it.next(); | ||
| } | ||
|
|
||
| #[test] | ||
| #[should_panic] | ||
| fn test_range_overflow_signed() { | ||
| let mut it = i8::MAX..; | ||
| it.next(); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_repeat() { | ||
| let mut it = repeat(42); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add::add(*self, 1)is what @alexcrichton meant. Similar situation on the rest.