diff options
| author | Paul Stansifer <paul.stansifer@gmail.com> | 2012-07-31 11:49:20 -0700 |
|---|---|---|
| committer | Paul Stansifer <paul.stansifer@gmail.com> | 2012-07-31 11:49:20 -0700 |
| commit | c2f49c46ae0b07aae8ae558d5a5e71ed85aeff23 (patch) | |
| tree | f06ba3cdb703fb037d02062f8e973cea7ba33694 /src/libsyntax/parse | |
| parent | fd52df1901e876a0705f16295f689cfc5727262d (diff) | |
| download | rust-c2f49c46ae0b07aae8ae558d5a5e71ed85aeff23.tar.gz rust-c2f49c46ae0b07aae8ae558d5a5e71ed85aeff23.zip | |
Avoid accidentally printing floating point numbers as `10.f`.
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/token.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index eecb6cf405f..372fff90c50 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -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 */ |
