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]
This commit is contained in:
parent
c0b2885ee1
commit
ddb2466f6a
222 changed files with 2330 additions and 2039 deletions
|
@ -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, }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue