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 | |
| parent | 8d6ef2e1b198461fde48565c7efdf92a83a33abd (diff) | |
| download | rust-b496d7bec2a79feab092e6b4e251f7b0cee2a6a6.tar.gz rust-b496d7bec2a79feab092e6b4e251f7b0cee2a6a6.zip | |
libsyntax: Make float literals not use `@str`
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/middle/const_eval.rs | 6 | ||||
| -rw-r--r-- | src/librustc/middle/trans/consts.rs | 8 | ||||
| -rw-r--r-- | src/librustdoc/clean.rs | 4 | ||||
| -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 |
7 files changed, 24 insertions, 20 deletions
diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index 68ac2f11bda..51410068378 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -515,9 +515,9 @@ pub fn lit_to_const(lit: &Lit) -> const_val { LitInt(n, _) => const_int(n), LitUint(n, _) => const_uint(n), LitIntUnsuffixed(n) => const_int(n), - LitFloat(n, _) => const_float(from_str::<f64>(n).unwrap() as f64), - LitFloatUnsuffixed(n) => - const_float(from_str::<f64>(n).unwrap() as f64), + LitFloat(ref n, _) | LitFloatUnsuffixed(ref n) => { + const_float(from_str::<f64>(n.get()).unwrap() as f64) + } LitNil => const_int(0i64), LitBool(b) => const_bool(b) } diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index ddab6407f9d..8f69b3cc2f2 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -57,12 +57,14 @@ pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: ast::Lit) ty_to_str(cx.tcx, lit_int_ty))) } } - ast::LitFloat(fs, t) => C_floating(fs, Type::float_from_ty(t)), - ast::LitFloatUnsuffixed(fs) => { + ast::LitFloat(ref fs, t) => { + C_floating(fs.get(), Type::float_from_ty(t)) + } + ast::LitFloatUnsuffixed(ref fs) => { let lit_float_ty = ty::node_id_to_type(cx.tcx, e.id); match ty::get(lit_float_ty).sty { ty::ty_float(t) => { - C_floating(fs, Type::float_from_ty(t)) + C_floating(fs.get(), Type::float_from_ty(t)) } _ => { cx.sess.span_bug(lit.span, diff --git a/src/librustdoc/clean.rs b/src/librustdoc/clean.rs index 4a4e7741982..09c30ae096c 100644 --- a/src/librustdoc/clean.rs +++ b/src/librustdoc/clean.rs @@ -1152,8 +1152,8 @@ fn lit_to_str(lit: &ast::Lit) -> ~str { ast::LitInt(i, _t) => i.to_str(), ast::LitUint(u, _t) => u.to_str(), ast::LitIntUnsuffixed(i) => i.to_str(), - ast::LitFloat(f, _t) => f.to_str(), - ast::LitFloatUnsuffixed(f) => f.to_str(), + ast::LitFloat(ref f, _t) => f.get().to_str(), + ast::LitFloatUnsuffixed(ref f) => f.get().to_str(), ast::LitBool(b) => b.to_str(), ast::LitNil => ~"", } 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"); } |
