diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2014-01-15 17:15:39 -0800 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2014-02-02 01:44:48 +1100 |
| commit | b496d7bec2a79feab092e6b4e251f7b0cee2a6a6 (patch) | |
| tree | 30bc26c3763372bb231dc24f7e34d666aaa9a6fb /src/libsyntax | |
| parent | 8d6ef2e1b198461fde48565c7efdf92a83a33abd (diff) | |
| download | rust-b496d7bec2a79feab092e6b4e251f7b0cee2a6a6.tar.gz rust-b496d7bec2a79feab092e6b4e251f7b0cee2a6a6.zip | |
libsyntax: Make float literals not use `@str`
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/concat.rs | 7 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 9 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 6 |
4 files changed, 14 insertions, 12 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 7416e213792..380641a8689 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -728,8 +728,8 @@ pub enum Lit_ { LitInt(i64, IntTy), LitUint(u64, UintTy), LitIntUnsuffixed(i64), - LitFloat(@str, FloatTy), - LitFloatUnsuffixed(@str), + LitFloat(InternedString, FloatTy), + LitFloatUnsuffixed(InternedString), LitNil, LitBool(bool), } diff --git a/src/libsyntax/ext/concat.rs b/src/libsyntax/ext/concat.rs index f570ca4c1bf..c13f9bf92af 100644 --- a/src/libsyntax/ext/concat.rs +++ b/src/libsyntax/ext/concat.rs @@ -29,12 +29,11 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt, match e.node { ast::ExprLit(lit) => { match lit.node { - ast::LitStr(ref s, _) => { + ast::LitStr(ref s, _) | + ast::LitFloat(ref s, _) | + ast::LitFloatUnsuffixed(ref s) => { accumulator.push_str(s.get()); } - ast::LitFloat(s, _) | ast::LitFloatUnsuffixed(s) => { - accumulator.push_str(s); - } ast::LitChar(c) => { accumulator.push_char(char::from_u32(c).unwrap()); } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 636dc504ff2..e86873d6418 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1405,9 +1405,12 @@ impl Parser { token::LIT_INT(i, it) => LitInt(i, it), token::LIT_UINT(u, ut) => LitUint(u, ut), token::LIT_INT_UNSUFFIXED(i) => LitIntUnsuffixed(i), - token::LIT_FLOAT(s, ft) => LitFloat(self.id_to_str(s), ft), - token::LIT_FLOAT_UNSUFFIXED(s) => - LitFloatUnsuffixed(self.id_to_str(s)), + token::LIT_FLOAT(s, ft) => { + LitFloat(self.id_to_interned_str(s), ft) + } + token::LIT_FLOAT_UNSUFFIXED(s) => { + LitFloatUnsuffixed(self.id_to_interned_str(s)) + } token::LIT_STR(s) => { LitStr(self.id_to_interned_str(s), ast::CookedStr) } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 8bf439818a2..d2a388cc14d 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -2202,10 +2202,10 @@ pub fn print_literal(s: &mut State, lit: &ast::Lit) { word(&mut s.s, (i as u64).to_str_radix(10u)); } } - ast::LitFloat(f, t) => { - word(&mut s.s, f.to_owned() + ast_util::float_ty_to_str(t)); + ast::LitFloat(ref f, t) => { + word(&mut s.s, f.get() + ast_util::float_ty_to_str(t)); } - ast::LitFloatUnsuffixed(f) => word(&mut s.s, f), + ast::LitFloatUnsuffixed(ref f) => word(&mut s.s, f.get()), ast::LitNil => word(&mut s.s, "()"), ast::LitBool(val) => { if val { word(&mut s.s, "true"); } else { word(&mut s.s, "false"); } |
