about summary refs log tree commit diff
path: root/src/libstd/num
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2014-11-14 09:18:10 -0800
committerJorge Aparicio <japaricious@gmail.com>2014-12-18 12:09:07 -0500
commitddb2466f6a1bb66f22824334022a4cee61c73bdc (patch)
tree9cb97d3e4c4521b56d0776e5f7bda81e62135be4 /src/libstd/num
parentc0b2885ee12b79c99ac8245edb6eebaaa8e7fef1 (diff)
downloadrust-ddb2466f6a1bb66f22824334022a4cee61c73bdc.tar.gz
rust-ddb2466f6a1bb66f22824334022a4cee61c73bdc.zip
librustc: Always parse `macro!()`/`macro![]` as expressions if not
followed by a semicolon.

This allows code like `vec![1i, 2, 3].len();` to work.

This breaks code that uses macros as statements without putting
semicolons after them, such as:

    fn main() {
        ...
        assert!(a == b)
        assert!(c == d)
        println(...);
    }

It also breaks code that uses macros as items without semicolons:

    local_data_key!(foo)

    fn main() {
        println("hello world")
    }

Add semicolons to fix this code. Those two examples can be fixed as
follows:

    fn main() {
        ...
        assert!(a == b);
        assert!(c == d);
        println(...);
    }

    local_data_key!(foo);

    fn main() {
        println("hello world")
    }

RFC #378.

Closes #18635.

[breaking-change]
Diffstat (limited to 'src/libstd/num')
-rw-r--r--src/libstd/num/f32.rs4
-rw-r--r--src/libstd/num/f64.rs4
-rw-r--r--src/libstd/num/float_macros.rs4
-rw-r--r--src/libstd/num/i16.rs2
-rw-r--r--src/libstd/num/i32.rs2
-rw-r--r--src/libstd/num/i64.rs2
-rw-r--r--src/libstd/num/i8.rs2
-rw-r--r--src/libstd/num/int.rs2
-rw-r--r--src/libstd/num/int_macros.rs4
-rw-r--r--src/libstd/num/mod.rs36
-rw-r--r--src/libstd/num/u16.rs2
-rw-r--r--src/libstd/num/u32.rs2
-rw-r--r--src/libstd/num/u64.rs2
-rw-r--r--src/libstd/num/u8.rs2
-rw-r--r--src/libstd/num/uint.rs2
-rw-r--r--src/libstd/num/uint_macros.rs4
16 files changed, 38 insertions, 38 deletions
diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs
index 9aac857bb65..60b17de1718 100644
--- a/src/libstd/num/f32.rs
+++ b/src/libstd/num/f32.rs
@@ -671,8 +671,8 @@ mod tests {
         let inf: f32 = Float::infinity();
         let neg_inf: f32 = Float::neg_infinity();
         let nan: f32 = Float::nan();
-        assert_eq!(match inf.frexp() { (x, _) => x }, inf)
-        assert_eq!(match neg_inf.frexp() { (x, _) => x }, neg_inf)
+        assert_eq!(match inf.frexp() { (x, _) => x }, inf);
+        assert_eq!(match neg_inf.frexp() { (x, _) => x }, neg_inf);
         assert!(match nan.frexp() { (x, _) => x.is_nan() })
     }
 
diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs
index 29ccfe512b9..4b31e33236d 100644
--- a/src/libstd/num/f64.rs
+++ b/src/libstd/num/f64.rs
@@ -673,8 +673,8 @@ mod tests {
         let inf: f64 = Float::infinity();
         let neg_inf: f64 = Float::neg_infinity();
         let nan: f64 = Float::nan();
-        assert_eq!(match inf.frexp() { (x, _) => x }, inf)
-        assert_eq!(match neg_inf.frexp() { (x, _) => x }, neg_inf)
+        assert_eq!(match inf.frexp() { (x, _) => x }, inf);
+        assert_eq!(match neg_inf.frexp() { (x, _) => x }, neg_inf);
         assert!(match nan.frexp() { (x, _) => x.is_nan() })
     }
 
diff --git a/src/libstd/num/float_macros.rs b/src/libstd/num/float_macros.rs
index 4b3727ead61..fd00f15662a 100644
--- a/src/libstd/num/float_macros.rs
+++ b/src/libstd/num/float_macros.rs
@@ -12,11 +12,11 @@
 #![macro_escape]
 #![doc(hidden)]
 
