about summary refs log tree commit diff
path: root/src/libsyntax/ext/build.rs
diff options
context:
space:
mode:
authorFalco Hirschenberger <falco.hirschenberger@gmail.com>2014-08-05 09:59:03 +0200
committerFalco Hirschenberger <falco.hirschenberger@gmail.com>2014-08-05 09:59:03 +0200
commit0dc215741b34236c310e409c437600ba0165c97c (patch)
treebfaee6d4c3d1b082fadf859cb106b5e99d458028 /src/libsyntax/ext/build.rs
parent795f6ae829ab1bfd72394a5da9096e2717ec0f62 (diff)
downloadrust-0dc215741b34236c310e409c437600ba0165c97c.tar.gz
rust-0dc215741b34236c310e409c437600ba0165c97c.zip
Fixes missing overflow lint for i64 #14269
The `type_overflow` lint, doesn't catch the overflow for `i64` because
the overflow happens earlier in the parse phase when the `u64` as biggest
possible int gets casted to `i64` , without checking the for overflows.
We can't lint in the parse phase, so a refactoring of the `LitInt` type
was necessary.

The types `LitInt`, `LitUint` and `LitIntUnsuffixed` where merged to one
type `LitInt` which stores it's value as `u64`. An additional parameter was
added which indicate the signedness of the type and the sign of the value.
Diffstat (limited to 'src/libsyntax/ext/build.rs')
-rw-r--r--src/libsyntax/ext/build.rs6
1 files changed, 3 insertions, 3 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))