File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
src/test/ui/proc-macro/auxiliary/api Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -1074,7 +1074,11 @@ impl Literal {
10741074 if !n. is_finite ( ) {
10751075 panic ! ( "Invalid float literal {}" , n) ;
10761076 }
1077- Literal ( bridge:: client:: Literal :: float ( & n. to_string ( ) ) )
1077+ let mut repr = n. to_string ( ) ;
1078+ if !repr. contains ( '.' ) {
1079+ repr. push_str ( ".0" ) ;
1080+ }
1081+ Literal ( bridge:: client:: Literal :: float ( & repr) )
10781082 }
10791083
10801084 /// Creates a new suffixed floating-point literal.
@@ -1115,7 +1119,11 @@ impl Literal {
11151119 if !n. is_finite ( ) {
11161120 panic ! ( "Invalid float literal {}" , n) ;
11171121 }
1118- Literal ( bridge:: client:: Literal :: float ( & n. to_string ( ) ) )
1122+ let mut repr = n. to_string ( ) ;
1123+ if !repr. contains ( '.' ) {
1124+ repr. push_str ( ".0" ) ;
1125+ }
1126+ Literal ( bridge:: client:: Literal :: float ( & repr) )
11191127 }
11201128
11211129 /// Creates a new suffixed floating-point literal.
Original file line number Diff line number Diff line change @@ -8,6 +8,10 @@ pub fn test() {
88fn test_display_literal ( ) {
99 assert_eq ! ( Literal :: isize_unsuffixed( -10 ) . to_string( ) , "-10" ) ;
1010 assert_eq ! ( Literal :: isize_suffixed( -10 ) . to_string( ) , "-10isize" ) ;
11+ assert_eq ! ( Literal :: f32_unsuffixed( -10.0 ) . to_string( ) , "-10.0" ) ;
12+ assert_eq ! ( Literal :: f32_suffixed( -10.0 ) . to_string( ) , "-10f32" ) ;
13+ assert_eq ! ( Literal :: f64_unsuffixed( -10.0 ) . to_string( ) , "-10.0" ) ;
14+ assert_eq ! ( Literal :: f64_suffixed( -10.0 ) . to_string( ) , "-10f64" ) ;
1115}
1216
1317fn test_parse_literal ( ) {
You can’t perform that action at this time.
0 commit comments