-macro_rules! assert_approx_eq(
+macro_rules! assert_approx_eq {
     ($a:expr, $b:expr) => ({
         use num::Float;
         let (a, b) = (&$a, &$b);
         assert!((*a - *b).abs() < 1.0e-6,
                 "{} is not approximately equal to {}", *a, *b);
     })
-)
+}
diff --git a/src/libstd/num/i16.rs b/src/libstd/num/i16.rs
index 333d1d7df0b..367147b84be 100644
--- a/src/libstd/num/i16.rs
+++ b/src/libstd/num/i16.rs
@@ -15,4 +15,4 @@
 
 pub use core::i16::{BITS, BYTES, MIN, MAX};
 
-int_module!(i16)
+int_module! { i16 }
diff --git a/src/libstd/num/i32.rs b/src/libstd/num/i32.rs
index 44b5397bf74..19fb40c9644 100644
--- a/src/libstd/num/i32.rs
+++ b/src/libstd/num/i32.rs
@@ -15,4 +15,4 @@
 
 pub use core::i32::{BITS, BYTES, MIN, MAX};
 
-int_module!(i32)
+int_module! { i32 }
diff --git a/src/libstd/num/i64.rs b/src/libstd/num/i64.rs
index de6fa0d3ef8..2379b03c64f 100644
--- a/src/libstd/num/i64.rs
+++ b/src/libstd/num/i64.rs
@@ -15,4 +15,4 @@
 
 pub use core::i64::{BITS, BYTES, MIN, MAX};
 
-int_module!(i64)
+int_module! { i64 }
diff --git a/src/libstd/num/i8.rs b/src/libstd/num/i8.rs
index 3b9fbcb768b..a09ceefc6a0 100644
--- a/src/libstd/num/i8.rs
+++ b/src/libstd/num/i8.rs
@@ -15,4 +15,4 @@
 
 pub use core::i8::{BITS, BYTES, MIN, MAX};
 
-int_module!(i8)
+int_module! { i8 }
diff --git a/src/libstd/num/int.rs b/src/libstd/num/int.rs
index 36c021efe0a..f59dab4b20b 100644
--- a/src/libstd/num/int.rs
+++ b/src/libstd/num/int.rs
@@ -15,4 +15,4 @@
 
 pub use core::int::{BITS, BYTES, MIN, MAX};
 
-int_module!(int)
+int_module! { int }
diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs
index 2f1162d28e5..fce150c4ad1 100644
--- a/src/libstd/num/int_macros.rs
+++ b/src/libstd/num/int_macros.rs
@@ -12,6 +12,6 @@
 #![macro_escape]
 #![doc(hidden)]
 
