@@ -431,9 +431,6 @@ set_option linter.unusedVariables false
431431
432432 fn expr ( & self , Expr { kind, ty, meta : _ } : & Expr ) -> DocBuilder < A > {
433433 match & * * kind {
434- ExprKind :: Literal ( int_lit @ Literal :: Int { .. } ) => {
435- docs ! [ int_lit, reflow!( " : " ) , ty] . parens ( ) . group ( )
436- }
437434 ExprKind :: If {
438435 condition,
439436 then,
@@ -478,6 +475,9 @@ set_option linter.unusedVariables false
478475 }
479476 }
480477 }
478+ ExprKind :: Literal ( numeric_lit @ ( Literal :: Float { .. } | Literal :: Int { .. } ) ) => {
479+ docs ! [ numeric_lit, reflow!( " : " ) , ty] . parens ( ) . group ( )
480+ }
481481 ExprKind :: Literal ( literal) => docs ! [ literal] ,
482482 ExprKind :: Array ( exprs) => docs ! [
483483 "#v[" ,
@@ -788,7 +788,11 @@ set_option linter.unusedVariables false
788788 negative,
789789 kind: _,
790790 } => format!( "{}{value}" , if * negative { "-" } else { "" } ) ,
791- Literal :: Float { .. } => emit_error!( issue 1715 , "Unsupported Float literal" ) ,
791+ Literal :: Float {
792+ value,
793+ negative,
794+ kind: _,
795+ } => format!( "{}{value}" , if * negative { "-" } else { "" } ) ,
792796 } ]
793797 }
794798
@@ -805,7 +809,7 @@ set_option linter.unusedVariables false
805809 match primitive_ty {
806810 PrimitiveTy :: Bool => docs ! [ "Bool" ] ,
807811 PrimitiveTy :: Int ( int_kind) => docs ! [ int_kind] ,
808- PrimitiveTy :: Float ( _ ) => emit_error ! ( issue 1715 , "Unsupported Float type" ) ,
812+ PrimitiveTy :: Float ( float_kind ) => docs ! [ float_kind ] ,
809813 PrimitiveTy :: Char => docs ! [ "Char" ] ,
810814 PrimitiveTy :: Str => docs ! [ "String" ] ,
811815 }
@@ -828,6 +832,14 @@ set_option linter.unusedVariables false
828832 } ]
829833 }
830834
835+ fn float_kind ( & self , float_kind : & FloatKind ) -> DocBuilder < A > {
836+ docs ! [ match float_kind {
837+ FloatKind :: F32 => "f32" ,
838+ FloatKind :: F64 => "f64" ,
839+ _ => emit_error!( issue 1787 , "The only supported float types are `f32` and `f64`." ) ,
840+ } ]
841+ }
842+
831843 fn generic_value ( & self , generic_value : & GenericValue ) -> DocBuilder < A > {
832844 match generic_value {
833845 GenericValue :: Ty ( ty) => docs ! [ ty] ,
@@ -1248,10 +1260,6 @@ set_option linter.unusedVariables false
12481260 unreachable_by_invariant ! ( Drop_references )
12491261 }
12501262
1251- fn float_kind ( & self , _float_kind : & FloatKind ) -> DocBuilder < A > {
1252- emit_error ! ( issue 1715 , "floats are unsupported" )
1253- }
1254-
12551263 fn dyn_trait_goal ( & self , _dyn_trait_goal : & DynTraitGoal ) -> DocBuilder < A > {
12561264 emit_error ! ( issue 1708 , "`dyn` traits are unsupported" )
12571265 }
0 commit comments