diff options
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/build.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/bytes.rs | 11 | ||||
| -rw-r--r-- | src/libsyntax/ext/concat.rs | 9 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/generic/mod.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/quote.rs | 9 |
5 files changed, 21 insertions, 16 deletions
diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 33daefa3e06..5acb84cf852 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -626,13 +626,13 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.expr(sp, ast::ExprLit(box(GC) respan(sp, lit))) } fn expr_uint(&self, span: Span, i: uint) -> Gc<ast::Expr> { - self.expr_lit(span, ast::LitUint(i as u64, ast::TyU)) + self.expr_lit(span, ast::LitInt(i as u64, ast::UnsignedIntLit(ast::TyU))) } fn expr_int(&self, sp: Span, i: int) -> Gc<ast::Expr> { - self.expr_lit(sp, ast::LitInt(i as i64, ast::TyI)) + self.expr_lit(sp, ast::LitInt(i as u64, ast::SignedIntLit(ast::TyI, ast::Sign::new(i)))) } fn expr_u8(&self, sp: Span, u: u8) -> Gc<ast::Expr> { - self.expr_lit(sp, ast::LitUint(u as u64, ast::TyU8)) + self.expr_lit(sp, ast::LitInt(u as u64, ast::UnsignedIntLit(ast::TyU8))) } fn expr_bool(&self, sp: Span, value: bool) -> Gc<ast::Expr> { self.expr_lit(sp, ast::LitBool(value)) diff --git a/src/libsyntax/ext/bytes.rs b/src/libsyntax/ext/bytes.rs index ce13fa2a7c6..6ea55096348 100644 --- a/src/libsyntax/ext/bytes.rs +++ b/src/libsyntax/ext/bytes.rs @@ -47,7 +47,7 @@ pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) } // u8 literal, push to vector expression - ast::LitUint(v, ast::TyU8) => { + ast::LitInt(v, ast::UnsignedIntLit(ast::TyU8)) => { if v > 0xFF { cx.span_err(expr.span, "too large u8 literal in bytes!"); err = true; @@ -57,13 +57,14 @@ pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) } // integer literal, push to vector expression - ast::LitIntUnsuffixed(v) => { + ast::LitInt(_, ast::UnsuffixedIntLit(ast::Minus)) => { + cx.span_err(expr.span, "negative integer literal in bytes!"); + err = true; + } + ast::LitInt(v, ast::UnsuffixedIntLit(ast::Plus)) => { if v > 0xFF { cx.span_err(expr.span, "too large integer literal in bytes!"); err = true; - } else if v < 0 { - cx.span_err(expr.span, "negative integer literal in bytes!"); - err = true; } else { bytes.push(cx.expr_u8(expr.span, v as u8)); } diff --git a/src/libsyntax/ext/concat.rs b/src/libsyntax/ext/concat.rs index 670e38327d6..dd1153bf666 100644 --- a/src/libsyntax/ext/concat.rs +++ b/src/libsyntax/ext/concat.rs @@ -37,11 +37,14 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt, ast::LitChar(c) => { accumulator.push_char(c); } - ast::LitInt(i, _) | ast::LitIntUnsuffixed(i) => { + ast::LitInt(i, ast::UnsignedIntLit(_)) | + ast::LitInt(i, ast::SignedIntLit(_, ast::Plus)) | + ast::LitInt(i, ast::UnsuffixedIntLit(ast::Plus)) => { accumulator.push_str(format!("{}", i).as_slice()); } - ast::LitUint(u, _) => { - accumulator.push_str(format!("{}", u).as_slice()); + ast::LitInt(i, ast::SignedIntLit(_, ast::Minus)) | + ast::LitInt(i, ast::UnsuffixedIntLit(ast::Minus)) => { + accumulator.push_str(format!("-{}", i).as_slice()); } ast::LitNil => {} ast::LitBool(b) => { diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs index 871f277a2da..9225e4414c4 100644 --- a/src/libsyntax/ext/deriving/generic/mod.rs +++ b/src/libsyntax/ext/deriving/generic/mod.rs @@ -996,7 +996,7 @@ impl<'a> MethodDef<'a> { let arms : Vec<ast::Arm> = variants.iter().enumerate() .map(|(index, &variant)| { let pat = variant_to_pat(cx, sp, &*variant); - let lit = ast::LitUint(index as u64, ast::TyU); + let lit = ast::LitInt(index as u64, ast::UnsignedIntLit(ast::TyU)); cx.arm(sp, vec![pat], cx.expr_lit(sp, lit)) }).collect(); diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index dcfb0198127..cc07b531258 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -189,16 +189,17 @@ pub mod rt { (signed, $t:ty, $tag:ident) => ( impl ToSource for $t { fn to_source(&self) -> String { - let lit = dummy_spanned(ast::LitInt(*self as i64, ast::$tag)); - pprust::lit_to_string(&lit) + let lit = ast::LitInt(*self as u64, ast::SignedIntLit(ast::$tag, + ast::Sign::new(*self))); + pprust::lit_to_string(&dummy_spanned(lit)) } } ); (unsigned, $t:ty, $tag:ident) => ( impl ToSource for $t { fn to_source(&self) -> String { - let lit = dummy_spanned(ast::LitUint(*self as u64, ast::$tag)); - pprust::lit_to_string(&lit) + let lit = ast::LitInt(*self as u64, ast::UnsignedIntLit(ast::$tag)); + pprust::lit_to_string(&dummy_spanned(lit)) } } ); |
