@@ -173,18 +173,17 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
173173 }
174174 }
175175 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 {
178177 ast:: LitKind :: Float ( v, _) |
179178 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 ) ,
183182 }
184183 }
185184 _ => bug ! ( ) ,
186185 } ;
187- if lit_val < min || lit_val > max {
186+ if is_infinite == Ok ( true ) {
188187 cx. span_lint ( OVERFLOWING_LITERALS ,
189188 e. span ,
190189 & format ! ( "literal out of range for {:?}" , t) ) ;
@@ -242,13 +241,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
242241 }
243242 }
244243
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-
252244 fn int_ty_bits ( int_ty : ast:: IntTy , target_int_ty : ast:: IntTy ) -> u64 {
253245 match int_ty {
254246 ast:: IntTy :: Is => int_ty_bits ( target_int_ty, target_int_ty) ,
0 commit comments