File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -95,11 +95,13 @@ macro_rules! step_impl_unsigned {
95
95
}
96
96
97
97
#[ inline]
98
+ #[ rustc_inherit_overflow_checks]
98
99
fn add_one( & self ) -> Self {
99
100
* self + 1
100
101
}
101
102
102
103
#[ inline]
104
+ #[ rustc_inherit_overflow_checks]
103
105
fn sub_one( & self ) -> Self {
104
106
* self - 1
105
107
}
@@ -166,11 +168,13 @@ macro_rules! step_impl_signed {
166
168
}
167
169
168
170
#[ inline]
171
+ #[ rustc_inherit_overflow_checks]
169
172
fn add_one( & self ) -> Self {
170
173
* self + 1
171
174
}
172
175
173
176
#[ inline]
177
+ #[ rustc_inherit_overflow_checks]
174
178
fn sub_one( & self ) -> Self {
175
179
* self - 1
176
180
}
@@ -215,11 +219,13 @@ macro_rules! step_impl_no_between {
215
219
}
216
220
217
221
#[ inline]
222
+ #[ rustc_inherit_overflow_checks]
218
223
fn add_one( & self ) -> Self {
219
224
* self + 1
220
225
}
221
226
222
227
#[ inline]
228
+ #[ rustc_inherit_overflow_checks]
223
229
fn sub_one( & self ) -> Self {
224
230
* self - 1
225
231
}
Original file line number Diff line number Diff line change @@ -915,6 +915,20 @@ fn test_range_step() {
915
915
assert_eq ! ( ( isize :: MIN ..isize :: MAX ) . step_by( 1 ) . size_hint( ) , ( usize :: MAX , Some ( usize :: MAX ) ) ) ;
916
916
}
917
917
918
+ #[ test]
919
+ #[ should_panic]
920
+ fn test_range_overflow_unsigned ( ) {
921
+ let mut it = u8:: MAX ..;
922
+ it. next ( ) ;
923
+ }
924
+
925
+ #[ test]
926
+ #[ should_panic]
927
+ fn test_range_overflow_signed ( ) {
928
+ let mut it = i8:: MAX ..;
929
+ it. next ( ) ;
930
+ }
931
+
918
932
#[ test]
919
933
fn test_repeat ( ) {
920
934
let mut it = repeat ( 42 ) ;
You can’t perform that action at this time.
0 commit comments