diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2014-11-14 09:18:10 -0800 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2014-12-18 12:09:07 -0500 |
| commit | ddb2466f6a1bb66f22824334022a4cee61c73bdc (patch) | |
| tree | 9cb97d3e4c4521b56d0776e5f7bda81e62135be4 /src/libserialize/serialize.rs | |
| parent | c0b2885ee12b79c99ac8245edb6eebaaa8e7fef1 (diff) | |
| download | rust-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/libserialize/serialize.rs')
| -rw-r--r-- | src/libserialize/serialize.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/libserialize/serialize.rs b/src/libserialize/serialize.rs index 0e0d3b4115b..00c5158309e 100644 --- a/src/libserialize/serialize.rs +++ b/src/libserialize/serialize.rs @@ -474,7 +474,9 @@ impl<E, D:Decoder<E>,T:Decodable<D, E>> Decodable<D, E> for Option<T> { } } -macro_rules! peel(($name:ident, $($other:ident,)*) => (tuple!($($other,)*))) +macro_rules! peel { + ($name:ident, $($other:ident,)*) => (tuple! { $($other,)* }) +} /// Evaluates to the number of identifiers passed to it, for example: `count_idents!(a, b, c) == 3 macro_rules! count_idents { @@ -482,7 +484,7 @@ macro_rules! count_idents { ($_i:ident $(, $rest:ident)*) => { 1 + count_idents!($($rest),*) } } -macro_rules! tuple ( +macro_rules! tuple { () => (); ( $($name:ident,)+ ) => ( impl<E, D:Decoder<E>,$($name:Decodable<D, E>),*> Decodable<D,E> for ($($name,)*) { @@ -511,9 +513,9 @@ macro_rules! tuple ( }) } } - peel!($($name,)*) + peel! { $($name,)* } ) -) +} tuple! { T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, } |
