@@ -173,18 +173,17 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
173
173
}
174
174
}
175
175
ty:: TyFloat ( t) => {
176
- let ( min, max) = float_ty_range ( t) ;
177
- let lit_val: f64 = match lit. node {
176
+ let is_infinite = match lit. node {
178
177
ast:: LitKind :: Float ( v, _) |
179
178
ast:: LitKind :: FloatUnsuffixed ( v) => {
180
- match v . as_str ( ) . parse ( ) {
181
- Ok ( f ) => f ,
182
- Err ( _ ) => return ,
179
+ match t {
180
+ ast :: FloatTy :: F32 => v . as_str ( ) . parse ( ) . map ( f32 :: is_infinite ) ,
181
+ ast :: FloatTy :: F64 => v . as_str ( ) . parse ( ) . map ( f64 :: is_infinite ) ,
183
182
}
184
183
}
185
184
_ => bug ! ( ) ,
186
185
} ;
187
- if lit_val < min || lit_val > max {
186
+ if is_infinite == Ok ( true ) {
188
187
cx. span_lint ( OVERFLOWING_LITERALS ,
189
188
e. span ,
190
189
& format ! ( "literal out of range for {:?}" , t) ) ;
@@ -242,13 +241,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
242
241
}
243
242
}
244
243
245
- fn float_ty_range ( float_ty : ast:: FloatTy ) -> ( f64 , f64 ) {
246
- match float_ty {
247
- ast:: FloatTy :: F32 => ( f32:: MIN as f64 , f32:: MAX as f64 ) ,
248
- ast:: FloatTy :: F64 => ( f64:: MIN , f64:: MAX ) ,
249
- }
250
- }
251
-
252
244
fn int_ty_bits ( int_ty : ast:: IntTy , target_int_ty : ast:: IntTy ) -> u64 {
253
245
match int_ty {
254
246
ast:: IntTy :: Is => int_ty_bits ( target_int_ty, target_int_ty) ,
0 commit comments