-macro_rules! int_module (($T:ty) => (
+macro_rules! int_module { ($T:ty) => (
 
-))
+) }
diff --git a/src/libstd/num/mod.rs b/src/libstd/num/mod.rs
index 9aaaceb87e6..a568aafe1ed 100644
--- a/src/libstd/num/mod.rs
+++ b/src/libstd/num/mod.rs
@@ -161,7 +161,7 @@ mod tests {
     use u64;
     use uint;
 
-    macro_rules! test_cast_20(
+    macro_rules! test_cast_20 {
         ($_20:expr) => ({
             let _20 = $_20;
 
@@ -204,7 +204,7 @@ mod tests {
             assert_eq!(_20, cast(20f32).unwrap());
             assert_eq!(_20, cast(20f64).unwrap());
         })
-    )
+    }
 
     #[test] fn test_u8_cast()    { test_cast_20!(20u8)  }
     #[test] fn test_u16_cast()   { test_cast_20!(20u16) }
@@ -664,7 +664,7 @@ mod tests {
         assert_eq!(third.checked_mul(4), None);
     }
 
-    macro_rules! test_next_power_of_two(
+    macro_rules! test_next_power_of_two {
         ($test_name:ident, $T:ident) => (
             fn $test_name() {
                 #![test]
@@ -676,15 +676,15 @@ mod tests {
                 }
             }
         )
-    )
+    }
 
-    test_next_power_of_two!(test_next_power_of_two_u8, u8)
-    test_next_power_of_two!(test_next_power_of_two_u16, u16)
-    test_next_power_of_two!(test_next_power_of_two_u32, u32)
-    test_next_power_of_two!(test_next_power_of_two_u64, u64)
-    test_next_power_of_two!(test_next_power_of_two_uint, uint)
+    test_next_power_of_two! { test_next_power_of_two_u8, u8 }
+    test_next_power_of_two! { test_next_power_of_two_u16, u16 }
+    test_next_power_of_two! { test_next_power_of_two_u32, u32 }
+    test_next_power_of_two! { test_next_power_of_two_u64, u64 }
+    test_next_power_of_two! { test_next_power_of_two_uint, uint }
 
-    macro_rules! test_checked_next_power_of_two(
+    macro_rules! test_checked_next_power_of_two {
         ($test_name:ident, $T:ident) => (
             fn $test_name() {
                 #![test]
@@ -699,13 +699,13 @@ mod tests {
                 assert_eq!($T::MAX.checked_next_power_of_two(), None);
             }
         )
-    )
+    }
 
-    test_checked_next_power_of_two!(test_checked_next_power_of_two_u8, u8)
-    test_checked_next_power_of_two!(test_checked_next_power_of_two_u16, u16)
-    test_checked_next_power_of_two!(test_checked_next_power_of_two_u32, u32)
-    test_checked_next_power_of_two!(test_checked_next_power_of_two_u64, u64)
-    test_checked_next_power_of_two!(test_checked_next_power_of_two_uint, uint)
+    test_checked_next_power_of_two! { test_checked_next_power_of_two_u8, u8 }
+    test_checked_next_power_of_two! { test_checked_next_power_of_two_u16, u16 }
+    test_checked_next_power_of_two! { test_checked_next_power_of_two_u32, u32 }
+    test_checked_next_power_of_two! { test_checked_next_power_of_two_u64, u64 }
+    test_checked_next_power_of_two! { test_checked_next_power_of_two_uint, uint }
 
     #[deriving(PartialEq, Show)]
     struct Value { x: int }
@@ -759,13 +759,13 @@ mod tests {
             let one: T = Int::one();
             range(0, exp).fold(one, |acc, _| acc * base)
         }
-        macro_rules! assert_pow(
+        macro_rules! assert_pow {
             (($num:expr, $exp:expr) => $expected:expr) => {{
                 let result = $num.pow($exp);
                 assert_eq!(result, $expected);
                 assert_eq!(result, naive_pow($num, $exp));
             }}
-        )
+        }
         assert_pow!((3i,     0 ) => 1);
         assert_pow!((5i,     1 ) => 5);
         assert_pow!((-4i,    2 ) => 16);
diff --git a/src/libstd/num/u16.rs b/src/libstd/num/u16.rs
index 6d9b177574a..46699b78599 100644
--- a/src/libstd/num/u16.rs
+++ b/src/libstd/num/u16.rs
@@ -17,4 +17,4 @@ pub use core::u16::{BITS, BYTES, MIN, MAX};
 
 use ops::FnOnce;
 
-uint_module!(u16)
+uint_module! { u16 }
diff --git a/src/libstd/num/u32.rs b/src/libstd/num/u32.rs
index 0d6d17fa007..45ee9251d2f 100644
--- a/src/libstd/num/u32.rs
+++ b/src/libstd/num/u32.rs
@@ -17,4 +17,4 @@ pub use core::u32::{BITS, BYTES, MIN, MAX};
 
 use ops::FnOnce;
 
-uint_module!(u32)
+uint_module! { u32 }
diff --git a/src/libstd/num/u64.rs b/src/libstd/num/u64.rs
index ebb5d2946c5..1d8ff77dac8 100644
--- a/src/libstd/num/u64.rs
+++ b/src/libstd/num/u64.rs
@@ -17,4 +17,4 @@ pub use core::u64::{BITS, BYTES, MIN, MAX};
 
 use ops::FnOnce;
 
-uint_module!(u64)
+uint_module! { u64 }
diff --git a/src/libstd/num/u8.rs b/src/libstd/num/u8.rs
index 59aea214aae..0663ace2e5b 100644
--- a/src/libstd/num/u8.rs
+++ b/src/libstd/num/u8.rs
@@ -17,4 +17,4 @@ pub use core::u8::{BITS, BYTES, MIN, MAX};
 
 use ops::FnOnce;
 
-uint_module!(u8)
+uint_module! { u8 }
diff --git a/src/libstd/num/uint.rs b/src/libstd/num/uint.rs
index 484d28dfed0..7f8edee571f 100644
--- a/src/libstd/num/uint.rs
+++ b/src/libstd/num/uint.rs
@@ -17,4 +17,4 @@ pub use core::uint::{BITS, BYTES, MIN, MAX};
 
 use ops::FnOnce;
 
-uint_module!(uint)
+uint_module! { uint }
diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs
index bd6f3d4bb28..c42b7eebfdd 100644
--- a/src/libstd/num/uint_macros.rs
+++ b/src/libstd/num/uint_macros.rs
@@ -13,7 +13,7 @@
 #![doc(hidden)]
 #![allow(unsigned_negation)]
 
-macro_rules! uint_module (($T:ty) => (
+macro_rules! uint_module { ($T:ty) => (
 
 // String conversion functions and impl num -> str
 
@@ -141,4 +141,4 @@ mod tests {
     }
 }
 
-))
+) }