File tree Expand file tree Collapse file tree 3 files changed +7
-3
lines changed Expand file tree Collapse file tree 3 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,6 @@ refs/heads/tmp: e5d90d98402475b6e154ce216f9efcb80da1a747
29
29
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
30
30
refs/tags/homu-tmp: 1fe32ca12c51afcd761d9962f51a74ff0d07a591
31
31
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32
- refs/heads/stable: 0ec3183df8d0cdccc735fa6572d664b43dbb5e31
32
+ refs/heads/stable: c654a07d29c77b5a023cb9d36dfc61811349f64e
33
33
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
34
34
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
Original file line number Diff line number Diff line change @@ -203,10 +203,12 @@ impl LintPass for TypeLimits {
203
203
} else {
204
204
t
205
205
} ;
206
- let ( min , max) = int_ty_range ( int_type) ;
206
+ let ( _ , max) = int_ty_range ( int_type) ;
207
207
let negative = self . negated_expr_id == e. id ;
208
208
209
- if ( negative && min != i64:: MIN && v > -min as u64 ) ||
209
+ // Detect literal value out of range [min, max] inclusive
210
+ // avoiding use of -min to prevent overflow/panic
211
+ if ( negative && v > max as u64 + 1 ) ||
210
212
( !negative && v > max as u64 ) {
211
213
cx. span_lint ( OVERFLOWING_LITERALS , e. span ,
212
214
& * format ! ( "literal out of range for {:?}" , t) ) ;
Original file line number Diff line number Diff line change @@ -52,6 +52,8 @@ fn main() {
52
52
let x = 9223372036854775808_i64 ; //~ error: literal out of range for i64
53
53
let x = -9223372036854775808_i64 ; // should be OK
54
54
let x = 18446744073709551615_i64 ; //~ error: literal out of range for i64
55
+ let x: i64 = -9223372036854775809 ; //~ error: literal out of range for i64
56
+ let x = -9223372036854775809_i64 ; //~ error: literal out of range for i64
55
57
56
58
let x = -3.40282348e+38_f32 ; //~ error: literal out of range for f32
57
59
let x = 3.40282348e+38_f32 ; //~ error: literal out of range for f32
You can’t perform that action at this time.
0 commit comments