]> git.lizzy.rs Git - rust.git/commitdiff
Avoid accidentally printing floating point numbers as `10.f`.
authorPaul Stansifer <paul.stansifer@gmail.com>
Tue, 31 Jul 2012 18:49:20 +0000 (11:49 -0700)
committerPaul Stansifer <paul.stansifer@gmail.com>
Tue, 31 Jul 2012 18:49:20 +0000 (11:49 -0700)
src/libsyntax/parse/token.rs

index eecb6cf405f6533be3300deed840a3f4b375448a..372fff90c500b247095f1896ab1c6c1cc341f9f2 100644 (file)
@@ -165,7 +165,13 @@ fn to_str(in: interner<@~str>, t: token) -> ~str {
       LIT_INT_UNSUFFIXED(i) {
         int::to_str(i as int, 10u)
       }
-      LIT_FLOAT(s, t) { *in.get(s) + ast_util::float_ty_to_str(t) }
+      LIT_FLOAT(s, t) {
+        let mut body = *in.get(s);
+        if body.ends_with(".") {
+            body = body + "0";  // `10.f` is not a float literal
+        }
+        body + ast_util::float_ty_to_str(t)
+      }
       LIT_STR(s) { ~"\"" + str::escape_default( *in.get(s)) + ~"\"" }
 
       /* Name components */