about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2015-02-17 09:45:58 -0500
committerNiko Matsakis <niko@alum.mit.edu>2015-02-18 09:07:56 -0500
commit700c518f2afd4b759fb54b867aee62660188d870 (patch)
tree4ffedf4e0812c9b47b7fdd376e4797b6cd20ffb9 /src/libsyntax
parentdfc5c0f1e8799f47f9033bdcc8a7cd8a217620a5 (diff)
downloadrust-700c518f2afd4b759fb54b867aee62660188d870.tar.gz
rust-700c518f2afd4b759fb54b867aee62660188d870.zip
Modify parser to require `isize`/`usize` suffixes.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/parse/mod.rs17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs
index 5f4cf9af5ee..e3bed496647 100644
--- a/src/libsyntax/parse/mod.rs
+++ b/src/libsyntax/parse/mod.rs
@@ -701,14 +701,12 @@ pub fn integer_lit(s: &str, suffix: Option<&str>, sd: &SpanHandler, sp: Span) ->
     if let Some(suf) = suffix {
         if suf.is_empty() { sd.span_bug(sp, "found empty literal suffix in Some")}
         ty = match suf {
-            "i"   => ast::SignedIntLit(ast::TyIs(true), ast::Plus),
-            "is"   => ast::SignedIntLit(ast::TyIs(false), ast::Plus),
+            "isize" => ast::SignedIntLit(ast::TyIs(false), ast::Plus),
             "i8"  => ast::SignedIntLit(ast::TyI8, ast::Plus),
             "i16" => ast::SignedIntLit(ast::TyI16, ast::Plus),
             "i32" => ast::SignedIntLit(ast::TyI32, ast::Plus),
             "i64" => ast::SignedIntLit(ast::TyI64, ast::Plus),
-            "u"   => ast::UnsignedIntLit(ast::TyUs(true)),
-            "us"   => ast::UnsignedIntLit(ast::TyUs(false)),
+            "usize" => ast::UnsignedIntLit(ast::TyUs(false)),
             "u8"  => ast::UnsignedIntLit(ast::TyU8),
             "u16" => ast::UnsignedIntLit(ast::TyU16),
             "u32" => ast::UnsignedIntLit(ast::TyU32),
@@ -722,6 +720,17 @@ pub fn integer_lit(s: &str, suffix: Option<&str>, sd: &SpanHandler, sp: Span) ->
                                               &suf[1..]));
                 } else {
                     sd.span_err(sp, &*format!("illegal suffix `{}` for numeric literal", suf));
+
+                    if suf == "i" || suf == "is" {
+                        sd.span_help(sp, "per RFC 544/573, the suffix \
+                                          for `isize` literals is now `isize`");
+                    } else if suf == "u" || suf == "us" {
+                        sd.span_help(sp, "per RFC 544/573, the suffix \
+                                          for `usize` literals is now `usize`");
+                    } else {
+                        sd.span_help(sp, "the suffix must be one of the integral types \
+                                          (`u32`, `isize`, etc)");
+                    }
                 }
 
                 ty