about summary refs log tree commit diff
path: root/src/libcore/iter.rs
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/libcore/iter.rs
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/libcore/iter.rs')
-rw-r--r--src/libcore/iter.rs50
1 files changed, 25 insertions, 25 deletions
diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs
index 7e0380e8785..de5c0defb1a 100644
--- a/src/libcore/iter.rs
+++ b/src/libcore/iter.rs
@@ -875,18 +875,18 @@ macro_rules! impl_additive {
         }
     };
 }
-impl_additive!(i8,   0)
-impl_additive!(i16,  0)
-impl_additive!(i32,  0)
-impl_additive!(i64,  0)
-impl_additive!(int,  0)
-impl_additive!(u8,   0)
-impl_additive!(u16,  0)
-impl_additive!(u32,  0)
-impl_additive!(u64,  0)
-impl_additive!(uint, 0)
-impl_additive!(f32,  0.0)
-impl_additive!(f64,  0.0)
+impl_additive! { i8,   0 }
+impl_additive! { i16,  0 }
+impl_additive! { i32,  0 }
+impl_additive! { i64,  0 }
+impl_additive! { int,  0 }
+impl_additive! { u8,   0 }
+impl_additive! { u16,  0 }
+impl_additive! { u32,  0 }
+impl_additive! { u64,  0 }
+impl_additive! { uint, 0 }
+impl_additive! { f32,  0.0 }
+impl_additive! { f64,  0.0 }
 
 /// A trait for iterators over elements which can be multiplied together.
 #[experimental = "needs to be re-evaluated as part of numerics reform"]
@@ -919,18 +919,18 @@ macro_rules! impl_multiplicative {
         }
     };
 }
-impl_multiplicative!(i8,   1)
-impl_multiplicative!(i16,  1)
-impl_multiplicative!(i32,  1)
-impl_multiplicative!(i64,  1)
-impl_multiplicative!(int,  1)
-impl_multiplicative!(u8,   1)
-impl_multiplicative!(u16,  1)
-impl_multiplicative!(u32,  1)
-impl_multiplicative!(u64,  1)
-impl_multiplicative!(uint, 1)
-impl_multiplicative!(f32,  1.0)
-impl_multiplicative!(f64,  1.0)
+impl_multiplicative! { i8,   1 }
+impl_multiplicative! { i16,  1 }
+impl_multiplicative! { i32,  1 }
+impl_multiplicative! { i64,  1 }
+impl_multiplicative! { int,  1 }
+impl_multiplicative! { u8,   1 }
+impl_multiplicative! { u16,  1 }
+impl_multiplicative! { u32,  1 }
+impl_multiplicative! { u64,  1 }
+impl_multiplicative! { uint, 1 }
+impl_multiplicative! { f32,  1.0 }
+impl_multiplicative! { f64,  1.0 }
 
 /// A trait for iterators over elements which can be compared to one another.
 #[unstable = "recently renamed for new extension trait conventions"]
@@ -1084,7 +1084,7 @@ impl<T: Clone> MinMaxResult<T> {
     /// use std::iter::{NoElements, OneElement, MinMax, MinMaxResult};
     ///
     /// let r: MinMaxResult<int> = NoElements;
-    /// assert_eq!(r.into_option(), None)
+    /// assert_eq!(r.into_option(), None);
     ///
     /// let r = OneElement(1i);
     /// assert_eq!(r.into_option(), Some((1,1)));