about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-02-18 14:35:01 -0800
committerAlex Crichton <alex@alexcrichton.com>2015-02-18 14:35:01 -0800
commit5250a82f7917d6f9ec590e7e762bfd036e21ef74 (patch)
tree38ce94117b42eb159b630d0a97748b5f3056fbe5 /src/libsyntax
parent5a32b4a34fc6fbd78e293b16f7ba7d06caca7a48 (diff)
parent811c48fe22ffbe4ca45c32807c846d9a7c02a8f3 (diff)
downloadrust-5250a82f7917d6f9ec590e7e762bfd036e21ef74.tar.gz
rust-5250a82f7917d6f9ec590e7e762bfd036e21ef74.zip
rollup merge of #22497: nikomatsakis/suffixes
Conflicts:
	src/librustc_trans/trans/tvec.rs
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast_util.rs10
-rw-r--r--src/libsyntax/ext/tt/macro_parser.rs2
-rw-r--r--src/libsyntax/feature_gate.rs8
-rw-r--r--src/libsyntax/parse/mod.rs10
-rw-r--r--src/libsyntax/print/pp.rs2
5 files changed, 14 insertions, 18 deletions
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs
index b8d4c90f745..117507ad8b7 100644
--- a/src/libsyntax/ast_util.rs
+++ b/src/libsyntax/ast_util.rs
@@ -141,10 +141,7 @@ pub fn is_path(e: P<Expr>) -> bool {
 /// We want to avoid "45int" and "-3int" in favor of "45" and "-3"
 pub fn int_ty_to_string(t: IntTy, val: Option<i64>) -> String {
     let s = match t {
-        TyIs(true) if val.is_some() => "i",
-        TyIs(true) => "int",
-        TyIs(false) if val.is_some() => "is",
-        TyIs(false) => "isize",
+        TyIs(_) => "isize",
         TyI8 => "i8",
         TyI16 => "i16",
         TyI32 => "i32",
@@ -173,10 +170,7 @@ pub fn int_ty_max(t: IntTy) -> u64 {
 /// We want to avoid "42u" in favor of "42us". "42uint" is right out.
 pub fn uint_ty_to_string(t: UintTy, val: Option<u64>) -> String {
     let s = match t {
-        TyUs(true) if val.is_some() => "u",
-        TyUs(true) => "uint",
-        TyUs(false) if val.is_some() => "us",
-        TyUs(false) => "usize",
+        TyUs(_) => "usize",
         TyU8 => "u8",
         TyU16 => "u16",
         TyU32 => "u32",
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs
index a3224c25d09..f52d0a3be54 100644
--- a/src/libsyntax/ext/tt/macro_parser.rs
+++ b/src/libsyntax/ext/tt/macro_parser.rs
@@ -488,7 +488,7 @@ pub fn parse(sess: &ParseSess,
                     let match_cur = ei.match_cur;
                     (&mut ei.matches[match_cur]).push(Rc::new(MatchedNonterminal(
                         parse_nt(&mut rust_parser, span, &name_string))));
-                    ei.idx += 1us;
+                    ei.idx += 1;
                     ei.match_cur += 1;
                   }
                   _ => panic!()
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs
index 3bebba15a57..0110823ae98 100644
--- a/src/libsyntax/feature_gate.rs
+++ b/src/libsyntax/feature_gate.rs
@@ -588,11 +588,11 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
                 match lit.node {
                     ast::LitInt(_, ty) => {
                         let msg = if let ast::SignedIntLit(ast::TyIs(true), _) = ty {
-                            Some("the `i` suffix on integers is deprecated; use `is` \
-                                  or one of the fixed-sized suffixes")
+                            Some("the `i` and `is` suffixes on integers are deprecated; \
+                                  use `isize` or one of the fixed-sized suffixes")
                         } else if let ast::UnsignedIntLit(ast::TyUs(true)) = ty {
-                            Some("the `u` suffix on integers is deprecated; use `us` \
-                                 or one of the fixed-sized suffixes")
+                            Some("the `u` and `us` suffixes on integers are deprecated; \
+                                  use `usize` or one of the fixed-sized suffixes")
                         } else {
                             None
                         };
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs
index 5f4cf9af5ee..6ea23cf3f04 100644
--- a/src/libsyntax/parse/mod.rs
+++ b/src/libsyntax/parse/mod.rs
@@ -701,18 +701,18 @@ 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),
             "u64" => ast::UnsignedIntLit(ast::TyU64),
+            "i" | "is" => ast::SignedIntLit(ast::TyIs(true), ast::Plus),
+            "u" | "us" => ast::UnsignedIntLit(ast::TyUs(true)),
             _ => {
                 // i<digits> and u<digits> look like widths, so lets
                 // give an error message along those lines
@@ -722,6 +722,8 @@ 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));
+                    sd.span_help(sp, "the suffix must be one of the integral types \
+                                      (`u32`, `isize`, etc)");
                 }
 
                 ty
diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs
index 707b3c72ecd..6c6cf186e70 100644
--- a/src/libsyntax/print/pp.rs
+++ b/src/libsyntax/print/pp.rs
@@ -168,7 +168,7 @@ pub fn mk_printer(out: Box<old_io::Writer+'static>, linewidth: usize) -> Printer
     debug!("mk_printer {}", linewidth);
     let token: Vec<Token> = repeat(Token::Eof).take(n).collect();
     let size: Vec<isize> = repeat(0).take(n).collect();
-    let scan_stack: Vec<usize> = repeat(0us).take(n).collect();
+    let scan_stack: Vec<usize> = repeat(0).take(n).collect();
     Printer {
         out: out,
         buf_len: n,