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 | |
| 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]
222 files changed, 2338 insertions, 2047 deletions
diff --git a/src/doc/guide-macros.md b/src/doc/guide-macros.md index a7f4d103aca..58af5917407 100644 --- a/src/doc/guide-macros.md +++ b/src/doc/guide-macros.md @@ -58,7 +58,7 @@ macro_rules! early_return( _ => {} } ); -) +); // ... early_return!(input_1 T::SpecialA); // ... @@ -179,8 +179,8 @@ macro_rules! early_return( )+ _ => {} } - ); -) + ) +); // ... early_return!(input_1, [T::SpecialA|T::SpecialC|T::SpecialD]); // ... @@ -275,17 +275,17 @@ macro_rules! biased_match ( _ => { $err } }; ) -) +); # enum T1 { Good1(T2, uint), Bad1} # struct T2 { body: T3 } # enum T3 { Good2(uint), Bad2} # fn f(x: T1) -> uint { biased_match!((x) ~ (T1::Good1(g1, val)) else { return 0 }; - binds g1, val ) + binds g1, val ); biased_match!((g1.body) ~ (T3::Good2(result) ) else { panic!("Didn't get good_2") }; - binds result ) + binds result ); // complicated stuff goes here return result + val; # } @@ -303,7 +303,7 @@ pattern we want is clear: ( $( ($e:expr) ~ ($p:pat) else $err:stmt ; )* binds $( $bind_res:ident ),* ) -# => (0)) +# => (0)); ~~~~ However, it's not possible to directly expand to nested match statements. But @@ -323,7 +323,7 @@ input patterns: # #![feature(macro_rules)] # macro_rules! b( ( binds $( $bind_res:ident ),* ) -# => (0)) +# => (0)); # fn main() {} ~~~~ @@ -337,7 +337,7 @@ input patterns: $( ($e_rest:expr) ~ ($p_rest:pat) else $err_rest:stmt ; )* binds $( $bind_res:ident ),* ) -# => (0)) +# => (0)); ~~~~ The resulting macro looks like this. Note that the separation into @@ -366,7 +366,7 @@ macro_rules! biased_match_rec ( ); // Produce the requested values ( binds $( $bind_res:ident ),* ) => ( ($( $bind_res ),*) ) -) +); // Wrap the whole thing in a `let`. macro_rules! biased_match ( @@ -388,7 +388,7 @@ macro_rules! biased_match ( binds $( $bind_res ),* ); ) -) +); # enum T1 { Good1(T2, uint), Bad1} @@ -398,7 +398,7 @@ macro_rules! biased_match ( biased_match!( (x) ~ (T1::Good1(g1, val)) else { return 0 }; (g1.body) ~ (T3::Good2(result) ) else { panic!("Didn't get Good2") }; - binds val, result ) + binds val, result ); // complicated stuff goes here return result + val; # } @@ -444,7 +444,7 @@ macro_rules! loop_x ( $e } ); -) +); fn main() { 'x: loop { @@ -482,7 +482,7 @@ An example: ```rust # #![feature(macro_rules)] -macro_rules! m1 (() => (())) +macro_rules! m1 (() => (())); // visible here: m1 @@ -490,14 +490,14 @@ mod foo { // visible here: m1 #[macro_export] - macro_rules! m2 (() => (())) + macro_rules! m2 (() => (())); // visible here: m1, m2 } // visible here: m1 -macro_rules! m3 (() => (())) +macro_rules! m3 (() => (())); // visible here: m1, m3 @@ -505,7 +505,7 @@ macro_rules! m3 (() => (())) mod bar { // visible here: m1, m3 - macro_rules! m4 (() => (())) + macro_rules! m4 (() => (())); // visible here: m1, m3, m4 } diff --git a/src/etc/regex-match-tests.py b/src/etc/regex-match-tests.py index 826af961fce..ea7f51c86f8 100755 --- a/src/etc/regex-match-tests.py +++ b/src/etc/regex-match-tests.py @@ -63,7 +63,7 @@ def read_tests(f): def test_tostr(t): lineno, pat, text, groups = t options = map(group_tostr, groups) - return 'mat!(match_%s, r"%s", r"%s", %s)' \ + return 'mat!{match_%s, r"%s", r"%s", %s}' \ % (lineno, pat, '' if text == "NULL" else text, ', '.join(options)) diff --git a/src/libcollections/bit.rs b/src/libcollections/bit.rs index df860d6000e..7f78d56607e 100644 --- a/src/libcollections/bit.rs +++ b/src/libcollections/bit.rs @@ -2083,7 +2083,7 @@ mod tests { let bools = vec![true, false, true, true]; let bitv: Bitv = bools.iter().map(|n| *n).collect(); - assert_eq!(bitv.iter().collect::<Vec<bool>>(), bools) + assert_eq!(bitv.iter().collect::<Vec<bool>>(), bools); let long = Vec::from_fn(10000, |i| i % 2 == 0); let bitv: Bitv = long.iter().map(|n| *n).collect(); @@ -2112,8 +2112,8 @@ mod tests { for &b in bools.iter() { for &l in lengths.iter() { let bitset = BitvSet::from_bitv(Bitv::with_capacity(l, b)); - assert_eq!(bitset.contains(&1u), b) - assert_eq!(bitset.contains(&(l-1u)), b) + assert_eq!(bitset.contains(&1u), b); + assert_eq!(bitset.contains(&(l-1u)), b); assert!(!bitset.contains(&l)) } } @@ -2321,12 +2321,12 @@ mod tests { assert!(!a.is_disjoint(&d)); assert!(!d.is_disjoint(&a)); - assert!(a.is_disjoint(&b)) - assert!(a.is_disjoint(&c)) - assert!(b.is_disjoint(&a)) - assert!(b.is_disjoint(&c)) - assert!(c.is_disjoint(&a)) - assert!(c.is_disjoint(&b)) + assert!(a.is_disjoint(&b)); + assert!(a.is_disjoint(&c)); + assert!(b.is_disjoint(&a)); + assert!(b.is_disjoint(&c)); + assert!(c.is_disjoint(&a)); + assert!(c.is_disjoint(&b)); } #[test] diff --git a/src/libcollections/enum_set.rs b/src/libcollections/enum_set.rs index 4df1be1bb35..49b66ce25f5 100644 --- a/src/libcollections/enum_set.rs +++ b/src/libcollections/enum_set.rs @@ -411,7 +411,7 @@ mod test { assert!(e1.is_subset(&e2)); assert!(e2.is_superset(&e1)); - assert!(!e3.is_superset(&e2)) + assert!(!e3.is_superset(&e2)); assert!(!e2.is_superset(&e3)) } @@ -438,23 +438,23 @@ mod test { let mut e1: EnumSet<Foo> = EnumSet::new(); let elems: ::vec::Vec<Foo> = e1.iter().collect(); - assert!(elems.is_empty()) + assert!(elems.is_empty()); e1.insert(A); let elems: ::vec::Vec<_> = e1.iter().collect(); - assert_eq!(vec![A], elems) + assert_eq!(vec![A], elems); e1.insert(C); let elems: ::vec::Vec<_> = e1.iter().collect(); - assert_eq!(vec![A,C], elems) + assert_eq!(vec![A,C], elems); e1.insert(C); let elems: ::vec::Vec<_> = e1.iter().collect(); - assert_eq!(vec![A,C], elems) + assert_eq!(vec![A,C], elems); e1.insert(B); let elems: ::vec::Vec<_> = e1.iter().collect(); - assert_eq!(vec![A,B,C], elems) + assert_eq!(vec![A,B,C], elems); } /////////////////////////////////////////////////////////////////////////// @@ -472,35 +472,35 @@ mod test { let e_union = e1 | e2; let elems: ::vec::Vec<_> = e_union.iter().collect(); - assert_eq!(vec![A,B,C], elems) + assert_eq!(vec![A,B,C], elems); let e_intersection = e1 & e2; let elems: ::vec::Vec<_> = e_intersection.iter().collect(); - assert_eq!(vec![C], elems) + assert_eq!(vec![C], elems); // Another way to express intersection let e_intersection = e1 - (e1 - e2); let elems: ::vec::Vec<_> = e_intersection.iter().collect(); - assert_eq!(vec![C], elems) + assert_eq!(vec![C], elems); let e_subtract = e1 - e2; let elems: ::vec::Vec<_> = e_subtract.iter().collect(); - assert_eq!(vec![A], elems) + assert_eq!(vec![A], elems); // Bitwise XOR of two sets, aka symmetric difference let e_symmetric_diff = e1 ^ e2; let elems: ::vec::Vec<_> = e_symmetric_diff.iter().collect(); - assert_eq!(vec![A,B], elems) + assert_eq!(vec![A,B], elems); // Another way to express symmetric difference let e_symmetric_diff = (e1 - e2) | (e2 - e1); let elems: ::vec::Vec<_> = e_symmetric_diff.iter().collect(); - assert_eq!(vec![A,B], elems) + assert_eq!(vec![A,B], elems); // Yet another way to express symmetric difference let e_symmetric_diff = (e1 | e2) - (e1 & e2); let elems: ::vec::Vec<_> = e_symmetric_diff.iter().collect(); - assert_eq!(vec![A,B], elems) + assert_eq!(vec![A,B], elems); } #[test] diff --git a/src/libcollections/macros.rs b/src/libcollections/macros.rs index ba8b3b8c7d3..ce4b1e46773 100644 --- a/src/libcollections/macros.rs +++ b/src/libcollections/macros.rs @@ -11,7 +11,7 @@ #![macro_escape] /// Creates a `std::vec::Vec` containing the arguments. -macro_rules! vec( +macro_rules! vec { ($($e:expr),*) => ({ // leading _ to allow empty construction without a warning. let mut _temp = ::vec::Vec::new(); @@ -19,4 +19,5 @@ macro_rules! vec( _temp }); ($($e:expr),+,) => (vec!($($e),+)) -) +} + diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index 1ec3f1033e1..bba00a80f68 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -2515,7 +2515,7 @@ mod tests { assert_eq!(format!("{}", x), x_str); assert_eq!(format!("{}", x.as_slice()), x_str); }) - ) + ); let empty: Vec<int> = vec![]; test_show_vec!(empty, "[]"); test_show_vec!(vec![1i], "[1]"); diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 19ca1c9fd2b..9ac5f04efe5 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -415,14 +415,14 @@ Section: Misc // Return the initial codepoint accumulator for the first byte. // The first byte is special, only want bottom 5 bits for width 2, 4 bits // for width 3, and 3 bits for width 4 -macro_rules! utf8_first_byte( +macro_rules! utf8_first_byte { ($byte:expr, $width:expr) => (($byte & (0x7F >> $width)) as u32) -) +} // return the value of $ch updated with continuation byte $byte -macro_rules! utf8_acc_cont_byte( +macro_rules! utf8_acc_cont_byte { ($ch:expr, $byte:expr) => (($ch << 6) | ($byte & 63u8) as u32) -) +} /* Section: MaybeOwned diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index ba89fc133c4..38ebd686ddb 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -167,7 +167,7 @@ impl String { subseqidx = i; res.as_mut_vec().push_all(REPLACEMENT); } - })) + })); if byte < 128u8 { // subseqidx handles this @@ -788,8 +788,8 @@ macro_rules! impl_eq { } } -impl_eq!(String, &'a str) -impl_eq!(CowString<'a>, String) +impl_eq! { String, &'a str } +impl_eq! { CowString<'a>, String } impl<'a, 'b> PartialEq<&'b str> for CowString<'a> { #[inline] diff --git a/src/libcollections/tree/map.rs b/src/libcollections/tree/map.rs index 2b14f9569b0..cc667285d29 100644 --- a/src/libcollections/tree/map.rs +++ b/src/libcollections/tree/map.rs @@ -900,7 +900,7 @@ macro_rules! define_iterator { ) => { // private methods on the forward iterator (item!() for the // addr_mut in the next_ return value) - item!(impl<'a, K, V> $name<'a, K, V> { + item! { impl<'a, K, V> $name<'a, K, V> { #[inline(always)] fn next_(&mut self, forward: bool) -> Option<(&'a K, &'a $($addr_mut)* V)> { while !self.stack.is_empty() || !self.node.is_null() { @@ -968,10 +968,10 @@ macro_rules! define_iterator { self.node = ptr::RawPtr::null(); } } - }) + } } // the forward Iterator impl. - item!(impl<'a, K, V> Iterator<(&'a K, &'a $($addr_mut)* V)> for $name<'a, K, V> { + item! { impl<'a, K, V> Iterator<(&'a K, &'a $($addr_mut)* V)> for $name<'a, K, V> { /// Advances the iterator to the next node (in order) and return a /// tuple with a reference to the key and value. If there are no /// more nodes, return `None`. @@ -983,10 +983,10 @@ macro_rules! define_iterator { fn size_hint(&self) -> (uint, Option<uint>) { (self.remaining_min, Some(self.remaining_max)) } - }) + } } // the reverse Iterator impl. - item!(impl<'a, K, V> Iterator<(&'a K, &'a $($addr_mut)* V)> for $rev_name<'a, K, V> { + item! { impl<'a, K, V> Iterator<(&'a K, &'a $($addr_mut)* V)> for $rev_name<'a, K, V> { fn next(&mut self) -> Option<(&'a K, &'a $($addr_mut)* V)> { self.iter.next_(false) } @@ -995,7 +995,7 @@ macro_rules! define_iterator { fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() } - }) + } } } } // end of define_iterator diff --git a/src/libcollections/trie/map.rs b/src/libcollections/trie/map.rs index 67c5407eb6e..9a9ac6a3c58 100644 --- a/src/libcollections/trie/map.rs +++ b/src/libcollections/trie/map.rs @@ -1141,7 +1141,7 @@ macro_rules! iterator_impl { } } - item!(impl<'a, T> Iterator<(uint, &'a $($mut_)* T)> for $name<'a, T> { + item! { impl<'a, T> Iterator<(uint, &'a $($mut_)* T)> for $name<'a, T> { // you might wonder why we're not even trying to act within the // rules, and are just manipulating raw pointers like there's no // such thing as invalid pointers and memory unsafety. The @@ -1213,7 +1213,7 @@ macro_rules! iterator_impl { fn size_hint(&self) -> (uint, Option<uint>) { (self.remaining_min, Some(self.remaining_max)) } - }) + } } } } diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 75a389a7c95..94e6103f05f 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -582,8 +582,8 @@ macro_rules! impl_eq { } } -impl_eq!(Vec<A>, &'b [B]) -impl_eq!(Vec<A>, &'b mut [B]) +impl_eq! { Vec<A>, &'b [B] } +impl_eq! { Vec<A>, &'b mut [B] } impl<'a, A, B> PartialEq<Vec<B>> for CowVec<'a, A> where A: PartialEq<B> + Clone { #[inline] @@ -617,8 +617,8 @@ macro_rules! impl_eq_for_cowvec { } } -impl_eq_for_cowvec!(&'b [B]) -impl_eq_for_cowvec!(&'b mut [B]) +impl_eq_for_cowvec! { &'b [B] } +impl_eq_for_cowvec! { &'b mut [B] } #[unstable = "waiting on PartialOrd stability"] impl<T: PartialOrd> PartialOrd for Vec<T> { @@ -2065,7 +2065,7 @@ mod tests { #[test] fn test_partitioned() { - assert_eq!(vec![].partitioned(|x: &int| *x < 3), (vec![], vec![])) + assert_eq!(vec![].partitioned(|x: &int| *x < 3), (vec![], vec![])); assert_eq!(vec![1i, 2, 3].partitioned(|x: &int| *x < 4), (vec![1, 2, 3], vec![])); assert_eq!(vec![1i, 2, 3].partitioned(|x: &int| *x < 2), (vec![1], vec![2, 3])); assert_eq!(vec![1i, 2, 3].partitioned(|x: &int| *x < 0), (vec![], vec![1, 2, 3])); diff --git a/src/libcollections/vec_map.rs b/src/libcollections/vec_map.rs index 9f1a0075352..8faa9c1c522 100644 --- a/src/libcollections/vec_map.rs +++ b/src/libcollections/vec_map.rs @@ -612,8 +612,8 @@ pub struct Entries<'a, V:'a> { iter: slice::Items<'a, Option<V>> } -iterator!(impl Entries -> (uint, &'a V), as_ref) -double_ended_iterator!(impl Entries -> (uint, &'a V), as_ref) +iterator! { impl Entries -> (uint, &'a V), as_ref } +double_ended_iterator! { impl Entries -> (uint, &'a V), as_ref } /// An iterator over the key-value pairs of a map, with the /// values being mutable. @@ -623,8 +623,8 @@ pub struct MutEntries<'a, V:'a> { iter: slice::MutItems<'a, Option<V>> } -iterator!(impl MutEntries -> (uint, &'a mut V), as_mut) -double_ended_iterator!(impl MutEntries -> (uint, &'a mut V), as_mut) +iterator! { impl MutEntries -> (uint, &'a mut V), as_mut } +double_ended_iterator! { impl MutEntries -> (uint, &'a mut V), as_mut } /// An iterator over the keys of a map. pub struct Keys<'a, V: 'a> { diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs index 9f928f57e9e..f6be422813a 100644 --- a/src/libcore/clone.rs +++ b/src/libcore/clone.rs @@ -46,7 +46,7 @@ impl<'a, Sized? T> Clone for &'a T { fn clone(&self) -> &'a T { *self } } -macro_rules! clone_impl( +macro_rules! clone_impl { ($t:ty) => { impl Clone for $t { /// Return a deep copy of the value. @@ -54,28 +54,28 @@ macro_rules! clone_impl( fn clone(&self) -> $t { *self } } } -) +} -clone_impl!(int) -clone_impl!(i8) -clone_impl!(i16) -clone_impl!(i32) -clone_impl!(i64) +clone_impl! { int } +clone_impl! { i8 } +clone_impl! { i16 } +clone_impl! { i32 } +clone_impl! { i64 } -clone_impl!(uint) -clone_impl!(u8) -clone_impl!(u16) -clone_impl!(u32) -clone_impl!(u64) +clone_impl! { uint } +clone_impl! { u8 } +clone_impl! { u16 } +clone_impl! { u32 } +clone_impl! { u64 } -clone_impl!(f32) -clone_impl!(f64) +clone_impl! { f32 } +clone_impl! { f64 } -clone_impl!(()) -clone_impl!(bool) -clone_impl!(char) +clone_impl! { () } +clone_impl! { bool } +clone_impl! { char } -macro_rules! extern_fn_clone( +macro_rules! extern_fn_clone { ($($A:ident),*) => ( #[experimental = "this may not be sufficient for fns with region parameters"] impl<$($A,)* ReturnType> Clone for extern "Rust" fn($($A),*) -> ReturnType { @@ -84,15 +84,15 @@ macro_rules! extern_fn_clone( fn clone(&self) -> extern "Rust" fn($($A),*) -> ReturnType { *self } } ) -) +} -extern_fn_clone!() -extern_fn_clone!(A) -extern_fn_clone!(A, B) -extern_fn_clone!(A, B, C) -extern_fn_clone!(A, B, C, D) -extern_fn_clone!(A, B, C, D, E) -extern_fn_clone!(A, B, C, D, E, F) -extern_fn_clone!(A, B, C, D, E, F, G) -extern_fn_clone!(A, B, C, D, E, F, G, H) +extern_fn_clone! {} +extern_fn_clone! { A } +extern_fn_clone! { A, B } +extern_fn_clone! { A, B, C } +extern_fn_clone! { A, B, C, D } +extern_fn_clone! { A, B, C, D, E } +extern_fn_clone! { A, B, C, D, E, F } +extern_fn_clone! { A, B, C, D, E, F, G } +extern_fn_clone! { A, B, C, D, E, F, G, H } diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 4235531c199..af82e6a00f3 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -296,7 +296,7 @@ mod impls { use option::Option; use option::Option::{Some, None}; - macro_rules! partial_eq_impl( + macro_rules! partial_eq_impl { ($($t:ty)*) => ($( #[unstable = "Trait is unstable."] impl PartialEq for $t { @@ -306,7 +306,7 @@ mod impls { fn ne(&self, other: &$t) -> bool { (*self) != (*other) } } )*) - ) + } #[unstable = "Trait is unstable."] impl PartialEq for () { @@ -316,18 +316,20 @@ mod impls { fn ne(&self, _other: &()) -> bool { false } } - partial_eq_impl!(bool char uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64) + partial_eq_impl! { + bool char uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 + } - macro_rules! eq_impl( + macro_rules! eq_impl { ($($t:ty)*) => ($( #[unstable = "Trait is unstable."] impl Eq for $t {} )*) - ) + } - eq_impl!(() bool char uint u8 u16 u32 u64 int i8 i16 i32 i64) + eq_impl! { () bool char uint u8 u16 u32 u64 int i8 i16 i32 i64 } - macro_rules! partial_ord_impl( + macro_rules! partial_ord_impl { ($($t:ty)*) => ($( #[unstable = "Trait is unstable."] impl PartialOrd for $t { @@ -350,7 +352,7 @@ mod impls { fn gt(&self, other: &$t) -> bool { (*self) > (*other) } } )*) - ) + } #[unstable = "Trait is unstable."] impl PartialOrd for () { @@ -368,9 +370,9 @@ mod impls { } } - partial_ord_impl!(char uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64) + partial_ord_impl! { char uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 } - macro_rules! ord_impl( + macro_rules! ord_impl { ($($t:ty)*) => ($( #[unstable = "Trait is unstable."] impl Ord for $t { @@ -382,7 +384,7 @@ mod impls { } } )*) - ) + } #[unstable = "Trait is unstable."] impl Ord for () { @@ -398,7 +400,7 @@ mod impls { } } - ord_impl!(char uint u8 u16 u32 u64 int i8 i16 i32 i64) + ord_impl! { char uint u8 u16 u32 u64 int i8 i16 i32 i64 } // & pointers diff --git a/src/libcore/default.rs b/src/libcore/default.rs index 10facfe4750..0632ffd9c69 100644 --- a/src/libcore/default.rs +++ b/src/libcore/default.rs @@ -135,7 +135,7 @@ pub trait Default { fn default() -> Self; } -macro_rules! default_impl( +macro_rules! default_impl { ($t:ty, $v:expr) => { #[stable] impl Default for $t { @@ -144,23 +144,24 @@ macro_rules! default_impl( fn default() -> $t { $v } } } -) +} + +default_impl! { (), () } +default_impl! { bool, false } +default_impl! { char, '\x00' } -default_impl!((), ()) -default_impl!(bool, false) -default_impl!(char, '\x00') +default_impl! { uint, 0u } +default_impl! { u8, 0u8 } +default_impl! { u16, 0u16 } +default_impl! { u32, 0u32 } +default_impl! { u64, 0u64 } -default_impl!(uint, 0u) -default_impl!(u8, 0u8) -default_impl!(u16, 0u16) -default_impl!(u32, 0u32) -default_impl!(u64, 0u64) +default_impl! { int, 0i } +default_impl! { i8, 0i8 } +default_impl! { i16, 0i16 } +default_impl! { i32, 0i32 } +default_impl! { i64, 0i64 } -default_impl!(int, 0i) -default_impl!(i8, 0i8) -default_impl!(i16, 0i16) -default_impl!(i32, 0i32) -default_impl!(i64, 0i64) +default_impl! { f32, 0.0f32 } +default_impl! { f64, 0.0f64 } -default_impl!(f32, 0.0f32) -default_impl!(f64, 0.0f64) diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 6ece6264d8c..cc940cd9e20 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -639,7 +639,7 @@ impl<'a, T> Pointer for &'a mut T { } } -macro_rules! floating(($ty:ident) => { +macro_rules! floating { ($ty:ident) => { impl Show for $ty { fn fmt(&self, fmt: &mut Formatter) -> Result { use num::Float; @@ -702,9 +702,9 @@ macro_rules! floating(($ty:ident) => { }) } } -}) -floating!(f32) -floating!(f64) +} } +floating! { f32 } +floating! { f64 } // Implementation of Show for various core types @@ -716,9 +716,11 @@ impl<T> Show for *mut T { fn fmt(&self, f: &mut Formatter) -> Result { Pointer::fmt(self, f) } } -macro_rules! peel(($name:ident, $($other:ident,)*) => (tuple!($($other,)*))) +macro_rules! peel { + ($name:ident, $($other:ident,)*) => (tuple! { $($other,)* }) +} -macro_rules! tuple ( +macro_rules! tuple { () => (); ( $($name:ident,)+ ) => ( impl<$($name:Show),*> Show for ($($name,)*) { @@ -740,9 +742,9 @@ macro_rules! tuple ( write!(f, ")") } } - peel!($($name,)*) + peel! { $($name,)* } ) -) +} tuple! { T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, } diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index 9cfa7bec22f..13cfcacf8da 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -100,13 +100,13 @@ macro_rules! radix { } } -radix!(Binary, 2, "0b", x @ 0 ... 2 => b'0' + x) -radix!(Octal, 8, "0o", x @ 0 ... 7 => b'0' + x) -radix!(Decimal, 10, "", x @ 0 ... 9 => b'0' + x) -radix!(LowerHex, 16, "0x", x @ 0 ... 9 => b'0' + x, - x @ 10 ... 15 => b'a' + (x - 10)) -radix!(UpperHex, 16, "0x", x @ 0 ... 9 => b'0' + x, - x @ 10 ... 15 => b'A' + (x - 10)) +radix! { Binary, 2, "0b", x @ 0 ... 2 => b'0' + x } +radix! { Octal, 8, "0o", x @ 0 ... 7 => b'0' + x } +radix! { Decimal, 10, "", x @ 0 ... 9 => b'0' + x } +radix! { LowerHex, 16, "0x", x @ 0 ... 9 => b'0' + x, + x @ 10 ... 15 => b'a' + (x - 10) } +radix! { UpperHex, 16, "0x", x @ 0 ... 9 => b'0' + x, + x @ 10 ... 15 => b'A' + (x - 10) } /// A radix with in the range of `2..36`. #[deriving(Clone, PartialEq)] @@ -174,23 +174,23 @@ macro_rules! int_base { } macro_rules! integer { ($Int:ident, $Uint:ident) => { - int_base!(Show for $Int as $Int -> Decimal) - int_base!(Binary for $Int as $Uint -> Binary) - int_base!(Octal for $Int as $Uint -> Octal) - int_base!(LowerHex for $Int as $Uint -> LowerHex) - int_base!(UpperHex for $Int as $Uint -> UpperHex) - radix_fmt!($Int as $Int, fmt_int) - - int_base!(Show for $Uint as $Uint -> Decimal) - int_base!(Binary for $Uint as $Uint -> Binary) - int_base!(Octal for $Uint as $Uint -> Octal) - int_base!(LowerHex for $Uint as $Uint -> LowerHex) - int_base!(UpperHex for $Uint as $Uint -> UpperHex) - radix_fmt!($Uint as $Uint, fmt_int) + int_base! { Show for $Int as $Int -> Decimal } + int_base! { Binary for $Int as $Uint -> Binary } + int_base! { Octal for $Int as $Uint -> Octal } + int_base! { LowerHex for $Int as $Uint -> LowerHex } + int_base! { UpperHex for $Int as $Uint -> UpperHex } + radix_fmt! { $Int as $Int, fmt_int } + + int_base! { Show for $Uint as $Uint -> Decimal } + int_base! { Binary for $Uint as $Uint -> Binary } + int_base! { Octal for $Uint as $Uint -> Octal } + int_base! { LowerHex for $Uint as $Uint -> LowerHex } + int_base! { UpperHex for $Uint as $Uint -> UpperHex } + radix_fmt! { $Uint as $Uint, fmt_int } } } -integer!(int, uint) -integer!(i8, u8) -integer!(i16, u16) -integer!(i32, u32) -integer!(i64, u64) +integer! { int, uint } +integer! { i8, u8 } +integer! { i16, u16 } +integer! { i32, u32 } +integer! { i64, u64 } diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs index 671ab825829..c1aa605a455 100644 --- a/src/libcore/hash/mod.rs +++ b/src/libcore/hash/mod.rs @@ -109,16 +109,16 @@ macro_rules! impl_hash { } } -impl_hash!(u8, u8) -impl_hash!(u16, u16) -impl_hash!(u32, u32) -impl_hash!(u64, u64) -impl_hash!(uint, uint) -impl_hash!(i8, u8) -impl_hash!(i16, u16) -impl_hash!(i32, u32) -impl_hash!(i64, u64) -impl_hash!(int, uint) +impl_hash! { u8, u8 } +impl_hash! { u16, u16 } +impl_hash! { u32, u32 } +impl_hash! { u64, u64 } +impl_hash! { uint, uint } +impl_hash! { i8, u8 } +impl_hash! { i16, u16 } +impl_hash! { i32, u32 } +impl_hash! { i64, u64 } +impl_hash! { int, uint } impl<S: Writer> Hash<S> for bool { #[inline] @@ -142,7 +142,7 @@ impl<S: Writer> Hash<S> for str { } } -macro_rules! impl_hash_tuple( +macro_rules! impl_hash_tuple { () => ( impl<S: Writer> Hash<S> for () { #[inline] @@ -167,21 +167,21 @@ macro_rules! impl_hash_tuple( } } ); -) - -impl_hash_tuple!() -impl_hash_tuple!(A) -impl_hash_tuple!(A B) -impl_hash_tuple!(A B C) -impl_hash_tuple!(A B C D) -impl_hash_tuple!(A B C D E) -impl_hash_tuple!(A B C D E F) -impl_hash_tuple!(A B C D E F G) -impl_hash_tuple!(A B C D E F G H) -impl_hash_tuple!(A B C D E F G H I) -impl_hash_tuple!(A B C D E F G H I J) -impl_hash_tuple!(A B C D E F G H I J K) -impl_hash_tuple!(A B C D E F G H I J K L) +} + +impl_hash_tuple! {} +impl_hash_tuple! { A } +impl_hash_tuple! { A B } +impl_hash_tuple! { A B C } +impl_hash_tuple! { A B C D } +impl_hash_tuple! { A B C D E } +impl_hash_tuple! { A B C D E F } +impl_hash_tuple! { A B C D E F G } +impl_hash_tuple! { A B C D E F G H } +impl_hash_tuple! { A B C D E F G H I } +impl_hash_tuple! { A B C D E F G H I J } +impl_hash_tuple! { A B C D E F G H I J K } +impl_hash_tuple! { A B C D E F G H I J K L } impl<S: Writer, T: Hash<S>> Hash<S> for [T] { #[inline] diff --git a/src/libcore/hash/sip.rs b/src/libcore/hash/sip.rs index 1f511ed759e..15f6768edce 100644 --- a/src/libcore/hash/sip.rs +++ b/src/libcore/hash/sip.rs @@ -48,7 +48,7 @@ impl Copy for SipState {} // because they're needed in the following defs; // this design could be improved. -macro_rules! u8to64_le ( +macro_rules! u8to64_le { ($buf:expr, $i:expr) => ($buf[0+$i] as u64 | $buf[1+$i] as u64 << 8 | @@ -68,14 +68,14 @@ macro_rules! u8to64_le ( } out }); -) +} -macro_rules! rotl ( +macro_rules! rotl { ($x:expr, $b:expr) => (($x << $b) | ($x >> (64 - $b))) -) +} -macro_rules! compress ( +macro_rules! compress { ($v0:expr, $v1:expr, $v2:expr, $v3:expr) => ({ $v0 += $v1; $v1 = rotl!($v1, 13); $v1 ^= $v0; @@ -85,7 +85,7 @@ macro_rules! compress ( $v2 += $v1; $v1 = rotl!($v1, 17); $v1 ^= $v2; $v2 = rotl!($v2, 32); }) -) +} impl SipState { /// Creates a `SipState` that is keyed off the provided keys. 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))); diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index 9016f40b1b8..7ce1da7d2d0 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -12,7 +12,7 @@ /// Entry point of task panic, for details, see std::macros #[macro_export] -macro_rules! panic( +macro_rules! panic { () => ( panic!("{}", "explicit panic") ); @@ -44,11 +44,11 @@ macro_rules! panic( } format_args!(_run_fmt, $fmt, $($arg)*) }); -) +} /// Runtime assertion, for details see std::macros #[macro_export] -macro_rules! assert( +macro_rules! assert { ($cond:expr) => ( if !$cond { panic!(concat!("assertion failed: ", stringify!($cond))) @@ -59,21 +59,21 @@ macro_rules! assert( panic!($($arg)*) } ); -) +} /// Runtime assertion, only without `--cfg ndebug` #[macro_export] -macro_rules! debug_assert( +macro_rules! debug_assert { ($(a:tt)*) => ({ if cfg!(not(ndebug)) { assert!($($a)*); } }) -) +} /// Runtime assertion for equality, for details see std::macros #[macro_export] -macro_rules! assert_eq( +macro_rules! assert_eq { ($cond1:expr, $cond2:expr) => ({ let c1 = $cond1; let c2 = $cond2; @@ -81,46 +81,47 @@ macro_rules! assert_eq( panic!("expressions not equal, left: {}, right: {}", c1, c2); } }) -) +} /// Runtime assertion for equality, only without `--cfg ndebug` #[macro_export] -macro_rules! debug_assert_eq( +macro_rules! debug_assert_eq { ($($a:tt)*) => ({ if cfg!(not(ndebug)) { assert_eq!($($a)*); } }) -) +} /// Runtime assertion, disableable at compile time #[macro_export] -macro_rules! debug_assert( +macro_rules! debug_assert { ($($arg:tt)*) => (if cfg!(not(ndebug)) { assert!($($arg)*); }) -) +} /// Short circuiting evaluation on Err #[macro_export] -macro_rules! try( +macro_rules! try { ($e:expr) => (match $e { Ok(e) => e, Err(e) => return Err(e) }) -) +} /// Writing a formatted string into a writer #[macro_export] -macro_rules! write( +macro_rules! write { ($dst:expr, $($arg:tt)*) => ({ let dst = &mut *$dst; format_args!(|args| { dst.write_fmt(args) }, $($arg)*) }) -) +} /// Writing a formatted string plus a newline into a writer #[macro_export] -macro_rules! writeln( +macro_rules! writeln { ($dst:expr, $fmt:expr $($arg:tt)*) => ( write!($dst, concat!($fmt, "\n") $($arg)*) ) -) +} #[macro_export] -macro_rules! unreachable( () => (panic!("unreachable code")) ) +macro_rules! unreachable { () => (panic!("unreachable code")) } + diff --git a/src/libcore/num/float_macros.rs b/src/libcore/num/float_macros.rs index d15cff3a8a9..97de61d7e27 100644 --- a/src/libcore/num/float_macros.rs +++ b/src/libcore/num/float_macros.rs @@ -11,11 +11,12 @@ #![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/libcore/num/i16.rs b/src/libcore/num/i16.rs index 00c8dc5b68d..eb2a4c3835d 100644 --- a/src/libcore/num/i16.rs +++ b/src/libcore/num/i16.rs @@ -13,4 +13,4 @@ #![stable] #![doc(primitive = "i16")] -int_module!(i16, 16) +int_module! { i16, 16 } diff --git a/src/libcore/num/i32.rs b/src/libcore/num/i32.rs index 1879ce1ac86..849fa205756 100644 --- a/src/libcore/num/i32.rs +++ b/src/libcore/num/i32.rs @@ -13,4 +13,4 @@ #![stable] #![doc(primitive = "i32")] -int_module!(i32, 32) +int_module! { i32, 32 } diff --git a/src/libcore/num/i64.rs b/src/libcore/num/i64.rs index 5832b2fdc03..b6cba728e44 100644 --- a/src/libcore/num/i64.rs +++ b/src/libcore/num/i64.rs @@ -13,4 +13,4 @@ #![stable] #![doc(primitive = "i64")] -int_module!(i64, 64) +int_module! { i64, 64 } diff --git a/src/libcore/num/i8.rs b/src/libcore/num/i8.rs index 65cf5d2b1c1..fd0759898ea 100644 --- a/src/libcore/num/i8.rs +++ b/src/libcore/num/i8.rs @@ -13,4 +13,4 @@ #![stable] #![doc(primitive = "i8")] -int_module!(i8, 8) +int_module! { i8, 8 } diff --git a/src/libcore/num/int.rs b/src/libcore/num/int.rs index 835246684df..a0659d38307 100644 --- a/src/libcore/num/int.rs +++ b/src/libcore/num/int.rs @@ -13,6 +13,6 @@ #![unstable] #![doc(primitive = "int")] -#[cfg(target_word_size = "32")] int_module!(int, 32) -#[cfg(target_word_size = "64")] int_module!(int, 64) +#[cfg(target_word_size = "32")] int_module! { int, 32 } +#[cfg(target_word_size = "64")] int_module! { int, 64 } diff --git a/src/libcore/num/int_macros.rs b/src/libcore/num/int_macros.rs index 0f8950344c8..00b9d88abe1 100644 --- a/src/libcore/num/int_macros.rs +++ b/src/libcore/num/int_macros.rs @@ -11,7 +11,7 @@ #![macro_escape] #![doc(hidden)] -macro_rules! int_module (($T:ty, $bits:expr) => ( +macro_rules! int_module { ($T:ty, $bits:expr) => ( // FIXME(#11621): Should be deprecated once CTFE is implemented in favour of // calling the `mem::size_of` function. @@ -32,4 +32,5 @@ pub const MIN: $T = (-1 as $T) << (BITS - 1); #[unstable] pub const MAX: $T = !MIN; -)) +) } + diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 2416cf5bcc7..fcb2ca93054 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -458,61 +458,61 @@ macro_rules! uint_impl { /// consistency with the other `bswap` intrinsics. unsafe fn bswap8(x: u8) -> u8 { x } -uint_impl!(u8 = u8, 8, +uint_impl! { u8 = u8, 8, intrinsics::ctpop8, intrinsics::ctlz8, intrinsics::cttz8, bswap8, intrinsics::u8_add_with_overflow, intrinsics::u8_sub_with_overflow, - intrinsics::u8_mul_with_overflow) + intrinsics::u8_mul_with_overflow } -uint_impl!(u16 = u16, 16, +uint_impl! { u16 = u16, 16, intrinsics::ctpop16, intrinsics::ctlz16, intrinsics::cttz16, intrinsics::bswap16, intrinsics::u16_add_with_overflow, intrinsics::u16_sub_with_overflow, - intrinsics::u16_mul_with_overflow) + intrinsics::u16_mul_with_overflow } -uint_impl!(u32 = u32, 32, +uint_impl! { u32 = u32, 32, intrinsics::ctpop32, intrinsics::ctlz32, intrinsics::cttz32, intrinsics::bswap32, intrinsics::u32_add_with_overflow, intrinsics::u32_sub_with_overflow, - intrinsics::u32_mul_with_overflow) + intrinsics::u32_mul_with_overflow } -uint_impl!(u64 = u64, 64, +uint_impl! { u64 = u64, 64, intrinsics::ctpop64, intrinsics::ctlz64, intrinsics::cttz64, intrinsics::bswap64, intrinsics::u64_add_with_overflow, intrinsics::u64_sub_with_overflow, - intrinsics::u64_mul_with_overflow) + intrinsics::u64_mul_with_overflow } #[cfg(target_word_size = "32")] -uint_impl!(uint = u32, 32, +uint_impl! { uint = u32, 32, intrinsics::ctpop32, intrinsics::ctlz32, intrinsics::cttz32, intrinsics::bswap32, intrinsics::u32_add_with_overflow, intrinsics::u32_sub_with_overflow, - intrinsics::u32_mul_with_overflow) + intrinsics::u32_mul_with_overflow } #[cfg(target_word_size = "64")] -uint_impl!(uint = u64, 64, +uint_impl! { uint = u64, 64, intrinsics::ctpop64, intrinsics::ctlz64, intrinsics::cttz64, intrinsics::bswap64, intrinsics::u64_add_with_overflow, intrinsics::u64_sub_with_overflow, - intrinsics::u64_mul_with_overflow) + intrinsics::u64_mul_with_overflow } macro_rules! int_impl { ($T:ty = $ActualT:ty, $UnsignedT:ty, $BITS:expr, @@ -579,37 +579,37 @@ macro_rules! int_impl { } } -int_impl!(i8 = i8, u8, 8, +int_impl! { i8 = i8, u8, 8, intrinsics::i8_add_with_overflow, intrinsics::i8_sub_with_overflow, - intrinsics::i8_mul_with_overflow) + intrinsics::i8_mul_with_overflow } -int_impl!(i16 = i16, u16, 16, +int_impl! { i16 = i16, u16, 16, intrinsics::i16_add_with_overflow, intrinsics::i16_sub_with_overflow, - intrinsics::i16_mul_with_overflow) + intrinsics::i16_mul_with_overflow } -int_impl!(i32 = i32, u32, 32, +int_impl! { i32 = i32, u32, 32, intrinsics::i32_add_with_overflow, intrinsics::i32_sub_with_overflow, - intrinsics::i32_mul_with_overflow) + intrinsics::i32_mul_with_overflow } -int_impl!(i64 = i64, u64, 64, +int_impl! { i64 = i64, u64, 64, intrinsics::i64_add_with_overflow, intrinsics::i64_sub_with_overflow, - intrinsics::i64_mul_with_overflow) + intrinsics::i64_mul_with_overflow } #[cfg(target_word_size = "32")] -int_impl!(int = i32, u32, 32, +int_impl! { int = i32, u32, 32, intrinsics::i32_add_with_overflow, intrinsics::i32_sub_with_overflow, - intrinsics::i32_mul_with_overflow) + intrinsics::i32_mul_with_overflow } #[cfg(target_word_size = "64")] -int_impl!(int = i64, u64, 64, +int_impl! { int = i64, u64, 64, intrinsics::i64_add_with_overflow, intrinsics::i64_sub_with_overflow, - intrinsics::i64_mul_with_overflow) + intrinsics::i64_mul_with_overflow } /// A built-in two's complement integer. #[unstable = "recently settled as part of numerics reform"] @@ -663,11 +663,11 @@ macro_rules! signed_int_impl { } } -signed_int_impl!(i8) -signed_int_impl!(i16) -signed_int_impl!(i32) -signed_int_impl!(i64) -signed_int_impl!(int) +signed_int_impl! { i8 } +signed_int_impl! { i16 } +signed_int_impl! { i32 } +signed_int_impl! { i64 } +signed_int_impl! { int } /// A built-in unsigned integer. #[unstable = "recently settled as part of numerics reform"] @@ -791,7 +791,7 @@ pub trait ToPrimitive { } } -macro_rules! impl_to_primitive_int_to_int( +macro_rules! impl_to_primitive_int_to_int { ($SrcT:ty, $DstT:ty, $slf:expr) => ( { if size_of::<$SrcT>() <= size_of::<$DstT>() { @@ -808,9 +808,9 @@ macro_rules! impl_to_primitive_int_to_int( } } ) -) +} -macro_rules! impl_to_primitive_int_to_uint( +macro_rules! impl_to_primitive_int_to_uint { ($SrcT:ty, $DstT:ty, $slf:expr) => ( { let zero: $SrcT = Int::zero(); @@ -822,9 +822,9 @@ macro_rules! impl_to_primitive_int_to_uint( } } ) -) +} -macro_rules! impl_to_primitive_int( +macro_rules! impl_to_primitive_int { ($T:ty) => ( impl ToPrimitive for $T { #[inline] @@ -855,15 +855,15 @@ macro_rules! impl_to_primitive_int( fn to_f64(&self) -> Option<f64> { Some(*self as f64) } } ) -) +} -impl_to_primitive_int!(int) -impl_to_primitive_int!(i8) -impl_to_primitive_int!(i16) -impl_to_primitive_int!(i32) -impl_to_primitive_int!(i64) +impl_to_primitive_int! { int } +impl_to_primitive_int! { i8 } +impl_to_primitive_int! { i16 } +impl_to_primitive_int! { i32 } +impl_to_primitive_int! { i64 } -macro_rules! impl_to_primitive_uint_to_int( +macro_rules! impl_to_primitive_uint_to_int { ($DstT:ty, $slf:expr) => ( { let max_value: $DstT = Int::max_value(); @@ -874,9 +874,9 @@ macro_rules! impl_to_primitive_uint_to_int( } } ) -) +} -macro_rules! impl_to_primitive_uint_to_uint( +macro_rules! impl_to_primitive_uint_to_uint { ($SrcT:ty, $DstT:ty, $slf:expr) => ( { if size_of::<$SrcT>() <= size_of::<$DstT>() { @@ -892,9 +892,9 @@ macro_rules! impl_to_primitive_uint_to_uint( } } ) -) +} -macro_rules! impl_to_primitive_uint( +macro_rules! impl_to_primitive_uint { ($T:ty) => ( impl ToPrimitive for $T { #[inline] @@ -925,15 +925,15 @@ macro_rules! impl_to_primitive_uint( fn to_f64(&self) -> Option<f64> { Some(*self as f64) } } ) -) +} -impl_to_primitive_uint!(uint) -impl_to_primitive_uint!(u8) -impl_to_primitive_uint!(u16) -impl_to_primitive_uint!(u32) -impl_to_primitive_uint!(u64) +impl_to_primitive_uint! { uint } +impl_to_primitive_uint! { u8 } +impl_to_primitive_uint! { u16 } +impl_to_primitive_uint! { u32 } +impl_to_primitive_uint! { u64 } -macro_rules! impl_to_primitive_float_to_float( +macro_rules! impl_to_primitive_float_to_float { ($SrcT:ty, $DstT:ty, $slf:expr) => ( if size_of::<$SrcT>() <= size_of::<$DstT>() { Some($slf as $DstT) @@ -947,9 +947,9 @@ macro_rules! impl_to_primitive_float_to_float( } } ) -) +} -macro_rules! impl_to_primitive_float( +macro_rules! impl_to_primitive_float { ($T:ty) => ( impl ToPrimitive for $T { #[inline] @@ -980,10 +980,10 @@ macro_rules! impl_to_primitive_float( fn to_f64(&self) -> Option<f64> { impl_to_primitive_float_to_float!($T, f64, *self) } } ) -) +} -impl_to_primitive_float!(f32) -impl_to_primitive_float!(f64) +impl_to_primitive_float! { f32 } +impl_to_primitive_float! { f64 } /// A generic trait for converting a number to a value. #[experimental = "trait is likely to be removed"] @@ -1139,7 +1139,7 @@ pub fn from_f64<A: FromPrimitive>(n: f64) -> Option<A> { FromPrimitive::from_f64(n) } -macro_rules! impl_from_primitive( +macro_rules! impl_from_primitive { ($T:ty, $to_ty:ident) => ( impl FromPrimitive for $T { #[inline] fn from_int(n: int) -> Option<$T> { n.$to_ty() } @@ -1158,20 +1158,20 @@ macro_rules! impl_from_primitive( #[inline] fn from_f64(n: f64) -> Option<$T> { n.$to_ty() } } ) -) - -impl_from_primitive!(int, to_int) -impl_from_primitive!(i8, to_i8) -impl_from_primitive!(i16, to_i16) -impl_from_primitive!(i32, to_i32) -impl_from_primitive!(i64, to_i64) -impl_from_primitive!(uint, to_uint) -impl_from_primitive!(u8, to_u8) -impl_from_primitive!(u16, to_u16) -impl_from_primitive!(u32, to_u32) -impl_from_primitive!(u64, to_u64) -impl_from_primitive!(f32, to_f32) -impl_from_primitive!(f64, to_f64) +} + +impl_from_primitive! { int, to_int } +impl_from_primitive! { i8, to_i8 } +impl_from_primitive! { i16, to_i16 } +impl_from_primitive! { i32, to_i32 } +impl_from_primitive! { i64, to_i64 } +impl_from_primitive! { uint, to_uint } +impl_from_primitive! { u8, to_u8 } +impl_from_primitive! { u16, to_u16 } +impl_from_primitive! { u32, to_u32 } +impl_from_primitive! { u64, to_u64 } +impl_from_primitive! { f32, to_f32 } +impl_from_primitive! { f64, to_f64 } /// Cast from one machine scalar to another. /// @@ -1198,7 +1198,7 @@ pub trait NumCast: ToPrimitive { fn from<T: ToPrimitive>(n: T) -> Option<Self>; } -macro_rules! impl_num_cast( +macro_rules! impl_num_cast { ($T:ty, $conv:ident) => ( impl NumCast for $T { #[inline] @@ -1209,20 +1209,20 @@ macro_rules! impl_num_cast( } } ) -) - -impl_num_cast!(u8, to_u8) -impl_num_cast!(u16, to_u16) -impl_num_cast!(u32, to_u32) -impl_num_cast!(u64, to_u64) -impl_num_cast!(uint, to_uint) -impl_num_cast!(i8, to_i8) -impl_num_cast!(i16, to_i16) -impl_num_cast!(i32, to_i32) -impl_num_cast!(i64, to_i64) -impl_num_cast!(int, to_int) -impl_num_cast!(f32, to_f32) -impl_num_cast!(f64, to_f64) +} + +impl_num_cast! { u8, to_u8 } +impl_num_cast! { u16, to_u16 } +impl_num_cast! { u32, to_u32 } +impl_num_cast! { u64, to_u64 } +impl_num_cast! { uint, to_uint } +impl_num_cast! { i8, to_i8 } +impl_num_cast! { i16, to_i16 } +impl_num_cast! { i32, to_i32 } +impl_num_cast! { i64, to_i64 } +impl_num_cast! { int, to_int } +impl_num_cast! { f32, to_f32 } +impl_num_cast! { f64, to_f64 } /// Used for representing the classification of floating point numbers #[deriving(PartialEq, Show)] @@ -1638,8 +1638,8 @@ macro_rules! from_str_radix_float_impl { } } } -from_str_radix_float_impl!(f32) -from_str_radix_float_impl!(f64) +from_str_radix_float_impl! { f32 } +from_str_radix_float_impl! { f64 } macro_rules! from_str_radix_int_impl { ($T:ty) => { @@ -1705,16 +1705,16 @@ macro_rules! from_str_radix_int_impl { } } } -from_str_radix_int_impl!(int) -from_str_radix_int_impl!(i8) -from_str_radix_int_impl!(i16) -from_str_radix_int_impl!(i32) -from_str_radix_int_impl!(i64) -from_str_radix_int_impl!(uint) -from_str_radix_int_impl!(u8) -from_str_radix_int_impl!(u16) -from_str_radix_int_impl!(u32) -from_str_radix_int_impl!(u64) +from_str_radix_int_impl! { int } +from_str_radix_int_impl! { i8 } +from_str_radix_int_impl! { i16 } +from_str_radix_int_impl! { i32 } +from_str_radix_int_impl! { i64 } +from_str_radix_int_impl! { uint } +from_str_radix_int_impl! { u8 } +from_str_radix_int_impl! { u16 } +from_str_radix_int_impl! { u32 } +from_str_radix_int_impl! { u64 } // DEPRECATED @@ -1733,17 +1733,17 @@ pub trait Num: PartialEq + Zero + One + Mul<Self,Self> + Div<Self,Self> + Rem<Self,Self> {} -trait_impl!(Num for uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64) +trait_impl! { Num for uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 } #[deprecated = "Generalised unsigned numbers are no longer supported"] #[allow(deprecated)] pub trait Unsigned: Num {} -trait_impl!(Unsigned for uint u8 u16 u32 u64) +trait_impl! { Unsigned for uint u8 u16 u32 u64 } #[deprecated = "Use `Float` or `Int`"] #[allow(deprecated)] pub trait Primitive: Copy + Clone + Num + NumCast + PartialOrd {} -trait_impl!(Primitive for uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64) +trait_impl! { Primitive for uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 } #[deprecated = "The generic `Zero` trait will be removed soon."] pub trait Zero: Add<Self, Self> { @@ -1763,18 +1763,18 @@ macro_rules! zero_impl { } } } -zero_impl!(uint, 0u) -zero_impl!(u8, 0u8) -zero_impl!(u16, 0u16) -zero_impl!(u32, 0u32) -zero_impl!(u64, 0u64) -zero_impl!(int, 0i) -zero_impl!(i8, 0i8) -zero_impl!(i16, 0i16) -zero_impl!(i32, 0i32) -zero_impl!(i64, 0i64) -zero_impl!(f32, 0.0f32) -zero_impl!(f64, 0.0f64) +zero_impl! { uint, 0u } +zero_impl! { u8, 0u8 } +zero_impl! { u16, 0u16 } +zero_impl! { u32, 0u32 } +zero_impl! { u64, 0u64 } +zero_impl! { int, 0i } +zero_impl! { i8, 0i8 } +zero_impl! { i16, 0i16 } +zero_impl! { i32, 0i32 } +zero_impl! { i64, 0i64 } +zero_impl! { f32, 0.0f32 } +zero_impl! { f64, 0.0f64 } #[deprecated = "The generic `One` trait will be removed soon."] pub trait One: Mul<Self, Self> { @@ -1791,18 +1791,18 @@ macro_rules! one_impl { } } } -one_impl!(uint, 1u) -one_impl!(u8, 1u8) -one_impl!(u16, 1u16) -one_impl!(u32, 1u32) -one_impl!(u64, 1u64) -one_impl!(int, 1i) -one_impl!(i8, 1i8) -one_impl!(i16, 1i16) -one_impl!(i32, 1i32) -one_impl!(i64, 1i64) -one_impl!(f32, 1.0f32) -one_impl!(f64, 1.0f64) +one_impl! { uint, 1u } +one_impl! { u8, 1u8 } +one_impl! { u16, 1u16 } +one_impl! { u32, 1u32 } +one_impl! { u64, 1u64 } +one_impl! { int, 1i } +one_impl! { i8, 1i8 } +one_impl! { i16, 1i16 } +one_impl! { i32, 1i32 } +one_impl! { i64, 1i64 } +one_impl! { f32, 1.0f32 } +one_impl! { f64, 1.0f64 } #[deprecated = "Use `UnsignedInt::next_power_of_two`"] pub fn next_power_of_two<T: UnsignedInt>(n: T) -> T { @@ -1835,15 +1835,15 @@ macro_rules! bounded_impl { } }; } -bounded_impl!(uint, uint::MIN, uint::MAX) -bounded_impl!(u8, u8::MIN, u8::MAX) -bounded_impl!(u16, u16::MIN, u16::MAX) -bounded_impl!(u32, u32::MIN, u32::MAX) -bounded_impl!(u64, u64::MIN, u64::MAX) -bounded_impl!(int, int::MIN, int::MAX) -bounded_impl!(i8, i8::MIN, i8::MAX) -bounded_impl!(i16, i16::MIN, i16::MAX) -bounded_impl!(i32, i32::MIN, i32::MAX) -bounded_impl!(i64, i64::MIN, i64::MAX) -bounded_impl!(f32, f32::MIN_VALUE, f32::MAX_VALUE) -bounded_impl!(f64, f64::MIN_VALUE, f64::MAX_VALUE) +bounded_impl! { uint, uint::MIN, uint::MAX } +bounded_impl! { u8, u8::MIN, u8::MAX } +bounded_impl! { u16, u16::MIN, u16::MAX } +bounded_impl! { u32, u32::MIN, u32::MAX } +bounded_impl! { u64, u64::MIN, u64::MAX } +bounded_impl! { int, int::MIN, int::MAX } +bounded_impl! { i8, i8::MIN, i8::MAX } +bounded_impl! { i16, i16::MIN, i16::MAX } +bounded_impl! { i32, i32::MIN, i32::MAX } +bounded_impl! { i64, i64::MIN, i64::MAX } +bounded_impl! { f32, f32::MIN_VALUE, f32::MAX_VALUE } +bounded_impl! { f64, f64::MIN_VALUE, f64::MAX_VALUE } diff --git a/src/libcore/num/u16.rs b/src/libcore/num/u16.rs index 6971de279fa..730a24a963a 100644 --- a/src/libcore/num/u16.rs +++ b/src/libcore/num/u16.rs @@ -13,4 +13,4 @@ #![stable] #![doc(primitive = "u16")] -uint_module!(u16, i16, 16) +uint_module! { u16, i16, 16 } diff --git a/src/libcore/num/u32.rs b/src/libcore/num/u32.rs index 26affc3f790..f308122af43 100644 --- a/src/libcore/num/u32.rs +++ b/src/libcore/num/u32.rs @@ -13,4 +13,4 @@ #![stable] #![doc(primitive = "u32")] -uint_module!(u32, i32, 32) +uint_module! { u32, i32, 32 } diff --git a/src/libcore/num/u64.rs b/src/libcore/num/u64.rs index 3b50d033001..a55868eb746 100644 --- a/src/libcore/num/u64.rs +++ b/src/libcore/num/u64.rs @@ -13,4 +13,4 @@ #![stable] #![doc(primitive = "u64")] -uint_module!(u64, i64, 64) +uint_module! { u64, i64, 64 } diff --git a/src/libcore/num/u8.rs b/src/libcore/num/u8.rs index ce7d767aee4..8643f8ad650 100644 --- a/src/libcore/num/u8.rs +++ b/src/libcore/num/u8.rs @@ -13,4 +13,4 @@ #![stable] #![doc(primitive = "u8")] -uint_module!(u8, i8, 8) +uint_module! { u8, i8, 8 } diff --git a/src/libcore/num/uint.rs b/src/libcore/num/uint.rs index 62d2f11e541..80d7b0b4ef3 100644 --- a/src/libcore/num/uint.rs +++ b/src/libcore/num/uint.rs @@ -13,5 +13,5 @@ #![unstable] #![doc(primitive = "uint")] -uint_module!(uint, int, ::int::BITS) +uint_module! { uint, int, ::int::BITS } diff --git a/src/libcore/num/uint_macros.rs b/src/libcore/num/uint_macros.rs index 2a94f851646..d79cf20fdfa 100644 --- a/src/libcore/num/uint_macros.rs +++ b/src/libcore/num/uint_macros.rs @@ -11,7 +11,7 @@ #![macro_escape] #![doc(hidden)] -macro_rules! uint_module (($T:ty, $T_SIGNED:ty, $bits:expr) => ( +macro_rules! uint_module { ($T:ty, $T_SIGNED:ty, $bits:expr) => ( #[unstable] pub const BITS : uint = $bits; @@ -23,4 +23,5 @@ pub const MIN: $T = 0 as $T; #[unstable] pub const MAX: $T = 0 as $T - 1 as $T; -)) +) } + diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 7ff5026d0b9..bc29a2b4a58 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -113,14 +113,14 @@ pub trait Add<Sized? RHS,Result> for Sized? { // NOTE(stage0): Remove macro after a snapshot #[cfg(stage0)] -macro_rules! add_impl( +macro_rules! add_impl { ($($t:ty)*) => ($( impl Add<$t, $t> for $t { #[inline] fn add(&self, other: &$t) -> $t { (*self) + (*other) } } )*) -) +} /// The `Add` trait is used to specify the functionality of `+`. /// @@ -151,16 +151,16 @@ pub trait Add<RHS, Result> { } #[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot -macro_rules! add_impl( +macro_rules! add_impl { ($($t:ty)*) => ($( impl Add<$t, $t> for $t { #[inline] fn add(self, other: $t) -> $t { self + other } } )*) -) +} -add_impl!(uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64) +add_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 } /// The `Sub` trait is used to specify the functionality of `-`. /// @@ -195,14 +195,14 @@ pub trait Sub<Sized? RHS, Result> for Sized? { // NOTE(stage0): Remove macro after a snapshot #[cfg(stage0)] -macro_rules! sub_impl( +macro_rules! sub_impl { ($($t:ty)*) => ($( impl Sub<$t, $t> for $t { #[inline] fn sub(&self, other: &$t) -> $t { (*self) - (*other) } } )*) -) +} /// The `Sub` trait is used to specify the functionality of `-`. /// @@ -233,16 +233,16 @@ pub trait Sub<RHS, Result> { } #[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot -macro_rules! sub_impl( +macro_rules! sub_impl { ($($t:ty)*) => ($( impl Sub<$t, $t> for $t { #[inline] fn sub(self, other: $t) -> $t { self - other } } )*) -) +} -sub_impl!(uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64) +sub_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 } /// The `Mul` trait is used to specify the functionality of `*`. /// @@ -277,14 +277,14 @@ pub trait Mul<Sized? RHS, Result> for Sized? { // NOTE(stage0): Remove macro after a snapshot #[cfg(stage0)] -macro_rules! mul_impl( +macro_rules! mul_impl { ($($t:ty)*) => ($( impl Mul<$t, $t> for $t { #[inline] fn mul(&self, other: &$t) -> $t { (*self) * (*other) } } )*) -) +} /// The `Mul` trait is used to specify the functionality of `*`. /// @@ -315,16 +315,16 @@ pub trait Mul<RHS, Result> { } #[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot -macro_rules! mul_impl( +macro_rules! mul_impl { ($($t:ty)*) => ($( impl Mul<$t, $t> for $t { #[inline] fn mul(self, other: $t) -> $t { self * other } } )*) -) +} -mul_impl!(uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64) +mul_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 } /// The `Div` trait is used to specify the functionality of `/`. /// @@ -359,14 +359,14 @@ pub trait Div<Sized? RHS, Result> for Sized? { // NOTE(stage0): Remove macro after a snapshot #[cfg(stage0)] -macro_rules! div_impl( +macro_rules! div_impl { ($($t:ty)*) => ($( impl Div<$t, $t> for $t { #[inline] fn div(&self, other: &$t) -> $t { (*self) / (*other) } } )*) -) +} /// The `Div` trait is used to specify the functionality of `/`. /// @@ -397,16 +397,16 @@ pub trait Div<RHS, Result> { } #[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot -macro_rules! div_impl( +macro_rules! div_impl { ($($t:ty)*) => ($( impl Div<$t, $t> for $t { #[inline] fn div(self, other: $t) -> $t { self / other } } )*) -) +} -div_impl!(uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64) +div_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 } /// The `Rem` trait is used to specify the functionality of `%`. /// @@ -441,18 +441,18 @@ pub trait Rem<Sized? RHS, Result> for Sized? { // NOTE(stage0): Remove macro after a snapshot #[cfg(stage0)] -macro_rules! rem_impl( +macro_rules! rem_impl { ($($t:ty)*) => ($( impl Rem<$t, $t> for $t { #[inline] fn rem(&self, other: &$t) -> $t { (*self) % (*other) } } )*) -) +} // NOTE(stage0): Remove macro after a snapshot #[cfg(stage0)] -macro_rules! rem_float_impl( +macro_rules! rem_float_impl { ($t:ty, $fmod:ident) => { impl Rem<$t, $t> for $t { #[inline] @@ -462,7 +462,7 @@ macro_rules! rem_float_impl( } } } -) +} /// The `Rem` trait is used to specify the functionality of `%`. /// @@ -493,17 +493,17 @@ pub trait Rem<RHS, Result> { } #[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot -macro_rules! rem_impl( +macro_rules! rem_impl { ($($t:ty)*) => ($( impl Rem<$t, $t> for $t { #[inline] fn rem(self, other: $t) -> $t { self % other } } )*) -) +} #[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot -macro_rules! rem_float_impl( +macro_rules! rem_float_impl { ($t:ty, $fmod:ident) => { impl Rem<$t, $t> for $t { #[inline] @@ -513,11 +513,11 @@ macro_rules! rem_float_impl( } } } -) +} -rem_impl!(uint u8 u16 u32 u64 int i8 i16 i32 i64) -rem_float_impl!(f32, fmodf) -rem_float_impl!(f64, fmod) +rem_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 } +rem_float_impl! { f32, fmodf } +rem_float_impl! { f64, fmod } /// The `Neg` trait is used to specify the functionality of unary `-`. /// @@ -548,31 +548,31 @@ pub trait Neg<Result> for Sized? { fn neg(&self) -> Result; } -macro_rules! neg_impl( +macro_rules! neg_impl { ($($t:ty)*) => ($( impl Neg<$t> for $t { #[inline] fn neg(&self) -> $t { -*self } } )*) -) +} -macro_rules! neg_uint_impl( +macro_rules! neg_uint_impl { ($t:ty, $t_signed:ty) => { impl Neg<$t> for $t { #[inline] fn neg(&self) -> $t { -(*self as $t_signed) as $t } } } -) +} -neg_impl!(int i8 i16 i32 i64 f32 f64) +neg_impl! { int i8 i16 i32 i64 f32 f64 } -neg_uint_impl!(uint, int) -neg_uint_impl!(u8, i8) -neg_uint_impl!(u16, i16) -neg_uint_impl!(u32, i32) -neg_uint_impl!(u64, i64) +neg_uint_impl! { uint, int } +neg_uint_impl! { u8, i8 } +neg_uint_impl! { u16, i16 } +neg_uint_impl! { u32, i32 } +neg_uint_impl! { u64, i64 } /// The `Not` trait is used to specify the functionality of unary `!`. @@ -605,16 +605,16 @@ pub trait Not<Result> for Sized? { } -macro_rules! not_impl( +macro_rules! not_impl { ($($t:ty)*) => ($( impl Not<$t> for $t { #[inline] fn not(&self) -> $t { !*self } } )*) -) +} -not_impl!(bool uint u8 u16 u32 u64 int i8 i16 i32 i64) +not_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 } /// The `BitAnd` trait is used to specify the functionality of `&`. /// @@ -649,14 +649,14 @@ pub trait BitAnd<Sized? RHS, Result> for Sized? { // NOTE(stage0): Remove macro after a snapshot #[cfg(stage0)] -macro_rules! bitand_impl( +macro_rules! bitand_impl { ($($t:ty)*) => ($( impl BitAnd<$t, $t> for $t { #[inline] fn bitand(&self, rhs: &$t) -> $t { (*self) & (*rhs) } } )*) -) +} /// The `BitAnd` trait is used to specify the functionality of `&`. /// @@ -687,16 +687,16 @@ pub trait BitAnd<RHS, Result> { } #[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot -macro_rules! bitand_impl( +macro_rules! bitand_impl { ($($t:ty)*) => ($( impl BitAnd<$t, $t> for $t { #[inline] fn bitand(self, rhs: $t) -> $t { self & rhs } } )*) -) +} -bitand_impl!(bool uint u8 u16 u32 u64 int i8 i16 i32 i64) +bitand_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 } /// The `BitOr` trait is used to specify the functionality of `|`. /// @@ -731,14 +731,14 @@ pub trait BitOr<Sized? RHS, Result> for Sized? { // NOTE(stage0): Remove macro after a snapshot #[cfg(stage0)] -macro_rules! bitor_impl( +macro_rules! bitor_impl { ($($t:ty)*) => ($( impl BitOr<$t,$t> for $t { #[inline] fn bitor(&self, rhs: &$t) -> $t { (*self) | (*rhs) } } )*) -) +} /// The `BitOr` trait is used to specify the functionality of `|`. /// @@ -769,16 +769,16 @@ pub trait BitOr<RHS, Result> { } #[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot -macro_rules! bitor_impl( +macro_rules! bitor_impl { ($($t:ty)*) => ($( impl BitOr<$t,$t> for $t { #[inline] fn bitor(self, rhs: $t) -> $t { self | rhs } } )*) -) +} -bitor_impl!(bool uint u8 u16 u32 u64 int i8 i16 i32 i64) +bitor_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 } /// The `BitXor` trait is used to specify the functionality of `^`. /// @@ -813,14 +813,14 @@ pub trait BitXor<Sized? RHS, Result> for Sized? { // NOTE(stage0): Remove macro after a snapshot #[cfg(stage0)] -macro_rules! bitxor_impl( +macro_rules! bitxor_impl { ($($t:ty)*) => ($( impl BitXor<$t, $t> for $t { #[inline] fn bitxor(&self, other: &$t) -> $t { (*self) ^ (*other) } } )*) -) +} /// The `BitXor` trait is used to specify the functionality of `^`. /// @@ -851,16 +851,16 @@ pub trait BitXor<RHS, Result> { } #[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot -macro_rules! bitxor_impl( +macro_rules! bitxor_impl { ($($t:ty)*) => ($( impl BitXor<$t, $t> for $t { #[inline] fn bitxor(self, other: $t) -> $t { self ^ other } } )*) -) +} -bitxor_impl!(bool uint u8 u16 u32 u64 int i8 i16 i32 i64) +bitxor_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 } /// The `Shl` trait is used to specify the functionality of `<<`. /// @@ -895,7 +895,7 @@ pub trait Shl<Sized? RHS, Result> for Sized? { // NOTE(stage0): Remove macro after a snapshot #[cfg(stage0)] -macro_rules! shl_impl( +macro_rules! shl_impl { ($($t:ty)*) => ($( impl Shl<uint, $t> for $t { #[inline] @@ -904,7 +904,7 @@ macro_rules! shl_impl( } } )*) -) +} /// The `Shl` trait is used to specify the functionality of `<<`. /// @@ -935,7 +935,7 @@ pub trait Shl<RHS, Result> { } #[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot -macro_rules! shl_impl( +macro_rules! shl_impl { ($($t:ty)*) => ($( impl Shl<uint, $t> for $t { #[inline] @@ -944,9 +944,9 @@ macro_rules! shl_impl( } } )*) -) +} -shl_impl!(uint u8 u16 u32 u64 int i8 i16 i32 i64) +shl_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 } /// The `Shr` trait is used to specify the functionality of `>>`. /// @@ -981,14 +981,14 @@ pub trait Shr<Sized? RHS, Result> for Sized? { // NOTE(stage0): Remove macro after a snapshot #[cfg(stage0)] -macro_rules! shr_impl( +macro_rules! shr_impl { ($($t:ty)*) => ($( impl Shr<uint, $t> for $t { #[inline] fn shr(&self, other: &uint) -> $t { (*self) >> (*other) } } )*) -) +} /// The `Shr` trait is used to specify the functionality of `>>`. /// @@ -1019,16 +1019,16 @@ pub trait Shr<RHS, Result> { } #[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot -macro_rules! shr_impl( +macro_rules! shr_impl { ($($t:ty)*) => ($( impl Shr<uint, $t> for $t { #[inline] fn shr(self, other: uint) -> $t { self >> other } } )*) -) +} -shr_impl!(uint u8 u16 u32 u64 int i8 i16 i32 i64) +shr_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 } /// The `Index` trait is used to specify the functionality of indexing operations /// like `arr[idx]` when used in an immutable context. diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index edd5f989797..36c6b9572ea 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -367,7 +367,7 @@ mod externfnpointers { self_ == other_ } } - macro_rules! fnptreq( + macro_rules! fnptreq { ($($p:ident),*) => { impl<_R,$($p),*> PartialEq for extern "C" fn($($p),*) -> _R { #[inline] @@ -379,12 +379,12 @@ mod externfnpointers { } } } - ) - fnptreq!(A) - fnptreq!(A,B) - fnptreq!(A,B,C) - fnptreq!(A,B,C,D) - fnptreq!(A,B,C,D,E) + } + fnptreq! { A } + fnptreq! { A,B } + fnptreq! { A,B,C } + fnptreq! { A,B,C,D } + fnptreq! { A,B,C,D,E } } // Comparison for pointers diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 6dd23abf11f..e12666a2adf 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -222,7 +222,7 @@ //! # #![feature(macro_rules)] //! macro_rules! try( //! ($e:expr) => (match $e { Ok(e) => e, Err(e) => return Err(e) }) -//! ) +//! ); //! # fn main() { } //! ``` //! diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 411a46ee1bd..2ee60955245 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -1540,16 +1540,16 @@ macro_rules! impl_mut_int_slice { macro_rules! impl_int_slice { ($u:ty, $s:ty) => { - impl_immut_int_slice!($u, $s, $u) - impl_immut_int_slice!($u, $s, $s) - impl_mut_int_slice!($u, $s, $u) - impl_mut_int_slice!($u, $s, $s) + impl_immut_int_slice! { $u, $s, $u } + impl_immut_int_slice! { $u, $s, $s } + impl_mut_int_slice! { $u, $s, $u } + impl_mut_int_slice! { $u, $s, $s } } } -impl_int_slice!(u8, i8) -impl_int_slice!(u16, i16) -impl_int_slice!(u32, i32) -impl_int_slice!(u64, i64) -impl_int_slice!(uint, int) +impl_int_slice! { u8, i8 } +impl_int_slice! { u16, i16 } +impl_int_slice! { u32, i32 } +impl_int_slice! { u64, i64 } +impl_int_slice! { uint, int } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 1a7467555a5..28110cf7b1a 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -174,18 +174,18 @@ impl<'a> Copy for Chars<'a> {} // Return the initial codepoint accumulator for the first byte. // The first byte is special, only want bottom 5 bits for width 2, 4 bits // for width 3, and 3 bits for width 4 -macro_rules! utf8_first_byte( +macro_rules! utf8_first_byte { ($byte:expr, $width:expr) => (($byte & (0x7F >> $width)) as u32) -) +} // return the value of $ch updated with continuation byte $byte -macro_rules! utf8_acc_cont_byte( +macro_rules! utf8_acc_cont_byte { ($ch:expr, $byte:expr) => (($ch << 6) | ($byte & CONT_MASK) as u32) -) +} -macro_rules! utf8_is_cont_byte( +macro_rules! utf8_is_cont_byte { ($byte:expr) => (($byte & !CONT_MASK) == TAG_CONT_U8) -) +} #[inline] fn unwrap_or_0(opt: Option<&u8>) -> u8 { @@ -959,7 +959,7 @@ pub fn is_utf16(v: &[u16]) -> bool { macro_rules! next ( ($ret:expr) => { match it.next() { Some(u) => *u, None => return $ret } } - ) + ); loop { let u = next!(true); @@ -1660,10 +1660,10 @@ pub trait StrPrelude for Sized? { /// # #![feature(unboxed_closures)] /// /// # fn main() { - /// assert_eq!("11foo1bar11".trim_chars('1'), "foo1bar") + /// assert_eq!("11foo1bar11".trim_chars('1'), "foo1bar"); /// let x: &[_] = &['1', '2']; - /// assert_eq!("12foo1bar12".trim_chars(x), "foo1bar") - /// assert_eq!("123foo1bar123".trim_chars(|&: c: char| c.is_numeric()), "foo1bar") + /// assert_eq!("12foo1bar12".trim_chars(x), "foo1bar"); + /// assert_eq!("123foo1bar123".trim_chars(|&: c: char| c.is_numeric()), "foo1bar"); /// # } /// ``` fn trim_chars<'a, C: CharEq>(&'a self, to_trim: C) -> &'a str; @@ -1680,10 +1680,10 @@ pub trait StrPrelude for Sized? { /// # #![feature(unboxed_closures)] /// /// # fn main() { - /// assert_eq!("11foo1bar11".trim_left_chars('1'), "foo1bar11") + /// assert_eq!("11foo1bar11".trim_left_chars('1'), "foo1bar11"); /// let x: &[_] = &['1', '2']; - /// assert_eq!("12foo1bar12".trim_left_chars(x), "foo1bar12") - /// assert_eq!("123foo1bar123".trim_left_chars(|&: c: char| c.is_numeric()), "foo1bar123") + /// assert_eq!("12foo1bar12".trim_left_chars(x), "foo1bar12"); + /// assert_eq!("123foo1bar123".trim_left_chars(|&: c: char| c.is_numeric()), "foo1bar123"); /// # } /// ``` fn trim_left_chars<'a, C: CharEq>(&'a self, to_trim: C) -> &'a str; @@ -1700,10 +1700,10 @@ pub trait StrPrelude for Sized? { /// # #![feature(unboxed_closures)] /// /// # fn main() { - /// assert_eq!("11foo1bar11".trim_right_chars('1'), "11foo1bar") + /// assert_eq!("11foo1bar11".trim_right_chars('1'), "11foo1bar"); /// let x: &[_] = &['1', '2']; - /// assert_eq!("12foo1bar12".trim_right_chars(x), "12foo1bar") - /// assert_eq!("123foo1bar123".trim_right_chars(|&: c: char| c.is_numeric()), "123foo1bar") + /// assert_eq!("12foo1bar12".trim_right_chars(x), "12foo1bar"); + /// assert_eq!("123foo1bar123".trim_right_chars(|&: c: char| c.is_numeric()), "123foo1bar"); /// # } /// ``` fn trim_right_chars<'a, C: CharEq>(&'a self, to_trim: C) -> &'a str; @@ -2059,7 +2059,7 @@ impl StrPrelude for str { #[inline] fn match_indices<'a>(&'a self, sep: &'a str) -> MatchIndices<'a> { - assert!(!sep.is_empty()) + assert!(!sep.is_empty()); MatchIndices { haystack: self, needle: sep, diff --git a/src/libcoretest/iter.rs b/src/libcoretest/iter.rs index 0bcebe073a3..dbbbaa5892c 100644 --- a/src/libcoretest/iter.rs +++ b/src/libcoretest/iter.rs @@ -522,15 +522,15 @@ fn test_double_ended_chain() { let xs = [1i, 2, 3, 4, 5]; let ys = [7i, 9, 11]; let mut it = xs.iter().chain(ys.iter()).rev(); - assert_eq!(it.next().unwrap(), &11) - assert_eq!(it.next().unwrap(), &9) - assert_eq!(it.next_back().unwrap(), &1) - assert_eq!(it.next_back().unwrap(), &2) - assert_eq!(it.next_back().unwrap(), &3) - assert_eq!(it.next_back().unwrap(), &4) - assert_eq!(it.next_back().unwrap(), &5) - assert_eq!(it.next_back().unwrap(), &7) - assert_eq!(it.next_back(), None) + assert_eq!(it.next().unwrap(), &11); + assert_eq!(it.next().unwrap(), &9); + assert_eq!(it.next_back().unwrap(), &1); + assert_eq!(it.next_back().unwrap(), &2); + assert_eq!(it.next_back().unwrap(), &3); + assert_eq!(it.next_back().unwrap(), &4); + assert_eq!(it.next_back().unwrap(), &5); + assert_eq!(it.next_back().unwrap(), &7); + assert_eq!(it.next_back(), None); } #[test] @@ -800,7 +800,7 @@ fn test_min_max() { #[test] fn test_min_max_result() { 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))); diff --git a/src/libcoretest/num/i16.rs b/src/libcoretest/num/i16.rs index f3c2d67cdeb..7435831ac6d 100644 --- a/src/libcoretest/num/i16.rs +++ b/src/libcoretest/num/i16.rs @@ -8,4 +8,4 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -int_module!(i16, i16) +int_module!(i16, i16); diff --git a/src/libcoretest/num/i32.rs b/src/libcoretest/num/i32.rs index 7232fc7505d..3b3407e1ada 100644 --- a/src/libcoretest/num/i32.rs +++ b/src/libcoretest/num/i32.rs @@ -8,4 +8,4 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -int_module!(i32, i32) +int_module!(i32, i32); diff --git a/src/libcoretest/num/i64.rs b/src/libcoretest/num/i64.rs index 075b8448f35..9e1aec256ee 100644 --- a/src/libcoretest/num/i64.rs +++ b/src/libcoretest/num/i64.rs @@ -8,4 +8,4 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -int_module!(i64, i64) +int_module!(i64, i64); diff --git a/src/libcoretest/num/i8.rs b/src/libcoretest/num/i8.rs index 9e0439f2818..f72244239b2 100644 --- a/src/libcoretest/num/i8.rs +++ b/src/libcoretest/num/i8.rs @@ -8,4 +8,4 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -int_module!(i8, i8) +int_module!(i8, i8); diff --git a/src/libcoretest/num/int.rs b/src/libcoretest/num/int.rs index f01ec3f0310..be8dfd02ee1 100644 --- a/src/libcoretest/num/int.rs +++ b/src/libcoretest/num/int.rs @@ -8,4 +8,4 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -int_module!(int, int) +int_module!(int, int); diff --git a/src/libcoretest/num/int_macros.rs b/src/libcoretest/num/int_macros.rs index 87e2fe75299..55e0f10c865 100644 --- a/src/libcoretest/num/int_macros.rs +++ b/src/libcoretest/num/int_macros.rs @@ -202,4 +202,4 @@ mod tests { } } -)) +)); diff --git a/src/libcoretest/num/mod.rs b/src/libcoretest/num/mod.rs index b7f8b81f996..acc593d7be9 100644 --- a/src/libcoretest/num/mod.rs +++ b/src/libcoretest/num/mod.rs @@ -62,9 +62,9 @@ mod test { let s : Option<i16> = from_str_radix("80000", 10); assert_eq!(s, None); let f : Option<f32> = from_str_radix("10000000000000000000000000000000000000000", 10); - assert_eq!(f, Some(Float::infinity())) + assert_eq!(f, Some(Float::infinity())); let fe : Option<f32> = from_str_radix("1e40", 10); - assert_eq!(fe, Some(Float::infinity())) + assert_eq!(fe, Some(Float::infinity())); } #[test] diff --git a/src/libcoretest/num/u16.rs b/src/libcoretest/num/u16.rs index d6aa6476678..8455207583c 100644 --- a/src/libcoretest/num/u16.rs +++ b/src/libcoretest/num/u16.rs @@ -8,4 +8,4 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -uint_module!(u16, u16) +uint_module!(u16, u16); diff --git a/src/libcoretest/num/u32.rs b/src/libcoretest/num/u32.rs index 218e79df5ae..b44e60f6529 100644 --- a/src/libcoretest/num/u32.rs +++ b/src/libcoretest/num/u32.rs @@ -8,4 +8,4 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -uint_module!(u32, u32) +uint_module!(u32, u32); diff --git a/src/libcoretest/num/u64.rs b/src/libcoretest/num/u64.rs index f78d4813503..ffcd1015d58 100644 --- a/src/libcoretest/num/u64.rs +++ b/src/libcoretest/num/u64.rs @@ -8,4 +8,4 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -uint_module!(u64, u64) +uint_module!(u64, u64); diff --git a/src/libcoretest/num/u8.rs b/src/libcoretest/num/u8.rs index bb08072320b..4ee14e22f2d 100644 --- a/src/libcoretest/num/u8.rs +++ b/src/libcoretest/num/u8.rs @@ -8,4 +8,4 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -uint_module!(u8, u8) +uint_module!(u8, u8); diff --git a/src/libcoretest/num/uint.rs b/src/libcoretest/num/uint.rs index 0db865f4cde..395e55cf255 100644 --- a/src/libcoretest/num/uint.rs +++ b/src/libcoretest/num/uint.rs @@ -8,4 +8,4 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -uint_module!(uint, uint) +uint_module!(uint, uint); diff --git a/src/libcoretest/num/uint_macros.rs b/src/libcoretest/num/uint_macros.rs index 5657a43de19..b21ac11e6a0 100644 --- a/src/libcoretest/num/uint_macros.rs +++ b/src/libcoretest/num/uint_macros.rs @@ -124,4 +124,4 @@ mod tests { assert!(5u.checked_div(0) == None); } } -)) +)); diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index 976b9bcf37e..257ce79b588 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -213,9 +213,11 @@ pub const WARN: u32 = 2; /// Error log level pub const ERROR: u32 = 1; -thread_local!(static LOCAL_LOGGER: RefCell<Option<Box<Logger + Send>>> = { - RefCell::new(None) -}) +thread_local! { + static LOCAL_LOGGER: RefCell<Option<Box<Logger + Send>>> = { + RefCell::new(None) + } +} /// A trait used to represent an interface to a task-local logger. Each task /// can have its own custom logger which can respond to logging messages diff --git a/src/liblog/macros.rs b/src/liblog/macros.rs index 4f8837083ae..8b2cfcd420a 100644 --- a/src/liblog/macros.rs +++ b/src/liblog/macros.rs @@ -51,7 +51,7 @@ /// 6:main: this is a custom logging level: 6 /// ``` #[macro_export] -macro_rules! log( +macro_rules! log { ($lvl:expr, $($arg:tt)+) => ({ static LOC: ::log::LogLocation = ::log::LogLocation { line: line!(), @@ -63,7 +63,7 @@ macro_rules! log( format_args!(|args| { ::log::log(lvl, &LOC, args) }, $($arg)+) } }) -) +} /// A convenience macro for logging at the error log level. /// @@ -87,9 +87,9 @@ macro_rules! log( /// ``` /// #[macro_export] -macro_rules! error( +macro_rules! error { ($($arg:tt)*) => (log!(::log::ERROR, $($arg)*)) -) +} /// A convenience macro for logging at the warning log level. /// @@ -112,9 +112,9 @@ macro_rules! error( /// WARN:main: you may like to know that a process exited with: 3 /// ``` #[macro_export] -macro_rules! warn( +macro_rules! warn { ($($arg:tt)*) => (log!(::log::WARN, $($arg)*)) -) +} /// A convenience macro for logging at the info log level. /// @@ -137,9 +137,9 @@ macro_rules! warn( /// INFO:main: this function is about to return: 3 /// ``` #[macro_export] -macro_rules! info( +macro_rules! info { ($($arg:tt)*) => (log!(::log::INFO, $($arg)*)) -) +} /// A convenience macro for logging at the debug log level. This macro can also /// be omitted at compile time by passing `--cfg ndebug` to the compiler. If @@ -163,9 +163,9 @@ macro_rules! info( /// DEBUG:main: x = 10, y = 20 /// ``` #[macro_export] -macro_rules! debug( +macro_rules! debug { ($($arg:tt)*) => (if cfg!(not(ndebug)) { log!(::log::DEBUG, $($arg)*) }) -) +} /// A macro to test whether a log level is enabled for the current module. /// @@ -197,11 +197,12 @@ macro_rules! debug( /// DEBUG:main: x.x = 1, x.y = 2 /// ``` #[macro_export] -macro_rules! log_enabled( +macro_rules! log_enabled { ($lvl:expr) => ({ let lvl = $lvl; (lvl != ::log::DEBUG || cfg!(not(ndebug))) && lvl <= ::log::log_level() && ::log::mod_enabled(lvl, module_path!()) }) -) +} + diff --git a/src/librand/isaac.rs b/src/librand/isaac.rs index 2c1853b1951..2499d7f529f 100644 --- a/src/librand/isaac.rs +++ b/src/librand/isaac.rs @@ -434,7 +434,7 @@ impl Rng for Isaac64Rng { // See corresponding location in IsaacRng.next_u32 for // explanation. - debug_assert!(self.cnt < RAND_SIZE_64) + debug_assert!(self.cnt < RAND_SIZE_64); self.rsl[(self.cnt % RAND_SIZE_64) as uint] } } diff --git a/src/librand/rand_impls.rs b/src/librand/rand_impls.rs index 96f40bcc156..3b38fde3884 100644 --- a/src/librand/rand_impls.rs +++ b/src/librand/rand_impls.rs @@ -232,8 +232,8 @@ mod tests { #[test] fn floating_point_edge_cases() { // the test for exact equality is correct here. - assert!(ConstantRng(0xffff_ffff).gen::<f32>() != 1.0) - assert!(ConstantRng(0xffff_ffff_ffff_ffff).gen::<f64>() != 1.0) + assert!(ConstantRng(0xffff_ffff).gen::<f32>() != 1.0); + assert!(ConstantRng(0xffff_ffff_ffff_ffff).gen::<f64>() != 1.0); } #[test] diff --git a/src/librbml/lib.rs b/src/librbml/lib.rs index bbedbc75395..bb7af92eb54 100644 --- a/src/librbml/lib.rs +++ b/src/librbml/lib.rs @@ -139,7 +139,7 @@ pub mod reader { pub type DecodeResult<T> = Result<T, Error>; // rbml reading - macro_rules! try_or( + macro_rules! try_or { ($e:expr, $r:expr) => ( match $e { Ok(e) => e, @@ -149,7 +149,7 @@ pub mod reader { } } ) - ) + } pub struct Res { pub val: uint, diff --git a/src/libregex/parse.rs b/src/libregex/parse.rs index f9ae4d2591a..60cf45aeddc 100644 --- a/src/libregex/parse.rs +++ b/src/libregex/parse.rs @@ -224,7 +224,7 @@ impl<'a> Parser<'a> { }, '(' => { if self.peek_is(1, '?') { - try!(self.expect('?')) + try!(self.expect('?')); try!(self.parse_group_opts()) } else { self.caps += 1; @@ -373,7 +373,7 @@ impl<'a> Parser<'a> { fn parse_class(&mut self) -> Result<(), Error> { let negated = if self.peek_is(1, '^') { - try!(self.expect('^')) + try!(self.expect('^')); FLAG_NEGATED } else { FLAG_EMPTY @@ -597,7 +597,7 @@ impl<'a> Parser<'a> { // Parses all escape sequences. // Assumes that '\' is the current character. fn parse_escape(&mut self) -> Result<Ast, Error> { - try!(self.noteof("an escape sequence following a '\\'")) + try!(self.noteof("an escape sequence following a '\\'")); let c = self.cur(); if is_punct(c) { @@ -639,7 +639,7 @@ impl<'a> Parser<'a> { let negated = if self.cur() == 'P' { FLAG_NEGATED } else { FLAG_EMPTY }; let mut name: String; if self.peek_is(1, '{') { - try!(self.expect('{')) + try!(self.expect('{')); let closer = match self.pos('}') { Some(i) => i, @@ -677,10 +677,10 @@ impl<'a> Parser<'a> { let mut end = start + 1; let (d2, d3) = (self.peek(1), self.peek(2)); if d2 >= Some('0') && d2 <= Some('7') { - try!(self.noteof("expected octal character in [0-7]")) + try!(self.noteof("expected octal character in [0-7]")); end += 1; if d3 >= Some('0') && d3 <= Some('7') { - try!(self.noteof("expected octal character in [0-7]")) + try!(self.noteof("expected octal character in [0-7]")); end += 1; } } @@ -698,7 +698,7 @@ impl<'a> Parser<'a> { // Assumes that \x has been read. fn parse_hex(&mut self) -> Result<Ast, Error> { if !self.peek_is(1, '{') { - try!(self.expect('{')) + try!(self.expect('{')); return self.parse_hex_two() } let start = self.chari + 2; @@ -723,7 +723,7 @@ impl<'a> Parser<'a> { let (start, end) = (self.chari, self.chari + 2); let bad = self.slice(start - 2, self.chars.len()); try!(self.noteof(format!("Invalid hex escape sequence '{}'", - bad).as_slice())) + bad).as_slice())); self.parse_hex_digits(self.slice(start, end).as_slice()) } @@ -743,7 +743,7 @@ impl<'a> Parser<'a> { // is '<'. // When done, parser will be at the closing '>' character. fn parse_named_capture(&mut self) -> Result<(), Error> { - try!(self.noteof("a capture name")) + try!(self.noteof("a capture name")); let closer = match self.pos('>') { Some(i) => i, @@ -773,7 +773,8 @@ impl<'a> Parser<'a> { // character. fn parse_group_opts(&mut self) -> Result<(), Error> { if self.peek_is(1, 'P') && self.peek_is(2, '<') { - try!(self.expect('P')) try!(self.expect('<')) + try!(self.expect('P')); + try!(self.expect('<')); return self.parse_named_capture() } let start = self.chari; @@ -781,7 +782,8 @@ impl<'a> Parser<'a> { let mut sign = 1i; let mut saw_flag = false; loop { - try!(self.noteof("expected non-empty set of flags or closing ')'")) + try!(self.noteof( + "expected non-empty set of flags or closing ')'")); match self.cur() { 'i' => { flags = flags | FLAG_NOCASE; saw_flag = true}, 'm' => { flags = flags | FLAG_MULTI; saw_flag = true}, @@ -823,7 +825,7 @@ impl<'a> Parser<'a> { // If it is, then the next character is consumed. fn get_next_greedy(&mut self) -> Result<Greed, Error> { Ok(if self.peek_is(1, '?') { - try!(self.expect('?')) + try!(self.expect('?')); Ungreedy } else { Greedy diff --git a/src/libregex/test/bench.rs b/src/libregex/test/bench.rs index e1c24a902fa..0c204f759e6 100644 --- a/src/libregex/test/bench.rs +++ b/src/libregex/test/bench.rs @@ -137,7 +137,7 @@ fn one_pass_long_prefix_not(b: &mut Bencher) { b.iter(|| re.is_match(text)); } -macro_rules! throughput( +macro_rules! throughput { ($name:ident, $regex:expr, $size:expr) => ( #[bench] fn $name(b: &mut Bencher) { @@ -146,7 +146,7 @@ macro_rules! throughput( b.iter(|| if $regex.is_match(text.as_slice()) { panic!("match") }); } ); -) +} fn easy0() -> Regex { regex!("ABCDEFGHIJKLMNOPQRSTUVWXYZ$") } fn easy1() -> Regex { regex!("A[AB]B[BC]C[CD]D[DE]E[EF]F[FG]G[GH]H[HI]I[IJ]J$") } @@ -165,18 +165,18 @@ fn gen_text(n: uint) -> String { String::from_utf8(bytes).unwrap() } -throughput!(easy0_32, easy0(), 32) -throughput!(easy0_1K, easy0(), 1<<10) -throughput!(easy0_32K, easy0(), 32<<10) +throughput!{easy0_32, easy0(), 32} +throughput!{easy0_1K, easy0(), 1<<10} +throughput!{easy0_32K, easy0(), 32<<10} -throughput!(easy1_32, easy1(), 32) -throughput!(easy1_1K, easy1(), 1<<10) -throughput!(easy1_32K, easy1(), 32<<10) +throughput!{easy1_32, easy1(), 32} +throughput!{easy1_1K, easy1(), 1<<10} +throughput!{easy1_32K, easy1(), 32<<10} -throughput!(medium_32, medium(), 32) -throughput!(medium_1K, medium(), 1<<10) -throughput!(medium_32K,medium(), 32<<10) +throughput!{medium_32, medium(), 32} +throughput!{medium_1K, medium(), 1<<10} +throughput!{medium_32K,medium(), 32<<10} -throughput!(hard_32, hard(), 32) -throughput!(hard_1K, hard(), 1<<10) -throughput!(hard_32K,hard(), 32<<10) +throughput!{hard_32, hard(), 32} +throughput!{hard_1K, hard(), 1<<10} +throughput!{hard_32K,hard(), 32<<10} diff --git a/src/libregex/test/matches.rs b/src/libregex/test/matches.rs index fb938513cb1..7508f4c50a2 100644 --- a/src/libregex/test/matches.rs +++ b/src/libregex/test/matches.rs @@ -14,360 +14,360 @@ // on 2014-04-23 01:33:36.539280. // Tests from basic.dat -mat!(match_basic_3, r"abracadabra$", r"abracadabracadabra", Some((7, 18))) -mat!(match_basic_4, r"a...b", r"abababbb", Some((2, 7))) -mat!(match_basic_5, r"XXXXXX", r"..XXXXXX", Some((2, 8))) -mat!(match_basic_6, r"\)", r"()", Some((1, 2))) -mat!(match_basic_7, r"a]", r"a]a", Some((0, 2))) -mat!(match_basic_9, r"\}", r"}", Some((0, 1))) -mat!(match_basic_10, r"\]", r"]", Some((0, 1))) -mat!(match_basic_12, r"]", r"]", Some((0, 1))) -mat!(match_basic_15, r"^a", r"ax", Some((0, 1))) -mat!(match_basic_16, r"\^a", r"a^a", Some((1, 3))) -mat!(match_basic_17, r"a\^", r"a^", Some((0, 2))) -mat!(match_basic_18, r"a$", r"aa", Some((1, 2))) -mat!(match_basic_19, r"a\$", r"a$", Some((0, 2))) -mat!(match_basic_20, r"^$", r"", Some((0, 0))) -mat!(match_basic_21, r"$^", r"", Some((0, 0))) -mat!(match_basic_22, r"a($)", r"aa", Some((1, 2)), Some((2, 2))) -mat!(match_basic_23, r"a*(^a)", r"aa", Some((0, 1)), Some((0, 1))) -mat!(match_basic_24, r"(..)*(...)*", r"a", Some((0, 0))) -mat!(match_basic_25, r"(..)*(...)*", r"abcd", Some((0, 4)), Some((2, 4))) -mat!(match_basic_26, r"(ab|a)(bc|c)", r"abc", Some((0, 3)), Some((0, 2)), Some((2, 3))) -mat!(match_basic_27, r"(ab)c|abc", r"abc", Some((0, 3)), Some((0, 2))) -mat!(match_basic_28, r"a{0}b", r"ab", Some((1, 2))) -mat!(match_basic_29, r"(a*)(b?)(b+)b{3}", r"aaabbbbbbb", Some((0, 10)), Some((0, 3)), Some((3, 4)), Some((4, 7))) -mat!(match_basic_30, r"(a*)(b{0,1})(b{1,})b{3}", r"aaabbbbbbb", Some((0, 10)), Some((0, 3)), Some((3, 4)), Some((4, 7))) -mat!(match_basic_32, r"((a|a)|a)", r"a", Some((0, 1)), Some((0, 1)), Some((0, 1))) -mat!(match_basic_33, r"(a*)(a|aa)", r"aaaa", Some((0, 4)), Some((0, 3)), Some((3, 4))) -mat!(match_basic_34, r"a*(a.|aa)", r"aaaa", Some((0, 4)), Some((2, 4))) -mat!(match_basic_35, r"a(b)|c(d)|a(e)f", r"aef", Some((0, 3)), None, None, Some((1, 2))) -mat!(match_basic_36, r"(a|b)?.*", r"b", Some((0, 1)), Some((0, 1))) -mat!(match_basic_37, r"(a|b)c|a(b|c)", r"ac", Some((0, 2)), Some((0, 1))) -mat!(match_basic_38, r"(a|b)c|a(b|c)", r"ab", Some((0, 2)), None, Some((1, 2))) -mat!(match_basic_39, r"(a|b)*c|(a|ab)*c", r"abc", Some((0, 3)), Some((1, 2))) -mat!(match_basic_40, r"(a|b)*c|(a|ab)*c", r"xc", Some((1, 2))) -mat!(match_basic_41, r"(.a|.b).*|.*(.a|.b)", r"xa", Some((0, 2)), Some((0, 2))) -mat!(match_basic_42, r"a?(ab|ba)ab", r"abab", Some((0, 4)), Some((0, 2))) -mat!(match_basic_43, r"a?(ac{0}b|ba)ab", r"abab", Some((0, 4)), Some((0, 2))) -mat!(match_basic_44, r"ab|abab", r"abbabab", Some((0, 2))) -mat!(match_basic_45, r"aba|bab|bba", r"baaabbbaba", Some((5, 8))) -mat!(match_basic_46, r"aba|bab", r"baaabbbaba", Some((6, 9))) -mat!(match_basic_47, r"(aa|aaa)*|(a|aaaaa)", r"aa", Some((0, 2)), Some((0, 2))) -mat!(match_basic_48, r"(a.|.a.)*|(a|.a...)", r"aa", Some((0, 2)), Some((0, 2))) -mat!(match_basic_49, r"ab|a", r"xabc", Some((1, 3))) -mat!(match_basic_50, r"ab|a", r"xxabc", Some((2, 4))) -mat!(match_basic_51, r"(?i)(Ab|cD)*", r"aBcD", Some((0, 4)), Some((2, 4))) -mat!(match_basic_52, r"[^-]", r"--a", Some((2, 3))) -mat!(match_basic_53, r"[a-]*", r"--a", Some((0, 3))) -mat!(match_basic_54, r"[a-m-]*", r"--amoma--", Some((0, 4))) -mat!(match_basic_55, r":::1:::0:|:::1:1:0:", r":::0:::1:::1:::0:", Some((8, 17))) -mat!(match_basic_56, r":::1:::0:|:::1:1:1:", r":::0:::1:::1:::0:", Some((8, 17))) -mat!(match_basic_57, r"[[:upper:]]", r"A", Some((0, 1))) -mat!(match_basic_58, r"[[:lower:]]+", r"`az{", Some((1, 3))) -mat!(match_basic_59, r"[[:upper:]]+", r"@AZ[", Some((1, 3))) -mat!(match_basic_65, r" +mat!{match_basic_3, r"abracadabra$", r"abracadabracadabra", Some((7, 18))} +mat!{match_basic_4, r"a...b", r"abababbb", Some((2, 7))} +mat!{match_basic_5, r"XXXXXX", r"..XXXXXX", Some((2, 8))} +mat!{match_basic_6, r"\)", r"()", Some((1, 2))} +mat!{match_basic_7, r"a]", r"a]a", Some((0, 2))} +mat!{match_basic_9, r"\}", r"}", Some((0, 1))} +mat!{match_basic_10, r"\]", r"]", Some((0, 1))} +mat!{match_basic_12, r"]", r"]", Some((0, 1))} +mat!{match_basic_15, r"^a", r"ax", Some((0, 1))} +mat!{match_basic_16, r"\^a", r"a^a", Some((1, 3))} +mat!{match_basic_17, r"a\^", r"a^", Some((0, 2))} +mat!{match_basic_18, r"a$", r"aa", Some((1, 2))} +mat!{match_basic_19, r"a\$", r"a$", Some((0, 2))} +mat!{match_basic_20, r"^$", r"", Some((0, 0))} +mat!{match_basic_21, r"$^", r"", Some((0, 0))} +mat!{match_basic_22, r"a($)", r"aa", Some((1, 2)), Some((2, 2))} +mat!{match_basic_23, r"a*(^a)", r"aa", Some((0, 1)), Some((0, 1))} +mat!{match_basic_24, r"(..)*(...)*", r"a", Some((0, 0))} +mat!{match_basic_25, r"(..)*(...)*", r"abcd", Some((0, 4)), Some((2, 4))} +mat!{match_basic_26, r"(ab|a)(bc|c)", r"abc", Some((0, 3)), Some((0, 2)), Some((2, 3))} +mat!{match_basic_27, r"(ab)c|abc", r"abc", Some((0, 3)), Some((0, 2))} +mat!{match_basic_28, r"a{0}b", r"ab", Some((1, 2))} +mat!{match_basic_29, r"(a*)(b?)(b+)b{3}", r"aaabbbbbbb", Some((0, 10)), Some((0, 3)), Some((3, 4)), Some((4, 7))} +mat!{match_basic_30, r"(a*)(b{0,1})(b{1,})b{3}", r"aaabbbbbbb", Some((0, 10)), Some((0, 3)), Some((3, 4)), Some((4, 7))} +mat!{match_basic_32, r"((a|a)|a)", r"a", Some((0, 1)), Some((0, 1)), Some((0, 1))} +mat!{match_basic_33, r"(a*)(a|aa)", r"aaaa", Some((0, 4)), Some((0, 3)), Some((3, 4))} +mat!{match_basic_34, r"a*(a.|aa)", r"aaaa", Some((0, 4)), Some((2, 4))} +mat!{match_basic_35, r"a(b)|c(d)|a(e)f", r"aef", Some((0, 3)), None, None, Some((1, 2))} +mat!{match_basic_36, r"(a|b)?.*", r"b", Some((0, 1)), Some((0, 1))} +mat!{match_basic_37, r"(a|b)c|a(b|c)", r"ac", Some((0, 2)), Some((0, 1))} +mat!{match_basic_38, r"(a|b)c|a(b|c)", r"ab", Some((0, 2)), None, Some((1, 2))} +mat!{match_basic_39, r"(a|b)*c|(a|ab)*c", r"abc", Some((0, 3)), Some((1, 2))} +mat!{match_basic_40, r"(a|b)*c|(a|ab)*c", r"xc", Some((1, 2))} +mat!{match_basic_41, r"(.a|.b).*|.*(.a|.b)", r"xa", Some((0, 2)), Some((0, 2))} +mat!{match_basic_42, r"a?(ab|ba)ab", r"abab", Some((0, 4)), Some((0, 2))} +mat!{match_basic_43, r"a?(ac{0}b|ba)ab", r"abab", Some((0, 4)), Some((0, 2))} +mat!{match_basic_44, r"ab|abab", r"abbabab", Some((0, 2))} +mat!{match_basic_45, r"aba|bab|bba", r"baaabbbaba", Some((5, 8))} +mat!{match_basic_46, r"aba|bab", r"baaabbbaba", Some((6, 9))} +mat!{match_basic_47, r"(aa|aaa)*|(a|aaaaa)", r"aa", Some((0, 2)), Some((0, 2))} +mat!{match_basic_48, r"(a.|.a.)*|(a|.a...)", r"aa", Some((0, 2)), Some((0, 2))} +mat!{match_basic_49, r"ab|a", r"xabc", Some((1, 3))} +mat!{match_basic_50, r"ab|a", r"xxabc", Some((2, 4))} +mat!{match_basic_51, r"(?i)(Ab|cD)*", r"aBcD", Some((0, 4)), Some((2, 4))} +mat!{match_basic_52, r"[^-]", r"--a", Some((2, 3))} +mat!{match_basic_53, r"[a-]*", r"--a", Some((0, 3))} +mat!{match_basic_54, r"[a-m-]*", r"--amoma--", Some((0, 4))} +mat!{match_basic_55, r":::1:::0:|:::1:1:0:", r":::0:::1:::1:::0:", Some((8, 17))} +mat!{match_basic_56, r":::1:::0:|:::1:1:1:", r":::0:::1:::1:::0:", Some((8, 17))} +mat!{match_basic_57, r"[[:upper:]]", r"A", Some((0, 1))} +mat!{match_basic_58, r"[[:lower:]]+", r"`az{", Some((1, 3))} +mat!{match_basic_59, r"[[:upper:]]+", r"@AZ[", Some((1, 3))} +mat!{match_basic_65, r" ", r" -", Some((0, 1))) -mat!(match_basic_66, r" +", Some((0, 1))} +mat!{match_basic_66, r" ", r" -", Some((0, 1))) -mat!(match_basic_67, r"[^a]", r" -", Some((0, 1))) -mat!(match_basic_68, r" +", Some((0, 1))} +mat!{match_basic_67, r"[^a]", r" +", Some((0, 1))} +mat!{match_basic_68, r" a", r" -a", Some((0, 2))) -mat!(match_basic_69, r"(a)(b)(c)", r"abc", Some((0, 3)), Some((0, 1)), Some((1, 2)), Some((2, 3))) -mat!(match_basic_70, r"xxx", r"xxx", Some((0, 3))) -mat!(match_basic_71, r"(^|[ (,;])((([Ff]eb[^ ]* *|0*2/|\* */?)0*[6-7]))([^0-9]|$)", r"feb 6,", Some((0, 6))) -mat!(match_basic_72, r"(^|[ (,;])((([Ff]eb[^ ]* *|0*2/|\* */?)0*[6-7]))([^0-9]|$)", r"2/7", Some((0, 3))) -mat!(match_basic_73, r"(^|[ (,;])((([Ff]eb[^ ]* *|0*2/|\* */?)0*[6-7]))([^0-9]|$)", r"feb 1,Feb 6", Some((5, 11))) -mat!(match_basic_74, r"((((((((((((((((((((((((((((((x))))))))))))))))))))))))))))))", r"x", Some((0, 1)), Some((0, 1)), Some((0, 1))) -mat!(match_basic_75, r"((((((((((((((((((((((((((((((x))))))))))))))))))))))))))))))*", r"xx", Some((0, 2)), Some((1, 2)), Some((1, 2))) -mat!(match_basic_76, r"a?(ab|ba)*", r"ababababababababababababababababababababababababababababababababababababababababa", Some((0, 81)), Some((79, 81))) -mat!(match_basic_77, r"abaa|abbaa|abbbaa|abbbbaa", r"ababbabbbabbbabbbbabbbbaa", Some((18, 25))) -mat!(match_basic_78, r"abaa|abbaa|abbbaa|abbbbaa", r"ababbabbbabbbabbbbabaa", Some((18, 22))) -mat!(match_basic_79, r"aaac|aabc|abac|abbc|baac|babc|bbac|bbbc", r"baaabbbabac", Some((7, 11))) -mat!(match_basic_80, r".*", r"", Some((0, 2))) -mat!(match_basic_81, r"aaaa|bbbb|cccc|ddddd|eeeeee|fffffff|gggg|hhhh|iiiii|jjjjj|kkkkk|llll", r"XaaaXbbbXcccXdddXeeeXfffXgggXhhhXiiiXjjjXkkkXlllXcbaXaaaa", Some((53, 57))) -mat!(match_basic_83, r"a*a*a*a*a*b", r"aaaaaaaaab", Some((0, 10))) -mat!(match_basic_84, r"^", r"", Some((0, 0))) -mat!(match_basic_85, r"$", r"", Some((0, 0))) -mat!(match_basic_86, r"^$", r"", Some((0, 0))) -mat!(match_basic_87, r"^a$", r"a", Some((0, 1))) -mat!(match_basic_88, r"abc", r"abc", Some((0, 3))) -mat!(match_basic_89, r"abc", r"xabcy", Some((1, 4))) -mat!(match_basic_90, r"abc", r"ababc", Some((2, 5))) -mat!(match_basic_91, r"ab*c", r"abc", Some((0, 3))) -mat!(match_basic_92, r"ab*bc", r"abc", Some((0, 3))) -mat!(match_basic_93, r"ab*bc", r"abbc", Some((0, 4))) -mat!(match_basic_94, r"ab*bc", r"abbbbc", Some((0, 6))) -mat!(match_basic_95, r"ab+bc", r"abbc", Some((0, 4))) -mat!(match_basic_96, r"ab+bc", r"abbbbc", Some((0, 6))) -mat!(match_basic_97, r"ab?bc", r"abbc", Some((0, 4))) -mat!(match_basic_98, r"ab?bc", r"abc", Some((0, 3))) -mat!(match_basic_99, r"ab?c", r"abc", Some((0, 3))) -mat!(match_basic_100, r"^abc$", r"abc", Some((0, 3))) -mat!(match_basic_101, r"^abc", r"abcc", Some((0, 3))) -mat!(match_basic_102, r"abc$", r"aabc", Some((1, 4))) -mat!(match_basic_103, r"^", r"abc", Some((0, 0))) -mat!(match_basic_104, r"$", r"abc", Some((3, 3))) -mat!(match_basic_105, r"a.c", r"abc", Some((0, 3))) -mat!(match_basic_106, r"a.c", r"axc", Some((0, 3))) -mat!(match_basic_107, r"a.*c", r"axyzc", Some((0, 5))) -mat!(match_basic_108, r"a[bc]d", r"abd", Some((0, 3))) -mat!(match_basic_109, r"a[b-d]e", r"ace", Some((0, 3))) -mat!(match_basic_110, r"a[b-d]", r"aac", Some((1, 3))) -mat!(match_basic_111, r"a[-b]", r"a-", Some((0, 2))) -mat!(match_basic_112, r"a[b-]", r"a-", Some((0, 2))) -mat!(match_basic_113, r"a]", r"a]", Some((0, 2))) -mat!(match_basic_114, r"a[]]b", r"a]b", Some((0, 3))) -mat!(match_basic_115, r"a[^bc]d", r"aed", Some((0, 3))) -mat!(match_basic_116, r"a[^-b]c", r"adc", Some((0, 3))) -mat!(match_basic_117, r"a[^]b]c", r"adc", Some((0, 3))) -mat!(match_basic_118, r"ab|cd", r"abc", Some((0, 2))) -mat!(match_basic_119, r"ab|cd", r"abcd", Some((0, 2))) -mat!(match_basic_120, r"a\(b", r"a(b", Some((0, 3))) -mat!(match_basic_121, r"a\(*b", r"ab", Some((0, 2))) -mat!(match_basic_122, r"a\(*b", r"a((b", Some((0, 4))) -mat!(match_basic_123, r"((a))", r"abc", Some((0, 1)), Some((0, 1)), Some((0, 1))) -mat!(match_basic_124, r"(a)b(c)", r"abc", Some((0, 3)), Some((0, 1)), Some((2, 3))) -mat!(match_basic_125, r"a+b+c", r"aabbabc", Some((4, 7))) -mat!(match_basic_126, r"a*", r"aaa", Some((0, 3))) -mat!(match_basic_128, r"(a*)*", r"-", Some((0, 0)), None) -mat!(match_basic_129, r"(a*)+", r"-", Some((0, 0)), Some((0, 0))) -mat!(match_basic_131, r"(a*|b)*", r"-", Some((0, 0)), None) -mat!(match_basic_132, r"(a+|b)*", r"ab", Some((0, 2)), Some((1, 2))) -mat!(match_basic_133, r"(a+|b)+", r"ab", Some((0, 2)), Some((1, 2))) -mat!(match_basic_134, r"(a+|b)?", r"ab", Some((0, 1)), Some((0, 1))) -mat!(match_basic_135, r"[^ab]*", r"cde", Some((0, 3))) -mat!(match_basic_137, r"(^)*", r"-", Some((0, 0)), None) -mat!(match_basic_138, r"a*", r"", Some((0, 0))) -mat!(match_basic_139, r"([abc])*d", r"abbbcd", Some((0, 6)), Some((4, 5))) -mat!(match_basic_140, r"([abc])*bcd", r"abcd", Some((0, 4)), Some((0, 1))) -mat!(match_basic_141, r"a|b|c|d|e", r"e", Some((0, 1))) -mat!(match_basic_142, r"(a|b|c|d|e)f", r"ef", Some((0, 2)), Some((0, 1))) -mat!(match_basic_144, r"((a*|b))*", r"-", Some((0, 0)), None, None) -mat!(match_basic_145, r"abcd*efg", r"abcdefg", Some((0, 7))) -mat!(match_basic_146, r"ab*", r"xabyabbbz", Some((1, 3))) -mat!(match_basic_147, r"ab*", r"xayabbbz", Some((1, 2))) -mat!(match_basic_148, r"(ab|cd)e", r"abcde", Some((2, 5)), Some((2, 4))) -mat!(match_basic_149, r"[abhgefdc]ij", r"hij", Some((0, 3))) -mat!(match_basic_150, r"(a|b)c*d", r"abcd", Some((1, 4)), Some((1, 2))) -mat!(match_basic_151, r"(ab|ab*)bc", r"abc", Some((0, 3)), Some((0, 1))) -mat!(match_basic_152, r"a([bc]*)c*", r"abc", Some((0, 3)), Some((1, 3))) -mat!(match_basic_153, r"a([bc]*)(c*d)", r"abcd", Some((0, 4)), Some((1, 3)), Some((3, 4))) -mat!(match_basic_154, r"a([bc]+)(c*d)", r"abcd", Some((0, 4)), Some((1, 3)), Some((3, 4))) -mat!(match_basic_155, r"a([bc]*)(c+d)", r"abcd", Some((0, 4)), Some((1, 2)), Some((2, 4))) -mat!(match_basic_156, r"a[bcd]*dcdcde", r"adcdcde", Some((0, 7))) -mat!(match_basic_157, r"(ab|a)b*c", r"abc", Some((0, 3)), Some((0, 2))) -mat!(match_basic_158, r"((a)(b)c)(d)", r"abcd", Some((0, 4)), Some((0, 3)), Some((0, 1)), Some((1, 2)), Some((3, 4))) -mat!(match_basic_159, r"[A-Za-z_][A-Za-z0-9_]*", r"alpha", Some((0, 5))) -mat!(match_basic_160, r"^a(bc+|b[eh])g|.h$", r"abh", Some((1, 3))) -mat!(match_basic_161, r"(bc+d$|ef*g.|h?i(j|k))", r"effgz", Some((0, 5)), Some((0, 5))) -mat!(match_basic_162, r"(bc+d$|ef*g.|h?i(j|k))", r"ij", Some((0, 2)), Some((0, 2)), Some((1, 2))) -mat!(match_basic_163, r"(bc+d$|ef*g.|h?i(j|k))", r"reffgz", Some((1, 6)), Some((1, 6))) -mat!(match_basic_164, r"(((((((((a)))))))))", r"a", Some((0, 1)), Some((0, 1)), Some((0, 1)), Some((0, 1)), Some((0, 1)), Some((0, 1)), Some((0, 1)), Some((0, 1)), Some((0, 1)), Some((0, 1))) -mat!(match_basic_165, r"multiple words", r"multiple words yeah", Some((0, 14))) -mat!(match_basic_166, r"(.*)c(.*)", r"abcde", Some((0, 5)), Some((0, 2)), Some((3, 5))) -mat!(match_basic_167, r"abcd", r"abcd", Some((0, 4))) -mat!(match_basic_168, r"a(bc)d", r"abcd", Some((0, 4)), Some((1, 3))) -mat!(match_basic_169, r"a[-]?c", r"ac", Some((0, 3))) -mat!(match_basic_170, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Muammar Qaddafi", Some((0, 15)), None, Some((10, 12))) -mat!(match_basic_171, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Mo'ammar Gadhafi", Some((0, 16)), None, Some((11, 13))) -mat!(match_basic_172, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Muammar Kaddafi", Some((0, 15)), None, Some((10, 12))) -mat!(match_basic_173, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Muammar Qadhafi", Some((0, 15)), None, Some((10, 12))) -mat!(match_basic_174, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Muammar Gadafi", Some((0, 14)), None, Some((10, 11))) -mat!(match_basic_175, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Mu'ammar Qadafi", Some((0, 15)), None, Some((11, 12))) -mat!(match_basic_176, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Moamar Gaddafi", Some((0, 14)), None, Some((9, 11))) -mat!(match_basic_177, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Mu'ammar Qadhdhafi", Some((0, 18)), None, Some((13, 15))) -mat!(match_basic_178, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Muammar Khaddafi", Some((0, 16)), None, Some((11, 13))) -mat!(match_basic_179, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Muammar Ghaddafy", Some((0, 16)), None, Some((11, 13))) -mat!(match_basic_180, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Muammar Ghadafi", Some((0, 15)), None, Some((11, 12))) -mat!(match_basic_181, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Muammar Ghaddafi", Some((0, 16)), None, Some((11, 13))) -mat!(match_basic_182, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Muamar Kaddafi", Some((0, 14)), None, Some((9, 11))) -mat!(match_basic_183, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Muammar Quathafi", Some((0, 16)), None, Some((11, 13))) -mat!(match_basic_184, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Muammar Gheddafi", Some((0, 16)), None, Some((11, 13))) -mat!(match_basic_185, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Moammar Khadafy", Some((0, 15)), None, Some((11, 12))) -mat!(match_basic_186, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Moammar Qudhafi", Some((0, 15)), None, Some((10, 12))) -mat!(match_basic_187, r"a+(b|c)*d+", r"aabcdd", Some((0, 6)), Some((3, 4))) -mat!(match_basic_188, r"^.+$", r"vivi", Some((0, 4))) -mat!(match_basic_189, r"^(.+)$", r"vivi", Some((0, 4)), Some((0, 4))) -mat!(match_basic_190, r"^([^!.]+).att.com!(.+)$", r"gryphon.att.com!eby", Some((0, 19)), Some((0, 7)), Some((16, 19))) -mat!(match_basic_191, r"^([^!]+!)?([^!]+)$", r"bas", Some((0, 3)), None, Some((0, 3))) -mat!(match_basic_192, r"^([^!]+!)?([^!]+)$", r"bar!bas", Some((0, 7)), Some((0, 4)), Some((4, 7))) -mat!(match_basic_193, r"^([^!]+!)?([^!]+)$", r"foo!bas", Some((0, 7)), Some((0, 4)), Some((4, 7))) -mat!(match_basic_194, r"^.+!([^!]+!)([^!]+)$", r"foo!bar!bas", Some((0, 11)), Some((4, 8)), Some((8, 11))) -mat!(match_basic_195, r"((foo)|(bar))!bas", r"bar!bas", Some((0, 7)), Some((0, 3)), None, Some((0, 3))) -mat!(match_basic_196, r"((foo)|(bar))!bas", r"foo!bar!bas", Some((4, 11)), Some((4, 7)), None, Some((4, 7))) -mat!(match_basic_197, r"((foo)|(bar))!bas", r"foo!bas", Some((0, 7)), Some((0, 3)), Some((0, 3))) -mat!(match_basic_198, r"((foo)|bar)!bas", r"bar!bas", Some((0, 7)), Some((0, 3))) -mat!(match_basic_199, r"((foo)|bar)!bas", r"foo!bar!bas", Some((4, 11)), Some((4, 7))) -mat!(match_basic_200, r"((foo)|bar)!bas", r"foo!bas", Some((0, 7)), Some((0, 3)), Some((0, 3))) -mat!(match_basic_201, r"(foo|(bar))!bas", r"bar!bas", Some((0, 7)), Some((0, 3)), Some((0, 3))) -mat!(match_basic_202, r"(foo|(bar))!bas", r"foo!bar!bas", Some((4, 11)), Some((4, 7)), Some((4, 7))) -mat!(match_basic_203, r"(foo|(bar))!bas", r"foo!bas", Some((0, 7)), Some((0, 3))) -mat!(match_basic_204, r"(foo|bar)!bas", r"bar!bas", Some((0, 7)), Some((0, 3))) -mat!(match_basic_205, r"(foo|bar)!bas", r"foo!bar!bas", Some((4, 11)), Some((4, 7))) -mat!(match_basic_206, r"(foo|bar)!bas", r"foo!bas", Some((0, 7)), Some((0, 3))) -mat!(match_basic_207, r"^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$", r"foo!bar!bas", Some((0, 11)), Some((0, 11)), None, None, Some((4, 8)), Some((8, 11))) -mat!(match_basic_208, r"^([^!]+!)?([^!]+)$|^.+!([^!]+!)([^!]+)$", r"bas", Some((0, 3)), None, Some((0, 3))) -mat!(match_basic_209, r"^([^!]+!)?([^!]+)$|^.+!([^!]+!)([^!]+)$", r"bar!bas", Some((0, 7)), Some((0, 4)), Some((4, 7))) -mat!(match_basic_210, r"^([^!]+!)?([^!]+)$|^.+!([^!]+!)([^!]+)$", r"foo!bar!bas", Some((0, 11)), None, None, Some((4, 8)), Some((8, 11))) -mat!(match_basic_211, r"^([^!]+!)?([^!]+)$|^.+!([^!]+!)([^!]+)$", r"foo!bas", Some((0, 7)), Some((0, 4)), Some((4, 7))) -mat!(match_basic_212, r"^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$", r"bas", Some((0, 3)), Some((0, 3)), None, Some((0, 3))) -mat!(match_basic_213, r"^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$", r"bar!bas", Some((0, 7)), Some((0, 7)), Some((0, 4)), Some((4, 7))) -mat!(match_basic_214, r"^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$", r"foo!bar!bas", Some((0, 11)), Some((0, 11)), None, None, Some((4, 8)), Some((8, 11))) -mat!(match_basic_215, r"^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$", r"foo!bas", Some((0, 7)), Some((0, 7)), Some((0, 4)), Some((4, 7))) -mat!(match_basic_216, r".*(/XXX).*", r"/XXX", Some((0, 4)), Some((0, 4))) -mat!(match_basic_217, r".*(\\XXX).*", r"\XXX", Some((0, 4)), Some((0, 4))) -mat!(match_basic_218, r"\\XXX", r"\XXX", Some((0, 4))) -mat!(match_basic_219, r".*(/000).*", r"/000", Some((0, 4)), Some((0, 4))) -mat!(match_basic_220, r".*(\\000).*", r"\000", Some((0, 4)), Some((0, 4))) -mat!(match_basic_221, r"\\000", r"\000", Some((0, 4))) +a", Some((0, 2))} +mat!{match_basic_69, r"(a)(b)(c)", r"abc", Some((0, 3)), Some((0, 1)), Some((1, 2)), Some((2, 3))} +mat!{match_basic_70, r"xxx", r"xxx", Some((0, 3))} +mat!{match_basic_71, r"(^|[ (,;])((([Ff]eb[^ ]* *|0*2/|\* */?)0*[6-7]))([^0-9]|$)", r"feb 6,", Some((0, 6))} +mat!{match_basic_72, r"(^|[ (,;])((([Ff]eb[^ ]* *|0*2/|\* */?)0*[6-7]))([^0-9]|$)", r"2/7", Some((0, 3))} +mat!{match_basic_73, r"(^|[ (,;])((([Ff]eb[^ ]* *|0*2/|\* */?)0*[6-7]))([^0-9]|$)", r"feb 1,Feb 6", Some((5, 11))} +mat!{match_basic_74, r"((((((((((((((((((((((((((((((x))))))))))))))))))))))))))))))", r"x", Some((0, 1)), Some((0, 1)), Some((0, 1))} +mat!{match_basic_75, r"((((((((((((((((((((((((((((((x))))))))))))))))))))))))))))))*", r"xx", Some((0, 2)), Some((1, 2)), Some((1, 2))} +mat!{match_basic_76, r"a?(ab|ba)*", r"ababababababababababababababababababababababababababababababababababababababababa", Some((0, 81)), Some((79, 81))} +mat!{match_basic_77, r"abaa|abbaa|abbbaa|abbbbaa", r"ababbabbbabbbabbbbabbbbaa", Some((18, 25))} +mat!{match_basic_78, r"abaa|abbaa|abbbaa|abbbbaa", r"ababbabbbabbbabbbbabaa", Some((18, 22))} +mat!{match_basic_79, r"aaac|aabc|abac|abbc|baac|babc|bbac|bbbc", r"baaabbbabac", Some((7, 11))} +mat!{match_basic_80, r".*", r"", Some((0, 2))} +mat!{match_basic_81, r"aaaa|bbbb|cccc|ddddd|eeeeee|fffffff|gggg|hhhh|iiiii|jjjjj|kkkkk|llll", r"XaaaXbbbXcccXdddXeeeXfffXgggXhhhXiiiXjjjXkkkXlllXcbaXaaaa", Some((53, 57))} +mat!{match_basic_83, r"a*a*a*a*a*b", r"aaaaaaaaab", Some((0, 10))} +mat!{match_basic_84, r"^", r"", Some((0, 0))} +mat!{match_basic_85, r"$", r"", Some((0, 0))} +mat!{match_basic_86, r"^$", r"", Some((0, 0))} +mat!{match_basic_87, r"^a$", r"a", Some((0, 1))} +mat!{match_basic_88, r"abc", r"abc", Some((0, 3))} +mat!{match_basic_89, r"abc", r"xabcy", Some((1, 4))} +mat!{match_basic_90, r"abc", r"ababc", Some((2, 5))} +mat!{match_basic_91, r"ab*c", r"abc", Some((0, 3))} +mat!{match_basic_92, r"ab*bc", r"abc", Some((0, 3))} +mat!{match_basic_93, r"ab*bc", r"abbc", Some((0, 4))} +mat!{match_basic_94, r"ab*bc", r"abbbbc", Some((0, 6))} +mat!{match_basic_95, r"ab+bc", r"abbc", Some((0, 4))} +mat!{match_basic_96, r"ab+bc", r"abbbbc", Some((0, 6))} +mat!{match_basic_97, r"ab?bc", r"abbc", Some((0, 4))} +mat!{match_basic_98, r"ab?bc", r"abc", Some((0, 3))} +mat!{match_basic_99, r"ab?c", r"abc", Some((0, 3))} +mat!{match_basic_100, r"^abc$", r"abc", Some((0, 3))} +mat!{match_basic_101, r"^abc", r"abcc", Some((0, 3))} +mat!{match_basic_102, r"abc$", r"aabc", Some((1, 4))} +mat!{match_basic_103, r"^", r"abc", Some((0, 0))} +mat!{match_basic_104, r"$", r"abc", Some((3, 3))} +mat!{match_basic_105, r"a.c", r"abc", Some((0, 3))} +mat!{match_basic_106, r"a.c", r"axc", Some((0, 3))} +mat!{match_basic_107, r"a.*c", r"axyzc", Some((0, 5))} +mat!{match_basic_108, r"a[bc]d", r"abd", Some((0, 3))} +mat!{match_basic_109, r"a[b-d]e", r"ace", Some((0, 3))} +mat!{match_basic_110, r"a[b-d]", r"aac", Some((1, 3))} +mat!{match_basic_111, r"a[-b]", r"a-", Some((0, 2))} +mat!{match_basic_112, r"a[b-]", r"a-", Some((0, 2))} +mat!{match_basic_113, r"a]", r"a]", Some((0, 2))} +mat!{match_basic_114, r"a[]]b", r"a]b", Some((0, 3))} +mat!{match_basic_115, r"a[^bc]d", r"aed", Some((0, 3))} +mat!{match_basic_116, r"a[^-b]c", r"adc", Some((0, 3))} +mat!{match_basic_117, r"a[^]b]c", r"adc", Some((0, 3))} +mat!{match_basic_118, r"ab|cd", r"abc", Some((0, 2))} +mat!{match_basic_119, r"ab|cd", r"abcd", Some((0, 2))} +mat!{match_basic_120, r"a\(b", r"a(b", Some((0, 3))} +mat!{match_basic_121, r"a\(*b", r"ab", Some((0, 2))} +mat!{match_basic_122, r"a\(*b", r"a((b", Some((0, 4))} +mat!{match_basic_123, r"((a))", r"abc", Some((0, 1)), Some((0, 1)), Some((0, 1))} +mat!{match_basic_124, r"(a)b(c)", r"abc", Some((0, 3)), Some((0, 1)), Some((2, 3))} +mat!{match_basic_125, r"a+b+c", r"aabbabc", Some((4, 7))} +mat!{match_basic_126, r"a*", r"aaa", Some((0, 3))} +mat!{match_basic_128, r"(a*)*", r"-", Some((0, 0)), None} +mat!{match_basic_129, r"(a*)+", r"-", Some((0, 0)), Some((0, 0))} +mat!{match_basic_131, r"(a*|b)*", r"-", Some((0, 0)), None} +mat!{match_basic_132, r"(a+|b)*", r"ab", Some((0, 2)), Some((1, 2))} +mat!{match_basic_133, r"(a+|b)+", r"ab", Some((0, 2)), Some((1, 2))} +mat!{match_basic_134, r"(a+|b)?", r"ab", Some((0, 1)), Some((0, 1))} +mat!{match_basic_135, r"[^ab]*", r"cde", Some((0, 3))} +mat!{match_basic_137, r"(^)*", r"-", Some((0, 0)), None} +mat!{match_basic_138, r"a*", r"", Some((0, 0))} +mat!{match_basic_139, r"([abc])*d", r"abbbcd", Some((0, 6)), Some((4, 5))} +mat!{match_basic_140, r"([abc])*bcd", r"abcd", Some((0, 4)), Some((0, 1))} +mat!{match_basic_141, r"a|b|c|d|e", r"e", Some((0, 1))} +mat!{match_basic_142, r"(a|b|c|d|e)f", r"ef", Some((0, 2)), Some((0, 1))} +mat!{match_basic_144, r"((a*|b))*", r"-", Some((0, 0)), None, None} +mat!{match_basic_145, r"abcd*efg", r"abcdefg", Some((0, 7))} +mat!{match_basic_146, r"ab*", r"xabyabbbz", Some((1, 3))} +mat!{match_basic_147, r"ab*", r"xayabbbz", Some((1, 2))} +mat!{match_basic_148, r"(ab|cd)e", r"abcde", Some((2, 5)), Some((2, 4))} +mat!{match_basic_149, r"[abhgefdc]ij", r"hij", Some((0, 3))} +mat!{match_basic_150, r"(a|b)c*d", r"abcd", Some((1, 4)), Some((1, 2))} +mat!{match_basic_151, r"(ab|ab*)bc", r"abc", Some((0, 3)), Some((0, 1))} +mat!{match_basic_152, r"a([bc]*)c*", r"abc", Some((0, 3)), Some((1, 3))} +mat!{match_basic_153, r"a([bc]*)(c*d)", r"abcd", Some((0, 4)), Some((1, 3)), Some((3, 4))} +mat!{match_basic_154, r"a([bc]+)(c*d)", r"abcd", Some((0, 4)), Some((1, 3)), Some((3, 4))} +mat!{match_basic_155, r"a([bc]*)(c+d)", r"abcd", Some((0, 4)), Some((1, 2)), Some((2, 4))} +mat!{match_basic_156, r"a[bcd]*dcdcde", r"adcdcde", Some((0, 7))} +mat!{match_basic_157, r"(ab|a)b*c", r"abc", Some((0, 3)), Some((0, 2))} +mat!{match_basic_158, r"((a)(b)c)(d)", r"abcd", Some((0, 4)), Some((0, 3)), Some((0, 1)), Some((1, 2)), Some((3, 4))} +mat!{match_basic_159, r"[A-Za-z_][A-Za-z0-9_]*", r"alpha", Some((0, 5))} +mat!{match_basic_160, r"^a(bc+|b[eh])g|.h$", r"abh", Some((1, 3))} +mat!{match_basic_161, r"(bc+d$|ef*g.|h?i(j|k))", r"effgz", Some((0, 5)), Some((0, 5))} +mat!{match_basic_162, r"(bc+d$|ef*g.|h?i(j|k))", r"ij", Some((0, 2)), Some((0, 2)), Some((1, 2))} +mat!{match_basic_163, r"(bc+d$|ef*g.|h?i(j|k))", r"reffgz", Some((1, 6)), Some((1, 6))} +mat!{match_basic_164, r"(((((((((a)))))))))", r"a", Some((0, 1)), Some((0, 1)), Some((0, 1)), Some((0, 1)), Some((0, 1)), Some((0, 1)), Some((0, 1)), Some((0, 1)), Some((0, 1)), Some((0, 1))} +mat!{match_basic_165, r"multiple words", r"multiple words yeah", Some((0, 14))} +mat!{match_basic_166, r"(.*)c(.*)", r"abcde", Some((0, 5)), Some((0, 2)), Some((3, 5))} +mat!{match_basic_167, r"abcd", r"abcd", Some((0, 4))} +mat!{match_basic_168, r"a(bc)d", r"abcd", Some((0, 4)), Some((1, 3))} +mat!{match_basic_169, r"a[-]?c", r"ac", Some((0, 3))} +mat!{match_basic_170, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Muammar Qaddafi", Some((0, 15)), None, Some((10, 12))} +mat!{match_basic_171, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Mo'ammar Gadhafi", Some((0, 16)), None, Some((11, 13))} +mat!{match_basic_172, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Muammar Kaddafi", Some((0, 15)), None, Some((10, 12))} +mat!{match_basic_173, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Muammar Qadhafi", Some((0, 15)), None, Some((10, 12))} +mat!{match_basic_174, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Muammar Gadafi", Some((0, 14)), None, Some((10, 11))} +mat!{match_basic_175, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Mu'ammar Qadafi", Some((0, 15)), None, Some((11, 12))} +mat!{match_basic_176, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Moamar Gaddafi", Some((0, 14)), None, Some((9, 11))} +mat!{match_basic_177, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Mu'ammar Qadhdhafi", Some((0, 18)), None, Some((13, 15))} +mat!{match_basic_178, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Muammar Khaddafi", Some((0, 16)), None, Some((11, 13))} +mat!{match_basic_179, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Muammar Ghaddafy", Some((0, 16)), None, Some((11, 13))} +mat!{match_basic_180, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Muammar Ghadafi", Some((0, 15)), None, Some((11, 12))} +mat!{match_basic_181, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Muammar Ghaddafi", Some((0, 16)), None, Some((11, 13))} +mat!{match_basic_182, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Muamar Kaddafi", Some((0, 14)), None, Some((9, 11))} +mat!{match_basic_183, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Muammar Quathafi", Some((0, 16)), None, Some((11, 13))} +mat!{match_basic_184, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Muammar Gheddafi", Some((0, 16)), None, Some((11, 13))} +mat!{match_basic_185, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Moammar Khadafy", Some((0, 15)), None, Some((11, 12))} +mat!{match_basic_186, r"M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", r"Moammar Qudhafi", Some((0, 15)), None, Some((10, 12))} +mat!{match_basic_187, r"a+(b|c)*d+", r"aabcdd", Some((0, 6)), Some((3, 4))} +mat!{match_basic_188, r"^.+$", r"vivi", Some((0, 4))} +mat!{match_basic_189, r"^(.+)$", r"vivi", Some((0, 4)), Some((0, 4))} +mat!{match_basic_190, r"^([^!.]+).att.com!(.+)$", r"gryphon.att.com!eby", Some((0, 19)), Some((0, 7)), Some((16, 19))} +mat!{match_basic_191, r"^([^!]+!)?([^!]+)$", r"bas", Some((0, 3)), None, Some((0, 3))} +mat!{match_basic_192, r"^([^!]+!)?([^!]+)$", r"bar!bas", Some((0, 7)), Some((0, 4)), Some((4, 7))} +mat!{match_basic_193, r"^([^!]+!)?([^!]+)$", r"foo!bas", Some((0, 7)), Some((0, 4)), Some((4, 7))} +mat!{match_basic_194, r"^.+!([^!]+!)([^!]+)$", r"foo!bar!bas", Some((0, 11)), Some((4, 8)), Some((8, 11))} +mat!{match_basic_195, r"((foo)|(bar))!bas", r"bar!bas", Some((0, 7)), Some((0, 3)), None, Some((0, 3))} +mat!{match_basic_196, r"((foo)|(bar))!bas", r"foo!bar!bas", Some((4, 11)), Some((4, 7)), None, Some((4, 7))} +mat!{match_basic_197, r"((foo)|(bar))!bas", r"foo!bas", Some((0, 7)), Some((0, 3)), Some((0, 3))} +mat!{match_basic_198, r"((foo)|bar)!bas", r"bar!bas", Some((0, 7)), Some((0, 3))} +mat!{match_basic_199, r"((foo)|bar)!bas", r"foo!bar!bas", Some((4, 11)), Some((4, 7))} +mat!{match_basic_200, r"((foo)|bar)!bas", r"foo!bas", Some((0, 7)), Some((0, 3)), Some((0, 3))} +mat!{match_basic_201, r"(foo|(bar))!bas", r"bar!bas", Some((0, 7)), Some((0, 3)), Some((0, 3))} +mat!{match_basic_202, r"(foo|(bar))!bas", r"foo!bar!bas", Some((4, 11)), Some((4, 7)), Some((4, 7))} +mat!{match_basic_203, r"(foo|(bar))!bas", r"foo!bas", Some((0, 7)), Some((0, 3))} +mat!{match_basic_204, r"(foo|bar)!bas", r"bar!bas", Some((0, 7)), Some((0, 3))} +mat!{match_basic_205, r"(foo|bar)!bas", r"foo!bar!bas", Some((4, 11)), Some((4, 7))} +mat!{match_basic_206, r"(foo|bar)!bas", r"foo!bas", Some((0, 7)), Some((0, 3))} +mat!{match_basic_207, r"^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$", r"foo!bar!bas", Some((0, 11)), Some((0, 11)), None, None, Some((4, 8)), Some((8, 11))} +mat!{match_basic_208, r"^([^!]+!)?([^!]+)$|^.+!([^!]+!)([^!]+)$", r"bas", Some((0, 3)), None, Some((0, 3))} +mat!{match_basic_209, r"^([^!]+!)?([^!]+)$|^.+!([^!]+!)([^!]+)$", r"bar!bas", Some((0, 7)), Some((0, 4)), Some((4, 7))} +mat!{match_basic_210, r"^([^!]+!)?([^!]+)$|^.+!([^!]+!)([^!]+)$", r"foo!bar!bas", Some((0, 11)), None, None, Some((4, 8)), Some((8, 11))} +mat!{match_basic_211, r"^([^!]+!)?([^!]+)$|^.+!([^!]+!)([^!]+)$", r"foo!bas", Some((0, 7)), Some((0, 4)), Some((4, 7))} +mat!{match_basic_212, r"^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$", r"bas", Some((0, 3)), Some((0, 3)), None, Some((0, 3))} +mat!{match_basic_213, r"^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$", r"bar!bas", Some((0, 7)), Some((0, 7)), Some((0, 4)), Some((4, 7))} +mat!{match_basic_214, r"^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$", r"foo!bar!bas", Some((0, 11)), Some((0, 11)), None, None, Some((4, 8)), Some((8, 11))} +mat!{match_basic_215, r"^(([^!]+!)?([^!]+)|.+!([^!]+!)([^!]+))$", r"foo!bas", Some((0, 7)), Some((0, 7)), Some((0, 4)), Some((4, 7))} +mat!{match_basic_216, r".*(/XXX).*", r"/XXX", Some((0, 4)), Some((0, 4))} +mat!{match_basic_217, r".*(\\XXX).*", r"\XXX", Some((0, 4)), Some((0, 4))} +mat!{match_basic_218, r"\\XXX", r"\XXX", Some((0, 4))} +mat!{match_basic_219, r".*(/000).*", r"/000", Some((0, 4)), Some((0, 4))} +mat!{match_basic_220, r".*(\\000).*", r"\000", Some((0, 4)), Some((0, 4))} +mat!{match_basic_221, r"\\000", r"\000", Some((0, 4))} // Tests from nullsubexpr.dat -mat!(match_nullsubexpr_3, r"(a*)*", r"a", Some((0, 1)), Some((0, 1))) -mat!(match_nullsubexpr_5, r"(a*)*", r"x", Some((0, 0)), None) -mat!(match_nullsubexpr_6, r"(a*)*", r"aaaaaa", Some((0, 6)), Some((0, 6))) -mat!(match_nullsubexpr_7, r"(a*)*", r"aaaaaax", Some((0, 6)), Some((0, 6))) -mat!(match_nullsubexpr_8, r"(a*)+", r"a", Some((0, 1)), Some((0, 1))) -mat!(match_nullsubexpr_9, r"(a*)+", r"x", Some((0, 0)), Some((0, 0))) -mat!(match_nullsubexpr_10, r"(a*)+", r"aaaaaa", Some((0, 6)), Some((0, 6))) -mat!(match_nullsubexpr_11, r"(a*)+", r"aaaaaax", Some((0, 6)), Some((0, 6))) -mat!(match_nullsubexpr_12, r"(a+)*", r"a", Some((0, 1)), Some((0, 1))) -mat!(match_nullsubexpr_13, r"(a+)*", r"x", Some((0, 0))) -mat!(match_nullsubexpr_14, r"(a+)*", r"aaaaaa", Some((0, 6)), Some((0, 6))) -mat!(match_nullsubexpr_15, r"(a+)*", r"aaaaaax", Some((0, 6)), Some((0, 6))) -mat!(match_nullsubexpr_16, r"(a+)+", r"a", Some((0, 1)), Some((0, 1))) -mat!(match_nullsubexpr_17, r"(a+)+", r"x", None) -mat!(match_nullsubexpr_18, r"(a+)+", r"aaaaaa", Some((0, 6)), Some((0, 6))) -mat!(match_nullsubexpr_19, r"(a+)+", r"aaaaaax", Some((0, 6)), Some((0, 6))) -mat!(match_nullsubexpr_21, r"([a]*)*", r"a", Some((0, 1)), Some((0, 1))) -mat!(match_nullsubexpr_23, r"([a]*)*", r"x", Some((0, 0)), None) -mat!(match_nullsubexpr_24, r"([a]*)*", r"aaaaaa", Some((0, 6)), Some((0, 6))) -mat!(match_nullsubexpr_25, r"([a]*)*", r"aaaaaax", Some((0, 6)), Some((0, 6))) -mat!(match_nullsubexpr_26, r"([a]*)+", r"a", Some((0, 1)), Some((0, 1))) -mat!(match_nullsubexpr_27, r"([a]*)+", r"x", Some((0, 0)), Some((0, 0))) -mat!(match_nullsubexpr_28, r"([a]*)+", r"aaaaaa", Some((0, 6)), Some((0, 6))) -mat!(match_nullsubexpr_29, r"([a]*)+", r"aaaaaax", Some((0, 6)), Some((0, 6))) -mat!(match_nullsubexpr_30, r"([^b]*)*", r"a", Some((0, 1)), Some((0, 1))) -mat!(match_nullsubexpr_32, r"([^b]*)*", r"b", Some((0, 0)), None) -mat!(match_nullsubexpr_33, r"([^b]*)*", r"aaaaaa", Some((0, 6)), Some((0, 6))) -mat!(match_nullsubexpr_34, r"([^b]*)*", r"aaaaaab", Some((0, 6)), Some((0, 6))) -mat!(match_nullsubexpr_35, r"([ab]*)*", r"a", Some((0, 1)), Some((0, 1))) -mat!(match_nullsubexpr_36, r"([ab]*)*", r"aaaaaa", Some((0, 6)), Some((0, 6))) -mat!(match_nullsubexpr_37, r"([ab]*)*", r"ababab", Some((0, 6)), Some((0, 6))) -mat!(match_nullsubexpr_38, r"([ab]*)*", r"bababa", Some((0, 6)), Some((0, 6))) -mat!(match_nullsubexpr_39, r"([ab]*)*", r"b", Some((0, 1)), Some((0, 1))) -mat!(match_nullsubexpr_40, r"([ab]*)*", r"bbbbbb", Some((0, 6)), Some((0, 6))) -mat!(match_nullsubexpr_41, r"([ab]*)*", r"aaaabcde", Some((0, 5)), Some((0, 5))) -mat!(match_nullsubexpr_42, r"([^a]*)*", r"b", Some((0, 1)), Some((0, 1))) -mat!(match_nullsubexpr_43, r"([^a]*)*", r"bbbbbb", Some((0, 6)), Some((0, 6))) -mat!(match_nullsubexpr_45, r"([^a]*)*", r"aaaaaa", Some((0, 0)), None) -mat!(match_nullsubexpr_46, r"([^ab]*)*", r"ccccxx", Some((0, 6)), Some((0, 6))) -mat!(match_nullsubexpr_48, r"([^ab]*)*", r"ababab", Some((0, 0)), None) -mat!(match_nullsubexpr_50, r"((z)+|a)*", r"zabcde", Some((0, 2)), Some((1, 2))) -mat!(match_nullsubexpr_69, r"(a*)*(x)", r"x", Some((0, 1)), None, Some((0, 1))) -mat!(match_nullsubexpr_70, r"(a*)*(x)", r"ax", Some((0, 2)), Some((0, 1)), Some((1, 2))) -mat!(match_nullsubexpr_71, r"(a*)*(x)", r"axa", Some((0, 2)), Some((0, 1)), Some((1, 2))) -mat!(match_nullsubexpr_73, r"(a*)+(x)", r"x", Some((0, 1)), Some((0, 0)), Some((0, 1))) -mat!(match_nullsubexpr_74, r"(a*)+(x)", r"ax", Some((0, 2)), Some((0, 1)), Some((1, 2))) -mat!(match_nullsubexpr_75, r"(a*)+(x)", r"axa", Some((0, 2)), Some((0, 1)), Some((1, 2))) -mat!(match_nullsubexpr_77, r"(a*){2}(x)", r"x", Some((0, 1)), Some((0, 0)), Some((0, 1))) -mat!(match_nullsubexpr_78, r"(a*){2}(x)", r"ax", Some((0, 2)), Some((1, 1)), Some((1, 2))) -mat!(match_nullsubexpr_79, r"(a*){2}(x)", r"axa", Some((0, 2)), Some((1, 1)), Some((1, 2))) +mat!{match_nullsubexpr_3, r"(a*)*", r"a", Some((0, 1)), Some((0, 1))} +mat!{match_nullsubexpr_5, r"(a*)*", r"x", Some((0, 0)), None} +mat!{match_nullsubexpr_6, r"(a*)*", r"aaaaaa", Some((0, 6)), Some((0, 6))} +mat!{match_nullsubexpr_7, r"(a*)*", r"aaaaaax", Some((0, 6)), Some((0, 6))} +mat!{match_nullsubexpr_8, r"(a*)+", r"a", Some((0, 1)), Some((0, 1))} +mat!{match_nullsubexpr_9, r"(a*)+", r"x", Some((0, 0)), Some((0, 0))} +mat!{match_nullsubexpr_10, r"(a*)+", r"aaaaaa", Some((0, 6)), Some((0, 6))} +mat!{match_nullsubexpr_11, r"(a*)+", r"aaaaaax", Some((0, 6)), Some((0, 6))} +mat!{match_nullsubexpr_12, r"(a+)*", r"a", Some((0, 1)), Some((0, 1))} +mat!{match_nullsubexpr_13, r"(a+)*", r"x", Some((0, 0))} +mat!{match_nullsubexpr_14, r"(a+)*", r"aaaaaa", Some((0, 6)), Some((0, 6))} +mat!{match_nullsubexpr_15, r"(a+)*", r"aaaaaax", Some((0, 6)), Some((0, 6))} +mat!{match_nullsubexpr_16, r"(a+)+", r"a", Some((0, 1)), Some((0, 1))} +mat!{match_nullsubexpr_17, r"(a+)+", r"x", None} +mat!{match_nullsubexpr_18, r"(a+)+", r"aaaaaa", Some((0, 6)), Some((0, 6))} +mat!{match_nullsubexpr_19, r"(a+)+", r"aaaaaax", Some((0, 6)), Some((0, 6))} +mat!{match_nullsubexpr_21, r"([a]*)*", r"a", Some((0, 1)), Some((0, 1))} +mat!{match_nullsubexpr_23, r"([a]*)*", r"x", Some((0, 0)), None} +mat!{match_nullsubexpr_24, r"([a]*)*", r"aaaaaa", Some((0, 6)), Some((0, 6))} +mat!{match_nullsubexpr_25, r"([a]*)*", r"aaaaaax", Some((0, 6)), Some((0, 6))} +mat!{match_nullsubexpr_26, r"([a]*)+", r"a", Some((0, 1)), Some((0, 1))} +mat!{match_nullsubexpr_27, r"([a]*)+", r"x", Some((0, 0)), Some((0, 0))} +mat!{match_nullsubexpr_28, r"([a]*)+", r"aaaaaa", Some((0, 6)), Some((0, 6))} +mat!{match_nullsubexpr_29, r"([a]*)+", r"aaaaaax", Some((0, 6)), Some((0, 6))} +mat!{match_nullsubexpr_30, r"([^b]*)*", r"a", Some((0, 1)), Some((0, 1))} +mat!{match_nullsubexpr_32, r"([^b]*)*", r"b", Some((0, 0)), None} +mat!{match_nullsubexpr_33, r"([^b]*)*", r"aaaaaa", Some((0, 6)), Some((0, 6))} +mat!{match_nullsubexpr_34, r"([^b]*)*", r"aaaaaab", Some((0, 6)), Some((0, 6))} +mat!{match_nullsubexpr_35, r"([ab]*)*", r"a", Some((0, 1)), Some((0, 1))} +mat!{match_nullsubexpr_36, r"([ab]*)*", r"aaaaaa", Some((0, 6)), Some((0, 6))} +mat!{match_nullsubexpr_37, r"([ab]*)*", r"ababab", Some((0, 6)), Some((0, 6))} +mat!{match_nullsubexpr_38, r"([ab]*)*", r"bababa", Some((0, 6)), Some((0, 6))} +mat!{match_nullsubexpr_39, r"([ab]*)*", r"b", Some((0, 1)), Some((0, 1))} +mat!{match_nullsubexpr_40, r"([ab]*)*", r"bbbbbb", Some((0, 6)), Some((0, 6))} +mat!{match_nullsubexpr_41, r"([ab]*)*", r"aaaabcde", Some((0, 5)), Some((0, 5))} +mat!{match_nullsubexpr_42, r"([^a]*)*", r"b", Some((0, 1)), Some((0, 1))} +mat!{match_nullsubexpr_43, r"([^a]*)*", r"bbbbbb", Some((0, 6)), Some((0, 6))} +mat!{match_nullsubexpr_45, r"([^a]*)*", r"aaaaaa", Some((0, 0)), None} +mat!{match_nullsubexpr_46, r"([^ab]*)*", r"ccccxx", Some((0, 6)), Some((0, 6))} +mat!{match_nullsubexpr_48, r"([^ab]*)*", r"ababab", Some((0, 0)), None} +mat!{match_nullsubexpr_50, r"((z)+|a)*", r"zabcde", Some((0, 2)), Some((1, 2))} +mat!{match_nullsubexpr_69, r"(a*)*(x)", r"x", Some((0, 1)), None, Some((0, 1))} +mat!{match_nullsubexpr_70, r"(a*)*(x)", r"ax", Some((0, 2)), Some((0, 1)), Some((1, 2))} +mat!{match_nullsubexpr_71, r"(a*)*(x)", r"axa", Some((0, 2)), Some((0, 1)), Some((1, 2))} +mat!{match_nullsubexpr_73, r"(a*)+(x)", r"x", Some((0, 1)), Some((0, 0)), Some((0, 1))} +mat!{match_nullsubexpr_74, r"(a*)+(x)", r"ax", Some((0, 2)), Some((0, 1)), Some((1, 2))} +mat!{match_nullsubexpr_75, r"(a*)+(x)", r"axa", Some((0, 2)), Some((0, 1)), Some((1, 2))} +mat!{match_nullsubexpr_77, r"(a*){2}(x)", r"x", Some((0, 1)), Some((0, 0)), Some((0, 1))} +mat!{match_nullsubexpr_78, r"(a*){2}(x)", r"ax", Some((0, 2)), Some((1, 1)), Some((1, 2))} +mat!{match_nullsubexpr_79, r"(a*){2}(x)", r"axa", Some((0, 2)), Some((1, 1)), Some((1, 2))} // Tests from repetition.dat -mat!(match_repetition_10, r"((..)|(.))", r"", None) -mat!(match_repetition_11, r"((..)|(.))((..)|(.))", r"", None) -mat!(match_repetition_12, r"((..)|(.))((..)|(.))((..)|(.))", r"", None) -mat!(match_repetition_14, r"((..)|(.)){1}", r"", None) -mat!(match_repetition_15, r"((..)|(.)){2}", r"", None) -mat!(match_repetition_16, r"((..)|(.)){3}", r"", None) -mat!(match_repetition_18, r"((..)|(.))*", r"", Some((0, 0))) -mat!(match_repetition_20, r"((..)|(.))", r"a", Some((0, 1)), Some((0, 1)), None, Some((0, 1))) -mat!(match_repetition_21, r"((..)|(.))((..)|(.))", r"a", None) -mat!(match_repetition_22, r"((..)|(.))((..)|(.))((..)|(.))", r"a", None) -mat!(match_repetition_24, r"((..)|(.)){1}", r"a", Some((0, 1)), Some((0, 1)), None, Some((0, 1))) -mat!(match_repetition_25, r"((..)|(.)){2}", r"a", None) -mat!(match_repetition_26, r"((..)|(.)){3}", r"a", None) -mat!(match_repetition_28, r"((..)|(.))*", r"a", Some((0, 1)), Some((0, 1)), None, Some((0, 1))) -mat!(match_repetition_30, r"((..)|(.))", r"aa", Some((0, 2)), Some((0, 2)), Some((0, 2)), None) -mat!(match_repetition_31, r"((..)|(.))((..)|(.))", r"aa", Some((0, 2)), Some((0, 1)), None, Some((0, 1)), Some((1, 2)), None, Some((1, 2))) -mat!(match_repetition_32, r"((..)|(.))((..)|(.))((..)|(.))", r"aa", None) -mat!(match_repetition_34, r"((..)|(.)){1}", r"aa", Some((0, 2)), Some((0, 2)), Some((0, 2)), None) -mat!(match_repetition_35, r"((..)|(.)){2}", r"aa", Some((0, 2)), Some((1, 2)), None, Some((1, 2))) -mat!(match_repetition_36, r"((..)|(.)){3}", r"aa", None) -mat!(match_repetition_38, r"((..)|(.))*", r"aa", Some((0, 2)), Some((0, 2)), Some((0, 2)), None) -mat!(match_repetition_40, r"((..)|(.))", r"aaa", Some((0, 2)), Some((0, 2)), Some((0, 2)), None) -mat!(match_repetition_41, r"((..)|(.))((..)|(.))", r"aaa", Some((0, 3)), Some((0, 2)), Some((0, 2)), None, Some((2, 3)), None, Some((2, 3))) -mat!(match_repetition_42, r"((..)|(.))((..)|(.))((..)|(.))", r"aaa", Some((0, 3)), Some((0, 1)), None, Some((0, 1)), Some((1, 2)), None, Some((1, 2)), Some((2, 3)), None, Some((2, 3))) -mat!(match_repetition_44, r"((..)|(.)){1}", r"aaa", Some((0, 2)), Some((0, 2)), Some((0, 2)), None) -mat!(match_repetition_46, r"((..)|(.)){2}", r"aaa", Some((0, 3)), Some((2, 3)), Some((0, 2)), Some((2, 3))) -mat!(match_repetition_47, r"((..)|(.)){3}", r"aaa", Some((0, 3)), Some((2, 3)), None, Some((2, 3))) -mat!(match_repetition_50, r"((..)|(.))*", r"aaa", Some((0, 3)), Some((2, 3)), Some((0, 2)), Some((2, 3))) -mat!(match_repetition_52, r"((..)|(.))", r"aaaa", Some((0, 2)), Some((0, 2)), Some((0, 2)), None) -mat!(match_repetition_53, r"((..)|(.))((..)|(.))", r"aaaa", Some((0, 4)), Some((0, 2)), Some((0, 2)), None, Some((2, 4)), Some((2, 4)), None) -mat!(match_repetition_54, r"((..)|(.))((..)|(.))((..)|(.))", r"aaaa", Some((0, 4)), Some((0, 2)), Some((0, 2)), None, Some((2, 3)), None, Some((2, 3)), Some((3, 4)), None, Some((3, 4))) -mat!(match_repetition_56, r"((..)|(.)){1}", r"aaaa", Some((0, 2)), Some((0, 2)), Some((0, 2)), None) -mat!(match_repetition_57, r"((..)|(.)){2}", r"aaaa", Some((0, 4)), Some((2, 4)), Some((2, 4)), None) -mat!(match_repetition_59, r"((..)|(.)){3}", r"aaaa", Some((0, 4)), Some((3, 4)), Some((0, 2)), Some((3, 4))) -mat!(match_repetition_61, r"((..)|(.))*", r"aaaa", Some((0, 4)), Some((2, 4)), Some((2, 4)), None) -mat!(match_repetition_63, r"((..)|(.))", r"aaaaa", Some((0, 2)), Some((0, 2)), Some((0, 2)), None) -mat!(match_repetition_64, r"((..)|(.))((..)|(.))", r"aaaaa", Some((0, 4)), Some((0, 2)), Some((0, 2)), None, Some((2, 4)), Some((2, 4)), None) -mat!(match_repetition_65, r"((..)|(.))((..)|(.))((..)|(.))", r"aaaaa", Some((0, 5)), Some((0, 2)), Some((0, 2)), None, Some((2, 4)), Some((2, 4)), None, Some((4, 5)), None, Some((4, 5))) -mat!(match_repetition_67, r"((..)|(.)){1}", r"aaaaa", Some((0, 2)), Some((0, 2)), Some((0, 2)), None) -mat!(match_repetition_68, r"((..)|(.)){2}", r"aaaaa", Some((0, 4)), Some((2, 4)), Some((2, 4)), None) -mat!(match_repetition_70, r"((..)|(.)){3}", r"aaaaa", Some((0, 5)), Some((4, 5)), Some((2, 4)), Some((4, 5))) -mat!(match_repetition_73, r"((..)|(.))*", r"aaaaa", Some((0, 5)), Some((4, 5)), Some((2, 4)), Some((4, 5))) -mat!(match_repetition_75, r"((..)|(.))", r"aaaaaa", Some((0, 2)), Some((0, 2)), Some((0, 2)), None) -mat!(match_repetition_76, r"((..)|(.))((..)|(.))", r"aaaaaa", Some((0, 4)), Some((0, 2)), Some((0, 2)), None, Some((2, 4)), Some((2, 4)), None) -mat!(match_repetition_77, r"((..)|(.))((..)|(.))((..)|(.))", r"aaaaaa", Some((0, 6)), Some((0, 2)), Some((0, 2)), None, Some((2, 4)), Some((2, 4)), None, Some((4, 6)), Some((4, 6)), None) -mat!(match_repetition_79, r"((..)|(.)){1}", r"aaaaaa", Some((0, 2)), Some((0, 2)), Some((0, 2)), None) -mat!(match_repetition_80, r"((..)|(.)){2}", r"aaaaaa", Some((0, 4)), Some((2, 4)), Some((2, 4)), None) -mat!(match_repetition_81, r"((..)|(.)){3}", r"aaaaaa", Some((0, 6)), Some((4, 6)), Some((4, 6)), None) -mat!(match_repetition_83, r"((..)|(.))*", r"aaaaaa", Some((0, 6)), Some((4, 6)), Some((4, 6)), None) -mat!(match_repetition_90, r"X(.?){0,}Y", r"X1234567Y", Some((0, 9)), Some((7, 8))) -mat!(match_repetition_91, r"X(.?){1,}Y", r"X1234567Y", Some((0, 9)), Some((7, 8))) -mat!(match_repetition_92, r"X(.?){2,}Y", r"X1234567Y", Some((0, 9)), Some((7, 8))) -mat!(match_repetition_93, r"X(.?){3,}Y", r"X1234567Y", Some((0, 9)), Some((7, 8))) -mat!(match_repetition_94, r"X(.?){4,}Y", r"X1234567Y", Some((0, 9)), Some((7, 8))) -mat!(match_repetition_95, r"X(.?){5,}Y", r"X1234567Y", Some((0, 9)), Some((7, 8))) -mat!(match_repetition_96, r"X(.?){6,}Y", r"X1234567Y", Some((0, 9)), Some((7, 8))) -mat!(match_repetition_97, r"X(.?){7,}Y", r"X1234567Y", Some((0, 9)), Some((7, 8))) -mat!(match_repetition_98, r"X(.?){8,}Y", r"X1234567Y", Some((0, 9)), Some((8, 8))) -mat!(match_repetition_100, r"X(.?){0,8}Y", r"X1234567Y", Some((0, 9)), Some((8, 8))) -mat!(match_repetition_102, r"X(.?){1,8}Y", r"X1234567Y", Some((0, 9)), Some((8, 8))) -mat!(match_repetition_104, r"X(.?){2,8}Y", r"X1234567Y", Some((0, 9)), Some((8, 8))) -mat!(match_repetition_106, r"X(.?){3,8}Y", r"X1234567Y", Some((0, 9)), Some((8, 8))) -mat!(match_repetition_108, r"X(.?){4,8}Y", r"X1234567Y", Some((0, 9)), Some((8, 8))) -mat!(match_repetition_110, r"X(.?){5,8}Y", r"X1234567Y", Some((0, 9)), Some((8, 8))) -mat!(match_repetition_112, r"X(.?){6,8}Y", r"X1234567Y", Some((0, 9)), Some((8, 8))) -mat!(match_repetition_114, r"X(.?){7,8}Y", r"X1234567Y", Some((0, 9)), Some((8, 8))) -mat!(match_repetition_115, r"X(.?){8,8}Y", r"X1234567Y", Some((0, 9)), Some((8, 8))) -mat!(match_repetition_126, r"(a|ab|c|bcd){0,}(d*)", r"ababcd", Some((0, 1)), Some((0, 1)), Some((1, 1))) -mat!(match_repetition_127, r"(a|ab|c|bcd){1,}(d*)", r"ababcd", Some((0, 1)), Some((0, 1)), Some((1, 1))) -mat!(match_repetition_128, r"(a|ab|c|bcd){2,}(d*)", r"ababcd", Some((0, 6)), Some((3, 6)), Some((6, 6))) -mat!(match_repetition_129, r"(a|ab|c|bcd){3,}(d*)", r"ababcd", Some((0, 6)), Some((3, 6)), Some((6, 6))) -mat!(match_repetition_130, r"(a|ab|c|bcd){4,}(d*)", r"ababcd", None) -mat!(match_repetition_131, r"(a|ab|c|bcd){0,10}(d*)", r"ababcd", Some((0, 1)), Some((0, 1)), Some((1, 1))) -mat!(match_repetition_132, r"(a|ab|c|bcd){1,10}(d*)", r"ababcd", Some((0, 1)), Some((0, 1)), Some((1, 1))) -mat!(match_repetition_133, r"(a|ab|c|bcd){2,10}(d*)", r"ababcd", Some((0, 6)), Some((3, 6)), Some((6, 6))) -mat!(match_repetition_134, r"(a|ab|c|bcd){3,10}(d*)", r"ababcd", Some((0, 6)), Some((3, 6)), Some((6, 6))) -mat!(match_repetition_135, r"(a|ab|c|bcd){4,10}(d*)", r"ababcd", None) -mat!(match_repetition_136, r"(a|ab|c|bcd)*(d*)", r"ababcd", Some((0, 1)), Some((0, 1)), Some((1, 1))) -mat!(match_repetition_137, r"(a|ab|c|bcd)+(d*)", r"ababcd", Some((0, 1)), Some((0, 1)), Some((1, 1))) -mat!(match_repetition_143, r"(ab|a|c|bcd){0,}(d*)", r"ababcd", Some((0, 6)), Some((4, 5)), Some((5, 6))) -mat!(match_repetition_145, r"(ab|a|c|bcd){1,}(d*)", r"ababcd", Some((0, 6)), Some((4, 5)), Some((5, 6))) -mat!(match_repetition_147, r"(ab|a|c|bcd){2,}(d*)", r"ababcd", Some((0, 6)), Some((4, 5)), Some((5, 6))) -mat!(match_repetition_149, r"(ab|a|c|bcd){3,}(d*)", r"ababcd", Some((0, 6)), Some((4, 5)), Some((5, 6))) -mat!(match_repetition_150, r"(ab|a|c|bcd){4,}(d*)", r"ababcd", None) -mat!(match_repetition_152, r"(ab|a|c|bcd){0,10}(d*)", r"ababcd", Some((0, 6)), Some((4, 5)), Some((5, 6))) -mat!(match_repetition_154, r"(ab|a|c|bcd){1,10}(d*)", r"ababcd", Some((0, 6)), Some((4, 5)), Some((5, 6))) -mat!(match_repetition_156, r"(ab|a|c|bcd){2,10}(d*)", r"ababcd", Some((0, 6)), Some((4, 5)), Some((5, 6))) -mat!(match_repetition_158, r"(ab|a|c|bcd){3,10}(d*)", r"ababcd", Some((0, 6)), Some((4, 5)), Some((5, 6))) -mat!(match_repetition_159, r"(ab|a|c|bcd){4,10}(d*)", r"ababcd", None) -mat!(match_repetition_161, r"(ab|a|c|bcd)*(d*)", r"ababcd", Some((0, 6)), Some((4, 5)), Some((5, 6))) -mat!(match_repetition_163, r"(ab|a|c|bcd)+(d*)", r"ababcd", Some((0, 6)), Some((4, 5)), Some((5, 6))) +mat!{match_repetition_10, r"((..)|(.))", r"", None} +mat!{match_repetition_11, r"((..)|(.))((..)|(.))", r"", None} +mat!{match_repetition_12, r"((..)|(.))((..)|(.))((..)|(.))", r"", None} +mat!{match_repetition_14, r"((..)|(.)){1}", r"", None} +mat!{match_repetition_15, r"((..)|(.)){2}", r"", None} +mat!{match_repetition_16, r"((..)|(.)){3}", r"", None} +mat!{match_repetition_18, r"((..)|(.))*", r"", Some((0, 0))} +mat!{match_repetition_20, r"((..)|(.))", r"a", Some((0, 1)), Some((0, 1)), None, Some((0, 1))} +mat!{match_repetition_21, r"((..)|(.))((..)|(.))", r"a", None} +mat!{match_repetition_22, r"((..)|(.))((..)|(.))((..)|(.))", r"a", None} +mat!{match_repetition_24, r"((..)|(.)){1}", r"a", Some((0, 1)), Some((0, 1)), None, Some((0, 1))} +mat!{match_repetition_25, r"((..)|(.)){2}", r"a", None} +mat!{match_repetition_26, r"((..)|(.)){3}", r"a", None} +mat!{match_repetition_28, r"((..)|(.))*", r"a", Some((0, 1)), Some((0, 1)), None, Some((0, 1))} +mat!{match_repetition_30, r"((..)|(.))", r"aa", Some((0, 2)), Some((0, 2)), Some((0, 2)), None} +mat!{match_repetition_31, r"((..)|(.))((..)|(.))", r"aa", Some((0, 2)), Some((0, 1)), None, Some((0, 1)), Some((1, 2)), None, Some((1, 2))} +mat!{match_repetition_32, r"((..)|(.))((..)|(.))((..)|(.))", r"aa", None} +mat!{match_repetition_34, r"((..)|(.)){1}", r"aa", Some((0, 2)), Some((0, 2)), Some((0, 2)), None} +mat!{match_repetition_35, r"((..)|(.)){2}", r"aa", Some((0, 2)), Some((1, 2)), None, Some((1, 2))} +mat!{match_repetition_36, r"((..)|(.)){3}", r"aa", None} +mat!{match_repetition_38, r"((..)|(.))*", r"aa", Some((0, 2)), Some((0, 2)), Some((0, 2)), None} +mat!{match_repetition_40, r"((..)|(.))", r"aaa", Some((0, 2)), Some((0, 2)), Some((0, 2)), None} +mat!{match_repetition_41, r"((..)|(.))((..)|(.))", r"aaa", Some((0, 3)), Some((0, 2)), Some((0, 2)), None, Some((2, 3)), None, Some((2, 3))} +mat!{match_repetition_42, r"((..)|(.))((..)|(.))((..)|(.))", r"aaa", Some((0, 3)), Some((0, 1)), None, Some((0, 1)), Some((1, 2)), None, Some((1, 2)), Some((2, 3)), None, Some((2, 3))} +mat!{match_repetition_44, r"((..)|(.)){1}", r"aaa", Some((0, 2)), Some((0, 2)), Some((0, 2)), None} +mat!{match_repetition_46, r"((..)|(.)){2}", r"aaa", Some((0, 3)), Some((2, 3)), Some((0, 2)), Some((2, 3))} +mat!{match_repetition_47, r"((..)|(.)){3}", r"aaa", Some((0, 3)), Some((2, 3)), None, Some((2, 3))} +mat!{match_repetition_50, r"((..)|(.))*", r"aaa", Some((0, 3)), Some((2, 3)), Some((0, 2)), Some((2, 3))} +mat!{match_repetition_52, r"((..)|(.))", r"aaaa", Some((0, 2)), Some((0, 2)), Some((0, 2)), None} +mat!{match_repetition_53, r"((..)|(.))((..)|(.))", r"aaaa", Some((0, 4)), Some((0, 2)), Some((0, 2)), None, Some((2, 4)), Some((2, 4)), None} +mat!{match_repetition_54, r"((..)|(.))((..)|(.))((..)|(.))", r"aaaa", Some((0, 4)), Some((0, 2)), Some((0, 2)), None, Some((2, 3)), None, Some((2, 3)), Some((3, 4)), None, Some((3, 4))} +mat!{match_repetition_56, r"((..)|(.)){1}", r"aaaa", Some((0, 2)), Some((0, 2)), Some((0, 2)), None} +mat!{match_repetition_57, r"((..)|(.)){2}", r"aaaa", Some((0, 4)), Some((2, 4)), Some((2, 4)), None} +mat!{match_repetition_59, r"((..)|(.)){3}", r"aaaa", Some((0, 4)), Some((3, 4)), Some((0, 2)), Some((3, 4))} +mat!{match_repetition_61, r"((..)|(.))*", r"aaaa", Some((0, 4)), Some((2, 4)), Some((2, 4)), None} +mat!{match_repetition_63, r"((..)|(.))", r"aaaaa", Some((0, 2)), Some((0, 2)), Some((0, 2)), None} +mat!{match_repetition_64, r"((..)|(.))((..)|(.))", r"aaaaa", Some((0, 4)), Some((0, 2)), Some((0, 2)), None, Some((2, 4)), Some((2, 4)), None} +mat!{match_repetition_65, r"((..)|(.))((..)|(.))((..)|(.))", r"aaaaa", Some((0, 5)), Some((0, 2)), Some((0, 2)), None, Some((2, 4)), Some((2, 4)), None, Some((4, 5)), None, Some((4, 5))} +mat!{match_repetition_67, r"((..)|(.)){1}", r"aaaaa", Some((0, 2)), Some((0, 2)), Some((0, 2)), None} +mat!{match_repetition_68, r"((..)|(.)){2}", r"aaaaa", Some((0, 4)), Some((2, 4)), Some((2, 4)), None} +mat!{match_repetition_70, r"((..)|(.)){3}", r"aaaaa", Some((0, 5)), Some((4, 5)), Some((2, 4)), Some((4, 5))} +mat!{match_repetition_73, r"((..)|(.))*", r"aaaaa", Some((0, 5)), Some((4, 5)), Some((2, 4)), Some((4, 5))} +mat!{match_repetition_75, r"((..)|(.))", r"aaaaaa", Some((0, 2)), Some((0, 2)), Some((0, 2)), None} +mat!{match_repetition_76, r"((..)|(.))((..)|(.))", r"aaaaaa", Some((0, 4)), Some((0, 2)), Some((0, 2)), None, Some((2, 4)), Some((2, 4)), None} +mat!{match_repetition_77, r"((..)|(.))((..)|(.))((..)|(.))", r"aaaaaa", Some((0, 6)), Some((0, 2)), Some((0, 2)), None, Some((2, 4)), Some((2, 4)), None, Some((4, 6)), Some((4, 6)), None} +mat!{match_repetition_79, r"((..)|(.)){1}", r"aaaaaa", Some((0, 2)), Some((0, 2)), Some((0, 2)), None} +mat!{match_repetition_80, r"((..)|(.)){2}", r"aaaaaa", Some((0, 4)), Some((2, 4)), Some((2, 4)), None} +mat!{match_repetition_81, r"((..)|(.)){3}", r"aaaaaa", Some((0, 6)), Some((4, 6)), Some((4, 6)), None} +mat!{match_repetition_83, r"((..)|(.))*", r"aaaaaa", Some((0, 6)), Some((4, 6)), Some((4, 6)), None} +mat!{match_repetition_90, r"X(.?){0,}Y", r"X1234567Y", Some((0, 9)), Some((7, 8))} +mat!{match_repetition_91, r"X(.?){1,}Y", r"X1234567Y", Some((0, 9)), Some((7, 8))} +mat!{match_repetition_92, r"X(.?){2,}Y", r"X1234567Y", Some((0, 9)), Some((7, 8))} +mat!{match_repetition_93, r"X(.?){3,}Y", r"X1234567Y", Some((0, 9)), Some((7, 8))} +mat!{match_repetition_94, r"X(.?){4,}Y", r"X1234567Y", Some((0, 9)), Some((7, 8))} +mat!{match_repetition_95, r"X(.?){5,}Y", r"X1234567Y", Some((0, 9)), Some((7, 8))} +mat!{match_repetition_96, r"X(.?){6,}Y", r"X1234567Y", Some((0, 9)), Some((7, 8))} +mat!{match_repetition_97, r"X(.?){7,}Y", r"X1234567Y", Some((0, 9)), Some((7, 8))} +mat!{match_repetition_98, r"X(.?){8,}Y", r"X1234567Y", Some((0, 9)), Some((8, 8))} +mat!{match_repetition_100, r"X(.?){0,8}Y", r"X1234567Y", Some((0, 9)), Some((8, 8))} +mat!{match_repetition_102, r"X(.?){1,8}Y", r"X1234567Y", Some((0, 9)), Some((8, 8))} +mat!{match_repetition_104, r"X(.?){2,8}Y", r"X1234567Y", Some((0, 9)), Some((8, 8))} +mat!{match_repetition_106, r"X(.?){3,8}Y", r"X1234567Y", Some((0, 9)), Some((8, 8))} +mat!{match_repetition_108, r"X(.?){4,8}Y", r"X1234567Y", Some((0, 9)), Some((8, 8))} +mat!{match_repetition_110, r"X(.?){5,8}Y", r"X1234567Y", Some((0, 9)), Some((8, 8))} +mat!{match_repetition_112, r"X(.?){6,8}Y", r"X1234567Y", Some((0, 9)), Some((8, 8))} +mat!{match_repetition_114, r"X(.?){7,8}Y", r"X1234567Y", Some((0, 9)), Some((8, 8))} +mat!{match_repetition_115, r"X(.?){8,8}Y", r"X1234567Y", Some((0, 9)), Some((8, 8))} +mat!{match_repetition_126, r"(a|ab|c|bcd){0,}(d*)", r"ababcd", Some((0, 1)), Some((0, 1)), Some((1, 1))} +mat!{match_repetition_127, r"(a|ab|c|bcd){1,}(d*)", r"ababcd", Some((0, 1)), Some((0, 1)), Some((1, 1))} +mat!{match_repetition_128, r"(a|ab|c|bcd){2,}(d*)", r"ababcd", Some((0, 6)), Some((3, 6)), Some((6, 6))} +mat!{match_repetition_129, r"(a|ab|c|bcd){3,}(d*)", r"ababcd", Some((0, 6)), Some((3, 6)), Some((6, 6))} +mat!{match_repetition_130, r"(a|ab|c|bcd){4,}(d*)", r"ababcd", None} +mat!{match_repetition_131, r"(a|ab|c|bcd){0,10}(d*)", r"ababcd", Some((0, 1)), Some((0, 1)), Some((1, 1))} +mat!{match_repetition_132, r"(a|ab|c|bcd){1,10}(d*)", r"ababcd", Some((0, 1)), Some((0, 1)), Some((1, 1))} +mat!{match_repetition_133, r"(a|ab|c|bcd){2,10}(d*)", r"ababcd", Some((0, 6)), Some((3, 6)), Some((6, 6))} +mat!{match_repetition_134, r"(a|ab|c|bcd){3,10}(d*)", r"ababcd", Some((0, 6)), Some((3, 6)), Some((6, 6))} +mat!{match_repetition_135, r"(a|ab|c|bcd){4,10}(d*)", r"ababcd", None} +mat!{match_repetition_136, r"(a|ab|c|bcd)*(d*)", r"ababcd", Some((0, 1)), Some((0, 1)), Some((1, 1))} +mat!{match_repetition_137, r"(a|ab|c|bcd)+(d*)", r"ababcd", Some((0, 1)), Some((0, 1)), Some((1, 1))} +mat!{match_repetition_143, r"(ab|a|c|bcd){0,}(d*)", r"ababcd", Some((0, 6)), Some((4, 5)), Some((5, 6))} +mat!{match_repetition_145, r"(ab|a|c|bcd){1,}(d*)", r"ababcd", Some((0, 6)), Some((4, 5)), Some((5, 6))} +mat!{match_repetition_147, r"(ab|a|c|bcd){2,}(d*)", r"ababcd", Some((0, 6)), Some((4, 5)), Some((5, 6))} +mat!{match_repetition_149, r"(ab|a|c|bcd){3,}(d*)", r"ababcd", Some((0, 6)), Some((4, 5)), Some((5, 6))} +mat!{match_repetition_150, r"(ab|a|c|bcd){4,}(d*)", r"ababcd", None} +mat!{match_repetition_152, r"(ab|a|c|bcd){0,10}(d*)", r"ababcd", Some((0, 6)), Some((4, 5)), Some((5, 6))} +mat!{match_repetition_154, r"(ab|a|c|bcd){1,10}(d*)", r"ababcd", Some((0, 6)), Some((4, 5)), Some((5, 6))} +mat!{match_repetition_156, r"(ab|a|c|bcd){2,10}(d*)", r"ababcd", Some((0, 6)), Some((4, 5)), Some((5, 6))} +mat!{match_repetition_158, r"(ab|a|c|bcd){3,10}(d*)", r"ababcd", Some((0, 6)), Some((4, 5)), Some((5, 6))} +mat!{match_repetition_159, r"(ab|a|c|bcd){4,10}(d*)", r"ababcd", None} +mat!{match_repetition_161, r"(ab|a|c|bcd)*(d*)", r"ababcd", Some((0, 6)), Some((4, 5)), Some((5, 6))} +mat!{match_repetition_163, r"(ab|a|c|bcd)+(d*)", r"ababcd", Some((0, 6)), Some((4, 5)), Some((5, 6))} diff --git a/src/libregex/test/mod.rs b/src/libregex/test/mod.rs index 7f014b4eb68..14156647191 100644 --- a/src/libregex/test/mod.rs +++ b/src/libregex/test/mod.rs @@ -26,14 +26,14 @@ mod native_static; // Due to macro scoping rules, this definition only applies for the modules // defined below. Effectively, it allows us to use the same tests for both // native and dynamic regexes. -macro_rules! regex( +macro_rules! regex { ($re:expr) => ( match ::regex::Regex::new($re) { Ok(re) => re, Err(err) => panic!("{}", err), } ); -) +} #[path = "bench.rs"] mod dynamic_bench; diff --git a/src/libregex/test/tests.rs b/src/libregex/test/tests.rs index 27091b6ef4b..2f66d483d80 100644 --- a/src/libregex/test/tests.rs +++ b/src/libregex/test/tests.rs @@ -67,7 +67,7 @@ fn range_ends_with_escape() { assert_eq!(ms, vec![(0, 1), (1, 2)]); } -macro_rules! replace( +macro_rules! replace { ($name:ident, $which:ident, $re:expr, $search:expr, $replace:expr, $result:expr) => ( #[test] @@ -76,23 +76,23 @@ macro_rules! replace( assert_eq!(re.$which($search, $replace), String::from_str($result)); } ); -) - -replace!(rep_first, replace, r"\d", "age: 26", "Z", "age: Z6") -replace!(rep_plus, replace, r"\d+", "age: 26", "Z", "age: Z") -replace!(rep_all, replace_all, r"\d", "age: 26", "Z", "age: ZZ") -replace!(rep_groups, replace, r"(\S+)\s+(\S+)", "w1 w2", "$2 $1", "w2 w1") -replace!(rep_double_dollar, replace, - r"(\S+)\s+(\S+)", "w1 w2", "$2 $$1", "w2 $1") -replace!(rep_no_expand, replace, - r"(\S+)\s+(\S+)", "w1 w2", NoExpand("$2 $1"), "$2 $1") -replace!(rep_named, replace_all, +} + +replace!{rep_first, replace, r"\d", "age: 26", "Z", "age: Z6"} +replace!{rep_plus, replace, r"\d+", "age: 26", "Z", "age: Z"} +replace!{rep_all, replace_all, r"\d", "age: 26", "Z", "age: ZZ"} +replace!{rep_groups, replace, r"(\S+)\s+(\S+)", "w1 w2", "$2 $1", "w2 w1"} +replace!{rep_double_dollar, replace, + r"(\S+)\s+(\S+)", "w1 w2", "$2 $$1", "w2 $1"} +replace!{rep_no_expand, replace, + r"(\S+)\s+(\S+)", "w1 w2", NoExpand("$2 $1"), "$2 $1"} +replace!{rep_named, replace_all, r"(?P<first>\S+)\s+(?P<last>\S+)(?P<space>\s*)", - "w1 w2 w3 w4", "$last $first$space", "w2 w1 w4 w3") -replace!(rep_trim, replace_all, "^[ \t]+|[ \t]+$", " \t trim me\t \t", - "", "trim me") + "w1 w2 w3 w4", "$last $first$space", "w2 w1 w4 w3"} +replace!{rep_trim, replace_all, "^[ \t]+|[ \t]+$", " \t trim me\t \t", + "", "trim me"} -macro_rules! noparse( +macro_rules! noparse { ($name:ident, $re:expr) => ( #[test] fn $name() { @@ -103,47 +103,47 @@ macro_rules! noparse( } } ); -) - -noparse!(fail_double_repeat, "a**") -noparse!(fail_no_repeat_arg, "*") -noparse!(fail_no_repeat_arg_begin, "^*") -noparse!(fail_incomplete_escape, "\\") -noparse!(fail_class_incomplete, "[A-") -noparse!(fail_class_not_closed, "[A") -noparse!(fail_class_no_begin, r"[\A]") -noparse!(fail_class_no_end, r"[\z]") -noparse!(fail_class_no_boundary, r"[\b]") -noparse!(fail_open_paren, "(") -noparse!(fail_close_paren, ")") -noparse!(fail_invalid_range, "[a-Z]") -noparse!(fail_empty_capture_name, "(?P<>a)") -noparse!(fail_empty_capture_exp, "(?P<name>)") -noparse!(fail_bad_capture_name, "(?P<na-me>)") -noparse!(fail_bad_flag, "(?a)a") -noparse!(fail_empty_alt_before, "|a") -noparse!(fail_empty_alt_after, "a|") -noparse!(fail_counted_big_exact, "a{1001}") -noparse!(fail_counted_big_min, "a{1001,}") -noparse!(fail_counted_no_close, "a{1001") -noparse!(fail_unfinished_cap, "(?") -noparse!(fail_unfinished_escape, "\\") -noparse!(fail_octal_digit, r"\8") -noparse!(fail_hex_digit, r"\xG0") -noparse!(fail_hex_short, r"\xF") -noparse!(fail_hex_long_digits, r"\x{fffg}") -noparse!(fail_flag_bad, "(?a)") -noparse!(fail_flag_empty, "(?)") -noparse!(fail_double_neg, "(?-i-i)") -noparse!(fail_neg_empty, "(?i-)") -noparse!(fail_empty_group, "()") -noparse!(fail_dupe_named, "(?P<a>.)(?P<a>.)") -noparse!(fail_range_end_no_class, "[a-[:lower:]]") -noparse!(fail_range_end_no_begin, r"[a-\A]") -noparse!(fail_range_end_no_end, r"[a-\z]") -noparse!(fail_range_end_no_boundary, r"[a-\b]") - -macro_rules! mat( +} + +noparse!{fail_double_repeat, "a**"} +noparse!{fail_no_repeat_arg, "*"} +noparse!{fail_no_repeat_arg_begin, "^*"} +noparse!{fail_incomplete_escape, "\\"} +noparse!{fail_class_incomplete, "[A-"} +noparse!{fail_class_not_closed, "[A"} +noparse!{fail_class_no_begin, r"[\A]"} +noparse!{fail_class_no_end, r"[\z]"} +noparse!{fail_class_no_boundary, r"[\b]"} +noparse!{fail_open_paren, "("} +noparse!{fail_close_paren, ")"} +noparse!{fail_invalid_range, "[a-Z]"} +noparse!{fail_empty_capture_name, "(?P<>a)"} +noparse!{fail_empty_capture_exp, "(?P<name>)"} +noparse!{fail_bad_capture_name, "(?P<na-me>)"} +noparse!{fail_bad_flag, "(?a)a"} +noparse!{fail_empty_alt_before, "|a"} +noparse!{fail_empty_alt_after, "a|"} +noparse!{fail_counted_big_exact, "a{1001}"} +noparse!{fail_counted_big_min, "a{1001,}"} +noparse!{fail_counted_no_close, "a{1001"} +noparse!{fail_unfinished_cap, "(?"} +noparse!{fail_unfinished_escape, "\\"} +noparse!{fail_octal_digit, r"\8"} +noparse!{fail_hex_digit, r"\xG0"} +noparse!{fail_hex_short, r"\xF"} +noparse!{fail_hex_long_digits, r"\x{fffg}"} +noparse!{fail_flag_bad, "(?a)"} +noparse!{fail_flag_empty, "(?)"} +noparse!{fail_double_neg, "(?-i-i)"} +noparse!{fail_neg_empty, "(?i-)"} +noparse!{fail_empty_group, "()"} +noparse!{fail_dupe_named, "(?P<a>.)(?P<a>.)"} +noparse!{fail_range_end_no_class, "[a-[:lower:]]"} +noparse!{fail_range_end_no_begin, r"[a-\A]"} +noparse!{fail_range_end_no_end, r"[a-\z]"} +noparse!{fail_range_end_no_boundary, r"[a-\b]"} + +macro_rules! mat { ($name:ident, $re:expr, $text:expr, $($loc:tt)+) => ( #[test] fn $name() { @@ -166,78 +166,78 @@ macro_rules! mat( } } ); -) +} // Some crazy expressions from regular-expressions.info. -mat!(match_ranges, +mat!{match_ranges, r"\b(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b", - "num: 255", Some((5, 8))) -mat!(match_ranges_not, + "num: 255", Some((5, 8))} +mat!{match_ranges_not, r"\b(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b", - "num: 256", None) -mat!(match_float1, r"[-+]?[0-9]*\.?[0-9]+", "0.1", Some((0, 3))) -mat!(match_float2, r"[-+]?[0-9]*\.?[0-9]+", "0.1.2", Some((0, 3))) -mat!(match_float3, r"[-+]?[0-9]*\.?[0-9]+", "a1.2", Some((1, 4))) -mat!(match_float4, r"^[-+]?[0-9]*\.?[0-9]+$", "1.a", None) -mat!(match_email, r"(?i)\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b", - "mine is jam.slam@gmail.com ", Some((8, 26))) -mat!(match_email_not, r"(?i)\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b", - "mine is jam.slam@gmail ", None) -mat!(match_email_big, r"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", - "mine is jam.slam@gmail.com ", Some((8, 26))) -mat!(match_date1, + "num: 256", None} +mat!{match_float1, r"[-+]?[0-9]*\.?[0-9]+", "0.1", Some((0, 3))} +mat!{match_float2, r"[-+]?[0-9]*\.?[0-9]+", "0.1.2", Some((0, 3))} +mat!{match_float3, r"[-+]?[0-9]*\.?[0-9]+", "a1.2", Some((1, 4))} +mat!{match_float4, r"^[-+]?[0-9]*\.?[0-9]+$", "1.a", None} +mat!{match_email, r"(?i)\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b", + "mine is jam.slam@gmail.com ", Some((8, 26))} +mat!{match_email_not, r"(?i)\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b", + "mine is jam.slam@gmail ", None} +mat!{match_email_big, r"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", + "mine is jam.slam@gmail.com ", Some((8, 26))} +mat!{match_date1, r"^(19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])$", - "1900-01-01", Some((0, 10))) -mat!(match_date2, + "1900-01-01", Some((0, 10))} +mat!{match_date2, r"^(19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])$", - "1900-00-01", None) -mat!(match_date3, + "1900-00-01", None} +mat!{match_date3, r"^(19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])$", - "1900-13-01", None) + "1900-13-01", None} // Exercise the flags. -mat!(match_flag_case, "(?i)abc", "ABC", Some((0, 3))) -mat!(match_flag_weird_case, "(?i)a(?-i)bc", "Abc", Some((0, 3))) -mat!(match_flag_weird_case_not, "(?i)a(?-i)bc", "ABC", None) -mat!(match_flag_case_dotnl, "(?is)a.", "A\n", Some((0, 2))) -mat!(match_flag_case_dotnl_toggle, "(?is)a.(?-is)a.", "A\nab", Some((0, 4))) -mat!(match_flag_case_dotnl_toggle_not, "(?is)a.(?-is)a.", "A\na\n", None) -mat!(match_flag_case_dotnl_toggle_ok, "(?is)a.(?-is:a.)?", "A\na\n", Some((0, 2))) -mat!(match_flag_multi, "(?m)(?:^\\d+$\n?)+", "123\n456\n789", Some((0, 11))) -mat!(match_flag_ungreedy, "(?U)a+", "aa", Some((0, 1))) -mat!(match_flag_ungreedy_greedy, "(?U)a+?", "aa", Some((0, 2))) -mat!(match_flag_ungreedy_noop, "(?U)(?-U)a+", "aa", Some((0, 2))) +mat!{match_flag_case, "(?i)abc", "ABC", Some((0, 3))} +mat!{match_flag_weird_case, "(?i)a(?-i)bc", "Abc", Some((0, 3))} +mat!{match_flag_weird_case_not, "(?i)a(?-i)bc", "ABC", None} +mat!{match_flag_case_dotnl, "(?is)a.", "A\n", Some((0, 2))} +mat!{match_flag_case_dotnl_toggle, "(?is)a.(?-is)a.", "A\nab", Some((0, 4))} +mat!{match_flag_case_dotnl_toggle_not, "(?is)a.(?-is)a.", "A\na\n", None} +mat!{match_flag_case_dotnl_toggle_ok, "(?is)a.(?-is:a.)?", "A\na\n", Some((0, 2))} +mat!{match_flag_multi, "(?m)(?:^\\d+$\n?)+", "123\n456\n789", Some((0, 11))} +mat!{match_flag_ungreedy, "(?U)a+", "aa", Some((0, 1))} +mat!{match_flag_ungreedy_greedy, "(?U)a+?", "aa", Some((0, 2))} +mat!{match_flag_ungreedy_noop, "(?U)(?-U)a+", "aa", Some((0, 2))} // Some Unicode tests. // A couple of these are commented out because something in the guts of macro expansion is creating // invalid byte strings. -//mat!(uni_literal, r"â… ", "â… ", Some((0, 3))) -mat!(uni_one, r"\pN", "â… ", Some((0, 3))) -mat!(uni_mixed, r"\pN+", "â… 1â…¡2", Some((0, 8))) -mat!(uni_not, r"\PN+", "abâ… ", Some((0, 2))) -mat!(uni_not_class, r"[\PN]+", "abâ… ", Some((0, 2))) -mat!(uni_not_class_neg, r"[^\PN]+", "abâ… ", Some((2, 5))) -mat!(uni_case, r"(?i)Δ", "δ", Some((0, 2))) -//mat!(uni_case_not, r"Δ", "δ", None) -mat!(uni_case_upper, r"\p{Lu}+", "ΛΘΓΔα", Some((0, 8))) -mat!(uni_case_upper_nocase_flag, r"(?i)\p{Lu}+", "ΛΘΓΔα", Some((0, 10))) -mat!(uni_case_upper_nocase, r"\p{L}+", "ΛΘΓΔα", Some((0, 10))) -mat!(uni_case_lower, r"\p{Ll}+", "ΛΘΓΔα", Some((8, 10))) +//mat!{uni_literal, r"â… ", "â… ", Some((0, 3))} +mat!{uni_one, r"\pN", "â… ", Some((0, 3))} +mat!{uni_mixed, r"\pN+", "â… 1â…¡2", Some((0, 8))} +mat!{uni_not, r"\PN+", "abâ… ", Some((0, 2))} +mat!{uni_not_class, r"[\PN]+", "abâ… ", Some((0, 2))} +mat!{uni_not_class_neg, r"[^\PN]+", "abâ… ", Some((2, 5))} +mat!{uni_case, r"(?i)Δ", "δ", Some((0, 2))} +//mat!{uni_case_not, r"Δ", "δ", None} +mat!{uni_case_upper, r"\p{Lu}+", "ΛΘΓΔα", Some((0, 8))} +mat!{uni_case_upper_nocase_flag, r"(?i)\p{Lu}+", "ΛΘΓΔα", Some((0, 10))} +mat!{uni_case_upper_nocase, r"\p{L}+", "ΛΘΓΔα", Some((0, 10))} +mat!{uni_case_lower, r"\p{Ll}+", "ΛΘΓΔα", Some((8, 10))} // Test the Unicode friendliness of Perl character classes. -mat!(uni_perl_w, r"\w+", "dδd", Some((0, 4))) -mat!(uni_perl_w_not, r"\w+", "⥡", None) -mat!(uni_perl_w_neg, r"\W+", "⥡", Some((0, 3))) -mat!(uni_perl_d, r"\d+", "1२३9", Some((0, 8))) -mat!(uni_perl_d_not, r"\d+", "â…¡", None) -mat!(uni_perl_d_neg, r"\D+", "â…¡", Some((0, 3))) -mat!(uni_perl_s, r"\s+", " ", Some((0, 3))) -mat!(uni_perl_s_not, r"\s+", "☃", None) -mat!(uni_perl_s_neg, r"\S+", "☃", Some((0, 3))) +mat!{uni_perl_w, r"\w+", "dδd", Some((0, 4))} +mat!{uni_perl_w_not, r"\w+", "⥡", None} +mat!{uni_perl_w_neg, r"\W+", "⥡", Some((0, 3))} +mat!{uni_perl_d, r"\d+", "1२३9", Some((0, 8))} +mat!{uni_perl_d_not, r"\d+", "â…¡", None} +mat!{uni_perl_d_neg, r"\D+", "â…¡", Some((0, 3))} +mat!{uni_perl_s, r"\s+", " ", Some((0, 3))} +mat!{uni_perl_s_not, r"\s+", "☃", None} +mat!{uni_perl_s_neg, r"\S+", "☃", Some((0, 3))} // And do the same for word boundaries. -mat!(uni_boundary_none, r"\d\b", "6δ", None) -mat!(uni_boundary_ogham, r"\d\b", "6 ", Some((0, 1))) +mat!{uni_boundary_none, r"\d\b", "6δ", None} +mat!{uni_boundary_ogham, r"\d\b", "6 ", Some((0, 1))} // A whole mess of tests from Glenn Fowler's regex test suite. // Generated by the 'src/etc/regex-match-tests' program. diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index fcac718b370..4c3cb99f64d 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -10,16 +10,16 @@ #![allow(non_snake_case)] -register_diagnostic!(E0001, r##" +register_diagnostic! { E0001, r##" This error suggests that the expression arm corresponding to the noted pattern will never be reached as for all possible values of the expression being matched, one of the preceeding patterns will match. This means that perhaps some of the preceeding patterns are too general, this one is too specific or the ordering is incorrect. -"##) +"## } -register_diagnostics!( +register_diagnostics! { E0002, E0003, E0004, @@ -68,4 +68,4 @@ register_diagnostics!( E0174, E0177, E0178 -) +} diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 404c7edeb88..d87fbb01620 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -121,7 +121,7 @@ pub mod lib { pub use llvm; } -__build_diagnostic_array!(DIAGNOSTICS) +__build_diagnostic_array! { DIAGNOSTICS } // A private module so that macro-expanded idents like // `::rustc::lint::Lint` will also work in `rustc` itself. diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 3040125d97e..8c25bc702b3 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -50,8 +50,11 @@ use syntax::ast_util; use syntax::ptr::P; use syntax::visit::{mod, Visitor}; -declare_lint!(WHILE_TRUE, Warn, - "suggest using `loop { }` instead of `while true { }`") +declare_lint! { + WHILE_TRUE, + Warn, + "suggest using `loop { }` instead of `while true { }`" +} pub struct WhileTrue; @@ -74,8 +77,11 @@ impl LintPass for WhileTrue { } } -declare_lint!(UNUSED_TYPECASTS, Allow, - "detects unnecessary type casts, that can be removed") +declare_lint! { + UNUSED_TYPECASTS, + Allow, + "detects unnecessary type casts that can be removed" +} pub struct UnusedCasts; @@ -96,17 +102,29 @@ impl LintPass for UnusedCasts { } } -declare_lint!(UNSIGNED_NEGATION, Warn, - "using an unary minus operator on unsigned type") +declare_lint! { + UNSIGNED_NEGATION, + Warn, + "using an unary minus operator on unsigned type" +} -declare_lint!(UNUSED_COMPARISONS, Warn, - "comparisons made useless by limits of the types involved") +declare_lint! { + UNUSED_COMPARISONS, + Warn, + "comparisons made useless by limits of the types involved" +} -declare_lint!(OVERFLOWING_LITERALS, Warn, - "literal out of range for its type") +declare_lint! { + OVERFLOWING_LITERALS, + Warn, + "literal out of range for its type" +} -declare_lint!(EXCEEDING_BITSHIFTS, Deny, - "shift exceeds the type's number of bits") +declare_lint! { + EXCEEDING_BITSHIFTS, + Deny, + "shift exceeds the type's number of bits" +} pub struct TypeLimits { /// Id of the last visited negated expression @@ -373,8 +391,11 @@ impl LintPass for TypeLimits { } } -declare_lint!(IMPROPER_CTYPES, Warn, - "proper use of libc types in foreign modules") +declare_lint! { + IMPROPER_CTYPES, + Warn, + "proper use of libc types in foreign modules" +} struct ImproperCTypesVisitor<'a, 'tcx: 'a> { cx: &'a Context<'a, 'tcx> @@ -459,8 +480,11 @@ impl LintPass for ImproperCTypes { } } -declare_lint!(BOX_POINTERS, Allow, - "use of owned (Box type) heap memory") +declare_lint! { + BOX_POINTERS, + Allow, + "use of owned (Box type) heap memory" +} pub struct BoxPointers; @@ -527,8 +551,11 @@ impl LintPass for BoxPointers { } } -declare_lint!(RAW_POINTER_DERIVING, Warn, - "uses of #[deriving] with raw pointers are rarely correct") +declare_lint! { + RAW_POINTER_DERIVING, + Warn, + "uses of #[deriving] with raw pointers are rarely correct" +} struct RawPtrDerivingVisitor<'a, 'tcx: 'a> { cx: &'a Context<'a, 'tcx> @@ -594,8 +621,11 @@ impl LintPass for RawPointerDeriving { } } -declare_lint!(UNUSED_ATTRIBUTES, Warn, - "detects attributes that were not used by the compiler") +declare_lint! { + UNUSED_ATTRIBUTES, + Warn, + "detects attributes that were not used by the compiler" +} pub struct UnusedAttributes; @@ -675,8 +705,11 @@ impl LintPass for UnusedAttributes { } } -declare_lint!(pub PATH_STATEMENTS, Warn, - "path statements with no effect") +declare_lint! { + pub PATH_STATEMENTS, + Warn, + "path statements with no effect" +} pub struct PathStatements; @@ -701,11 +734,17 @@ impl LintPass for PathStatements { } } -declare_lint!(pub UNUSED_MUST_USE, Warn, - "unused result of a type flagged as #[must_use]") +declare_lint! { + pub UNUSED_MUST_USE, + Warn, + "unused result of a type flagged as #[must_use]" +} -declare_lint!(pub UNUSED_RESULTS, Allow, - "unused result of an expression in a statement") +declare_lint! { + pub UNUSED_RESULTS, + Allow, + "unused result of an expression in a statement" +} pub struct UnusedResults; @@ -770,8 +809,11 @@ impl LintPass for UnusedResults { } } -declare_lint!(pub NON_CAMEL_CASE_TYPES, Warn, - "types, variants, traits and type parameters should have camel case names") +declare_lint! { + pub NON_CAMEL_CASE_TYPES, + Warn, + "types, variants, traits and type parameters should have camel case names" +} pub struct NonCamelCaseTypes; @@ -891,8 +933,11 @@ fn method_context(cx: &Context, m: &ast::Method) -> MethodContext { } } -declare_lint!(pub NON_SNAKE_CASE, Warn, - "methods, functions, lifetime parameters and modules should have snake case names") +declare_lint! { + pub NON_SNAKE_CASE, + Warn, + "methods, functions, lifetime parameters and modules should have snake case names" +} pub struct NonSnakeCase; @@ -1002,8 +1047,11 @@ impl LintPass for NonSnakeCase { } } -declare_lint!(pub NON_UPPER_CASE_GLOBALS, Warn, - "static constants should have uppercase identifiers") +declare_lint! { + pub NON_UPPER_CASE_GLOBALS, + Warn, + "static constants should have uppercase identifiers" +} pub struct NonUpperCaseGlobals; @@ -1053,8 +1101,11 @@ impl LintPass for NonUpperCaseGlobals { } } -declare_lint!(UNUSED_PARENS, Warn, - "`if`, `match`, `while` and `return` do not need parentheses") +declare_lint! { + UNUSED_PARENS, + Warn, + "`if`, `match`, `while` and `return` do not need parentheses" +} pub struct UnusedParens; @@ -1145,8 +1196,11 @@ impl LintPass for UnusedParens { } } -declare_lint!(UNUSED_IMPORT_BRACES, Allow, - "unnecessary braces around an imported item") +declare_lint! { + UNUSED_IMPORT_BRACES, + Allow, + "unnecessary braces around an imported item" +} pub struct UnusedImportBraces; @@ -1182,8 +1236,11 @@ impl LintPass for UnusedImportBraces { } } -declare_lint!(NON_SHORTHAND_FIELD_PATTERNS, Warn, - "using `Struct { x: x }` instead of `Struct { x }`") +declare_lint! { + NON_SHORTHAND_FIELD_PATTERNS, + Warn, + "using `Struct { x: x }` instead of `Struct { x }`" +} pub struct NonShorthandFieldPatterns; @@ -1213,8 +1270,11 @@ impl LintPass for NonShorthandFieldPatterns { } } -declare_lint!(pub UNUSED_UNSAFE, Warn, - "unnecessary use of an `unsafe` block") +declare_lint! { + pub UNUSED_UNSAFE, + Warn, + "unnecessary use of an `unsafe` block" +} pub struct UnusedUnsafe; @@ -1236,8 +1296,11 @@ impl LintPass for UnusedUnsafe { } } -declare_lint!(UNSAFE_BLOCKS, Allow, - "usage of an `unsafe` block") +declare_lint! { + UNSAFE_BLOCKS, + Allow, + "usage of an `unsafe` block" +} pub struct UnsafeBlocks; @@ -1258,8 +1321,11 @@ impl LintPass for UnsafeBlocks { } } -declare_lint!(pub UNUSED_MUT, Warn, - "detect mut variables which don't need to be mutable") +declare_lint! { + pub UNUSED_MUT, + Warn, + "detect mut variables which don't need to be mutable" +} pub struct UnusedMut; @@ -1325,8 +1391,11 @@ impl LintPass for UnusedMut { } } -declare_lint!(UNUSED_ALLOCATION, Warn, - "detects unnecessary allocations that can be eliminated") +declare_lint! { + UNUSED_ALLOCATION, + Warn, + "detects unnecessary allocations that can be eliminated" +} pub struct UnusedAllocation; @@ -1361,8 +1430,11 @@ impl LintPass for UnusedAllocation { } } -declare_lint!(MISSING_DOCS, Allow, - "detects missing documentation for public members") +declare_lint! { + MISSING_DOCS, + Allow, + "detects missing documentation for public members" +} pub struct MissingDoc { /// Stack of IDs of struct definitions. @@ -1572,15 +1644,24 @@ impl LintPass for MissingCopyImplementations { } } -declare_lint!(DEPRECATED, Warn, - "detects use of #[deprecated] items") +declare_lint! { + DEPRECATED, + Warn, + "detects use of #[deprecated] items" +} // FIXME #6875: Change to Warn after std library stabilization is complete -declare_lint!(EXPERIMENTAL, Allow, - "detects use of #[experimental] items") +declare_lint! { + EXPERIMENTAL, + Allow, + "detects use of #[experimental] items" +} -declare_lint!(UNSTABLE, Allow, - "detects use of #[unstable] items (incl. items with no stability attribute)") +declare_lint! { + UNSTABLE, + Allow, + "detects use of #[unstable] items (incl. items with no stability attribute)" +} /// Checks for use of items with `#[deprecated]`, `#[experimental]` and /// `#[unstable]` attributes, or no stability attribute. @@ -1738,47 +1819,89 @@ impl LintPass for Stability { } } -declare_lint!(pub UNUSED_IMPORTS, Warn, - "imports that are never used") +declare_lint! { + pub UNUSED_IMPORTS, + Warn, + "imports that are never used" +} -declare_lint!(pub UNUSED_EXTERN_CRATES, Allow, - "extern crates that are never used") +declare_lint! { + pub UNUSED_EXTERN_CRATES, + Allow, + "extern crates that are never used" +} -declare_lint!(pub UNUSED_QUALIFICATIONS, Allow, - "detects unnecessarily qualified names") +declare_lint! { + pub UNUSED_QUALIFICATIONS, + Allow, + "detects unnecessarily qualified names" +} -declare_lint!(pub UNKNOWN_LINTS, Warn, - "unrecognized lint attribute") +declare_lint! { + pub UNKNOWN_LINTS, + Warn, + "unrecognized lint attribute" +} -declare_lint!(pub UNUSED_VARIABLES, Warn, - "detect variables which are not used in any way") +declare_lint! { + pub UNUSED_VARIABLES, + Warn, + "detect variables which are not used in any way" +} -declare_lint!(pub UNUSED_ASSIGNMENTS, Warn, - "detect assignments that will never be read") +declare_lint! { + pub UNUSED_ASSIGNMENTS, + Warn, + "detect assignments that will never be read" +} -declare_lint!(pub DEAD_CODE, Warn, - "detect unused, unexported items") +declare_lint! { + pub DEAD_CODE, + Warn, + "detect unused, unexported items" +} -declare_lint!(pub UNREACHABLE_CODE, Warn, - "detects unreachable code paths") +declare_lint! { + pub UNREACHABLE_CODE, + Warn, + "detects unreachable code paths" +} -declare_lint!(pub WARNINGS, Warn, - "mass-change the level for lints which produce warnings") +declare_lint! { + pub WARNINGS, + Warn, + "mass-change the level for lints which produce warnings" +} -declare_lint!(pub UNKNOWN_FEATURES, Deny, - "unknown features found in crate-level #[feature] directives") +declare_lint! { + pub UNKNOWN_FEATURES, + Deny, + "unknown features found in crate-level #[feature] directives" +} -declare_lint!(pub UNKNOWN_CRATE_TYPES, Deny, - "unknown crate type found in #[crate_type] directive") +declare_lint! { + pub UNKNOWN_CRATE_TYPES, + Deny, + "unknown crate type found in #[crate_type] directive" +} -declare_lint!(pub VARIANT_SIZE_DIFFERENCES, Allow, - "detects enums with widely varying variant sizes") +declare_lint! { + pub VARIANT_SIZE_DIFFERENCES, + Allow, + "detects enums with widely varying variant sizes" +} -declare_lint!(pub FAT_PTR_TRANSMUTES, Allow, - "detects transmutes of fat pointers") +declare_lint! { + pub FAT_PTR_TRANSMUTES, + Allow, + "detects transmutes of fat pointers" +} -declare_lint!(pub MISSING_COPY_IMPLEMENTATIONS, Warn, - "detects potentially-forgotten implementations of `Copy`") +declare_lint!{ + pub MISSING_COPY_IMPLEMENTATIONS, + Warn, + "detects potentially-forgotten implementations of `Copy`" +} /// Does nothing as a lint pass, but registers some `Lint`s /// which are used by other parts of the compiler. diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 75f2fc81900..d8d9d653e62 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -171,17 +171,17 @@ impl LintStore { {$( self.register_pass($sess, false, box builtin::$name as LintPassObject); )*} - )) + )); macro_rules! add_builtin_with_new ( ( $sess:ident, $($name:ident),*, ) => ( {$( self.register_pass($sess, false, box builtin::$name::new() as LintPassObject); )*} - )) + )); macro_rules! add_lint_group ( ( $sess:ident, $name:expr, $($lint:ident),* ) => ( self.register_group($sess, false, $name, vec![$(LintId::of(builtin::$lint)),*]); - )) + )); add_builtin!(sess, HardwiredLints, @@ -204,21 +204,21 @@ impl LintStore { UnusedAllocation, Stability, MissingCopyImplementations, - ) + ); add_builtin_with_new!(sess, TypeLimits, RawPointerDeriving, MissingDoc, - ) + ); add_lint_group!(sess, "bad_style", - NON_CAMEL_CASE_TYPES, NON_SNAKE_CASE, NON_UPPER_CASE_GLOBALS) + NON_CAMEL_CASE_TYPES, NON_SNAKE_CASE, NON_UPPER_CASE_GLOBALS); add_lint_group!(sess, "unused", UNUSED_IMPORTS, UNUSED_VARIABLES, UNUSED_ASSIGNMENTS, DEAD_CODE, UNUSED_MUT, UNREACHABLE_CODE, UNUSED_MUST_USE, - UNUSED_UNSAFE, PATH_STATEMENTS) + UNUSED_UNSAFE, PATH_STATEMENTS); // We have one lint pass defined in this module. self.register_pass(sess, false, box GatherNodeLevels as LintPassObject); @@ -318,7 +318,7 @@ pub struct Context<'a, 'tcx: 'a> { } /// Convenience macro for calling a `LintPass` method on every pass in the context. -macro_rules! run_lints ( ($cx:expr, $f:ident, $($args:expr),*) => ({ +macro_rules! run_lints { ($cx:expr, $f:ident, $($args:expr),*) => ({ // Move the vector of passes out of `$cx` so that we can // iterate over it mutably while passing `$cx` to the methods. let mut passes = $cx.lints.passes.take().unwrap(); @@ -326,7 +326,7 @@ macro_rules! run_lints ( ($cx:expr, $f:ident, $($args:expr),*) => ({ obj.$f($cx, $($args),*); } $cx.lints.passes = Some(passes); -})) +}) } /// Parse the lint attributes into a vector, with `Err`s for malformed lint /// attributes. Writing this as an iterator is an enormous mess. diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs index 4b4ba2ab94c..79d57305f96 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc/lint/mod.rs @@ -75,7 +75,7 @@ impl Lint { /// Build a `Lint` initializer. #[macro_export] -macro_rules! lint_initializer ( +macro_rules! lint_initializer { ($name:ident, $level:ident, $desc:expr) => ( ::rustc::lint::Lint { name: stringify!($name), @@ -83,11 +83,11 @@ macro_rules! lint_initializer ( desc: $desc, } ) -) +} /// Declare a static item of type `&'static Lint`. #[macro_export] -macro_rules! declare_lint ( +macro_rules! declare_lint { // FIXME(#14660): deduplicate (pub $name:ident, $level:ident, $desc:expr) => ( pub static $name: &'static ::rustc::lint::Lint @@ -97,17 +97,17 @@ macro_rules! declare_lint ( static $name: &'static ::rustc::lint::Lint = &lint_initializer!($name, $level, $desc); ); -) +} /// Declare a static `LintArray` and return it as an expression. #[macro_export] -macro_rules! lint_array ( ($( $lint:expr ),*) => ( +macro_rules! lint_array { ($( $lint:expr ),*) => ( { #[allow(non_upper_case_globals)] static array: LintArray = &[ $( &$lint ),* ]; array } -)) +) } pub type LintArray = &'static [&'static &'static Lint]; diff --git a/src/librustc/metadata/tyencode.rs b/src/librustc/metadata/tyencode.rs index 9b9d2ab42df..2a057da7db3 100644 --- a/src/librustc/metadata/tyencode.rs +++ b/src/librustc/metadata/tyencode.rs @@ -29,7 +29,7 @@ use syntax::parse::token; use rbml::io::SeekableMemWriter; -macro_rules! mywrite( ($($arg:tt)*) => ({ write!($($arg)*); }) ) +macro_rules! mywrite { ($($arg:tt)*) => ({ write!($($arg)*); }) } pub struct ctxt<'a, 'tcx: 'a> { pub diag: &'a SpanHandler, diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index 150bcbdd688..f0d52d1ac23 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -525,7 +525,7 @@ pub fn eval_const_expr_partial(tcx: &ty::ctxt, e: &Expr) -> Result<const_val, St },)* _ => Err("can't cast this type".to_string()) }) - ) + ); eval_const_expr_partial(tcx, &**base) .and_then(|val| define_casts!(val, { diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 2cb78beff4c..aacb994e5a4 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -320,14 +320,14 @@ pub struct ExprUseVisitor<'d,'t,'tcx,TYPER:'t> { // // Note that this macro appears similar to try!(), but, unlike try!(), // it does not propagate the error. -macro_rules! return_if_err( +macro_rules! return_if_err { ($inp: expr) => ( match $inp { Ok(v) => v, Err(()) => return } ) -) +} /// Whether the elements of an overloaded operation are passed by value or by reference enum PassArgs { diff --git a/src/librustc/middle/infer/error_reporting.rs b/src/librustc/middle/infer/error_reporting.rs index 5c2944f898e..ab685dd5dbc 100644 --- a/src/librustc/middle/infer/error_reporting.rs +++ b/src/librustc/middle/infer/error_reporting.rs @@ -224,7 +224,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> { for error in errors.iter() { match error.clone() { ConcreteFailure(origin, sub, sup) => { - debug!("processing ConcreteFailure") + debug!("processing ConcreteFailure"); let trace = match origin { infer::Subtype(trace) => Some(trace), _ => None, @@ -241,7 +241,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> { } } SubSupConflict(var_origin, _, sub_r, _, sup_r) => { - debug!("processing SubSupConflict") + debug!("processing SubSupConflict"); match free_regions_from_same_fn(self.tcx, sub_r, sup_r) { Some(ref same_frs) => { var_origins.push(var_origin); @@ -324,7 +324,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> { _ => None }, None => { - debug!("no parent node of scope_id {}", scope_id) + debug!("no parent node of scope_id {}", scope_id); None } } diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 86b912a579f..0e05eb4dcdd 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -389,14 +389,14 @@ impl MutabilityCategory { } } -macro_rules! if_ok( +macro_rules! if_ok { ($inp: expr) => ( match $inp { Ok(v) => { v } Err(e) => { return Err(e); } } ) -) +} impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { pub fn new(typer: &'t TYPER) -> MemCategorizationContext<'t,TYPER> { diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 84b69eb8471..b349b5ca0bf 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -1223,7 +1223,7 @@ pub fn mk_prim_t<'tcx>(primitive: &'tcx TyS<'static>) -> Ty<'tcx> { // Do not change these from static to const, interning types requires // the primitives to have a significant address. -macro_rules! def_prim_tys( +macro_rules! def_prim_tys { ($($name:ident -> $sty:expr;)*) => ( $(#[inline] pub fn $name<'tcx>() -> Ty<'tcx> { static PRIM_TY: TyS<'static> = TyS { @@ -1234,7 +1234,7 @@ macro_rules! def_prim_tys( mk_prim_t(&PRIM_TY) })* ) -) +} def_prim_tys!{ mk_bool -> ty_bool; @@ -2739,7 +2739,7 @@ pub struct TypeContents { impl Copy for TypeContents {} -macro_rules! def_type_content_sets( +macro_rules! def_type_content_sets { (mod $mname:ident { $($name:ident = $bits:expr),+ }) => { #[allow(non_snake_case)] mod $mname { @@ -2750,9 +2750,9 @@ macro_rules! def_type_content_sets( )+ } } -) +} -def_type_content_sets!( +def_type_content_sets! { mod TC { None = 0b0000_0000__0000_0000__0000, @@ -2790,7 +2790,7 @@ def_type_content_sets!( // All bits All = 0b1111_1111__1111_1111__1111 } -) +} impl TypeContents { pub fn when(&self, cond: bool) -> TypeContents { @@ -3113,7 +3113,7 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents { ty_open(ty) => { let result = tc_ty(cx, ty, cache); - assert!(!result.is_sized(cx)) + assert!(!result.is_sized(cx)); result.unsafe_pointer() | TC::Nonsized } @@ -3644,7 +3644,7 @@ pub fn unsized_part_of_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> { let unsized_fields: Vec<_> = struct_fields(cx, def_id, substs).iter() .map(|f| f.mt.ty).filter(|ty| !type_is_sized(cx, *ty)).collect(); // Exactly one of the fields must be unsized. - assert!(unsized_fields.len() == 1) + assert!(unsized_fields.len() == 1); unsized_part_of_type(cx, unsized_fields[0]) } diff --git a/src/librustc/middle/weak_lang_items.rs b/src/librustc/middle/weak_lang_items.rs index e0fe87d6d06..892a8004fec 100644 --- a/src/librustc/middle/weak_lang_items.rs +++ b/src/librustc/middle/weak_lang_items.rs @@ -23,7 +23,8 @@ use syntax::visit; use std::collections::HashSet; -macro_rules! weak_lang_items( ($($name:ident, $item:ident, $sym:ident;)*) => ( +macro_rules! weak_lang_items { + ($($name:ident, $item:ident, $sym:ident;)*) => ( struct Context<'a> { sess: &'a Session, @@ -115,10 +116,10 @@ impl<'a, 'v> Visitor<'v> for Context<'a> { } } -) ) +) } -weak_lang_items!( +weak_lang_items! { panic_fmt, PanicFmtLangItem, rust_begin_unwind; stack_exhausted, StackExhaustedLangItem, rust_stack_exhausted; eh_personality, EhPersonalityLangItem, rust_eh_personality; -) +} diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index b3b44b60b6e..59da0af417c 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -239,17 +239,17 @@ pub enum CrateType { impl Copy for CrateType {} -macro_rules! debugging_opts( +macro_rules! debugging_opts { ([ $opt:ident ] $cnt:expr ) => ( pub const $opt: u64 = 1 << $cnt; ); ([ $opt:ident, $($rest:ident),* ] $cnt:expr ) => ( pub const $opt: u64 = 1 << $cnt; - debugging_opts!([ $($rest),* ] $cnt + 1) + debugging_opts! { [ $($rest),* ] $cnt + 1 } ) -) +} -debugging_opts!( +debugging_opts! { [ VERBOSE, TIME_PASSES, @@ -280,7 +280,7 @@ debugging_opts!( PRINT_REGION_GRAPH ] 0 -) +} pub fn debugging_opts_map() -> Vec<(&'static str, &'static str, u64)> { vec![("verbose", "in general, enable more debug printouts", VERBOSE), @@ -354,7 +354,7 @@ impl Passes { /// cgsetters module which is a bunch of generated code to parse an option into /// its respective field in the struct. There are a few hand-written parsers for /// parsing specific types of values in this module. -macro_rules! cgoptions( +macro_rules! cgoptions { ($($opt:ident : $t:ty = ($init:expr, $parse:ident, $desc:expr)),* ,) => ( #[deriving(Clone)] @@ -469,9 +469,9 @@ macro_rules! cgoptions( } } } -) ) +) } -cgoptions!( +cgoptions! { ar: Option<String> = (None, parse_opt_string, "tool to assemble archives with"), linker: Option<String> = (None, parse_opt_string, @@ -520,7 +520,7 @@ cgoptions!( "print remarks for these optimization passes (space separated, or \"all\")"), no_stack_check: bool = (false, parse_bool, "disable checks for stack exhaustion (a memory-safety hazard!)"), -) +} pub fn build_codegen_options(matches: &getopts::Matches) -> CodegenOptions { diff --git a/src/librustc_back/sha2.rs b/src/librustc_back/sha2.rs index 1587104ca49..074341ccff4 100644 --- a/src/librustc_back/sha2.rs +++ b/src/librustc_back/sha2.rs @@ -349,7 +349,7 @@ impl Engine256State { macro_rules! schedule_round( ($t:expr) => ( w[$t] = sigma1(w[$t - 2]) + w[$t - 7] + sigma0(w[$t - 15]) + w[$t - 16]; ) - ) + ); macro_rules! sha2_round( ($A:ident, $B:ident, $C:ident, $D:ident, @@ -360,7 +360,7 @@ impl Engine256State { $H += sum0($A) + maj($A, $B, $C); } ) - ) + ); read_u32v_be(w[mut 0..16], data); @@ -454,7 +454,7 @@ impl Engine256 { } fn input(&mut self, input: &[u8]) { - assert!(!self.finished) + assert!(!self.finished); // Assumes that input.len() can be converted to u64 without overflow self.length_bits = add_bytes_to_bits(self.length_bits, input.len() as u64); let self_state = &mut self.state; diff --git a/src/librustc_back/svh.rs b/src/librustc_back/svh.rs index 116cff49153..98fa659ba55 100644 --- a/src/librustc_back/svh.rs +++ b/src/librustc_back/svh.rs @@ -340,14 +340,17 @@ mod svh_visitor { // expensive; a direct content-based hash on token // trees might be faster. Implementing this is far // easier in short term. - let macro_defn_as_string = - pprust::to_string(|pp_state| pp_state.print_mac(macro)); + let macro_defn_as_string = pprust::to_string(|pp_state| { + pp_state.print_mac(macro, token::Paren) + }); macro_defn_as_string.hash(self.st); } else { // It is not possible to observe any kind of macro // invocation at this stage except `macro_rules!`. panic!("reached macro somehow: {}", - pprust::to_string(|pp_state| pp_state.print_mac(macro))); + pprust::to_string(|pp_state| { + pp_state.print_mac(macro, token::Paren) + })); } visit::walk_mac(self, macro); diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs index 76adc4e472f..d12cb356e3f 100644 --- a/src/librustc_back/target/mod.rs +++ b/src/librustc_back/target/mod.rs @@ -256,7 +256,7 @@ impl Target { ) ); } ); - ) + ); key!(cpu); key!(linker); @@ -325,7 +325,7 @@ impl Target { } } ) - ) + ); load_specific!( x86_64_unknown_linux_gnu, @@ -348,7 +348,7 @@ impl Target { x86_64_pc_windows_gnu, i686_pc_windows_gnu - ) + ); let path = Path::new(target); diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index a3fb91aced0..7f469db3186 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -39,14 +39,14 @@ use syntax::visit; use syntax::visit::{Visitor, FnKind}; use syntax::ast::{FnDecl, Block, NodeId}; -macro_rules! if_ok( +macro_rules! if_ok { ($inp: expr) => ( match $inp { Ok(v) => { v } Err(e) => { return Err(e); } } ) -) +} pub mod doc; diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs index b052c8755cb..8b036b25015 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/lib.rs @@ -2290,5 +2290,5 @@ pub unsafe fn static_link_hack_this_sucks() { // Works to the above fix for #15460 to ensure LLVM dependencies that // are only used by rustllvm don't get stripped by the linker. mod llvmdeps { - include!(env!("CFG_LLVM_LINKAGE_FILE")) + include! { env!("CFG_LLVM_LINKAGE_FILE") } } diff --git a/src/librustc_trans/trans/_match.rs b/src/librustc_trans/trans/_match.rs index b0512925719..bf17043f0e4 100644 --- a/src/librustc_trans/trans/_match.rs +++ b/src/librustc_trans/trans/_match.rs @@ -676,7 +676,7 @@ fn extract_vec_elems<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, // pattern. Note that, because the macro is well-typed, either ALL of the // matches should fit that sort of pattern or NONE (however, some of the // matches may be wildcards like _ or identifiers). -macro_rules! any_pat ( +macro_rules! any_pat { ($m:expr, $col:expr, $pattern:pat) => ( ($m).iter().any(|br| { match br.pats[$col].node { @@ -685,7 +685,7 @@ macro_rules! any_pat ( } }) ) -) +} fn any_uniq_pat(m: &[Match], col: uint) -> bool { any_pat!(m, col, ast::PatBox(_)) diff --git a/src/librustc_trans/trans/adt.rs b/src/librustc_trans/trans/adt.rs index 991333d8f07..0c2c86fc32d 100644 --- a/src/librustc_trans/trans/adt.rs +++ b/src/librustc_trans/trans/adt.rs @@ -147,7 +147,7 @@ pub fn represent_type<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, } let repr = Rc::new(represent_type_uncached(cx, t)); - debug!("Represented as: {}", repr) + debug!("Represented as: {}", repr); cx.adt_reprs().borrow_mut().insert(t, repr.clone()); repr } diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index 83779ffbe16..f1d839e916d 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -103,9 +103,11 @@ use syntax::visit::Visitor; use syntax::visit; use syntax::{ast, ast_util, ast_map}; -thread_local!(static TASK_LOCAL_INSN_KEY: RefCell<Option<Vec<&'static str>>> = { - RefCell::new(None) -}) +thread_local! { + static TASK_LOCAL_INSN_KEY: RefCell<Option<Vec<&'static str>>> = { + RefCell::new(None) + } +} pub fn with_insn_ctxt<F>(blk: F) where F: FnOnce(&[&'static str]), diff --git a/src/librustc_trans/trans/context.rs b/src/librustc_trans/trans/context.rs index 3b5197594a1..89fa6a72e88 100644 --- a/src/librustc_trans/trans/context.rs +++ b/src/librustc_trans/trans/context.rs @@ -749,10 +749,10 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef return Some(f); } ) - ) + ); macro_rules! mk_struct ( ($($field_ty:expr),*) => (Type::struct_(ccx, &[$($field_ty),*], false)) - ) + ); let i8p = Type::i8p(ccx); let void = Type::void(ccx); @@ -886,7 +886,7 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef return Some(f); } ) - ) + ); compatible_ifn!("llvm.copysign.f32", copysignf(t_f32, t_f32) -> t_f32); compatible_ifn!("llvm.copysign.f64", copysign(t_f64, t_f64) -> t_f64); diff --git a/src/librustc_trans/trans/datum.rs b/src/librustc_trans/trans/datum.rs index 531b22c8fb5..e32b5792e5d 100644 --- a/src/librustc_trans/trans/datum.rs +++ b/src/librustc_trans/trans/datum.rs @@ -583,7 +583,7 @@ impl<'tcx, K: KindOps + fmt::Show> Datum<'tcx, K> { } pub fn to_llbool<'blk>(self, bcx: Block<'blk, 'tcx>) -> ValueRef { - assert!(ty::type_is_bool(self.ty)) + assert!(ty::type_is_bool(self.ty)); self.to_llscalarish(bcx) } } diff --git a/src/librustc_trans/trans/debuginfo.rs b/src/librustc_trans/trans/debuginfo.rs index c97e6a09529..e9730f7af0e 100644 --- a/src/librustc_trans/trans/debuginfo.rs +++ b/src/librustc_trans/trans/debuginfo.rs @@ -634,7 +634,7 @@ impl<'tcx> TypeMap<'tcx> { // Returns from the enclosing function if the type metadata with the given // unique id can be found in the type map -macro_rules! return_if_metadata_created_in_meantime( +macro_rules! return_if_metadata_created_in_meantime { ($cx: expr, $unique_type_id: expr) => ( match debug_context($cx).type_map .borrow() @@ -643,7 +643,7 @@ macro_rules! return_if_metadata_created_in_meantime( None => { /* proceed normally */ } }; ) -) +} /// A context object for maintaining all state needed by the debuginfo module. diff --git a/src/librustc_trans/trans/macros.rs b/src/librustc_trans/trans/macros.rs index 313280cb7a8..ab202975bfc 100644 --- a/src/librustc_trans/trans/macros.rs +++ b/src/librustc_trans/trans/macros.rs @@ -10,7 +10,7 @@ #![macro_escape] -macro_rules! unpack_datum( +macro_rules! unpack_datum { ($bcx: ident, $inp: expr) => ( { let db = $inp; @@ -18,9 +18,9 @@ macro_rules! unpack_datum( db.datum } ) -) +} -macro_rules! unpack_result( +macro_rules! unpack_result { ($bcx: ident, $inp: expr) => ( { let db = $inp; @@ -28,4 +28,4 @@ macro_rules! unpack_result( db.val } ) -) +} diff --git a/src/librustc_trans/trans/type_.rs b/src/librustc_trans/trans/type_.rs index 387af7390b2..70b1e99ce8e 100644 --- a/src/librustc_trans/trans/type_.rs +++ b/src/librustc_trans/trans/type_.rs @@ -33,9 +33,9 @@ pub struct Type { impl Copy for Type {} -macro_rules! ty ( +macro_rules! ty { ($e:expr) => ( Type::from_ref(unsafe { $e })) -) +} /// Wrapper for LLVM TypeRef impl Type { diff --git a/src/librustc_trans/trans/value.rs b/src/librustc_trans/trans/value.rs index 81488b99b67..c7cf86fb184 100644 --- a/src/librustc_trans/trans/value.rs +++ b/src/librustc_trans/trans/value.rs @@ -18,14 +18,14 @@ pub struct Value(pub ValueRef); impl Copy for Value {} -macro_rules! opt_val ( ($e:expr) => ( +macro_rules! opt_val { ($e:expr) => ( unsafe { match $e { p if p.is_not_null() => Some(Value(p)), _ => None } } -)) +) } /// Wrapper for LLVM ValueRef impl Value { diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index 6cfe24342e2..2ec7e2c3883 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -199,14 +199,14 @@ pub fn regionck_ensure_component_tys_wf<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, // check failed (or will fail, when the error is uncovered and // reported during writeback). In this case, we just ignore this part // of the code and don't try to add any more region constraints. -macro_rules! ignore_err( +macro_rules! ignore_err { ($inp: expr) => ( match $inp { Ok(v) => v, Err(()) => return } ) -) +} // Stores parameters for a potential call to link_region() // to perform if an upvar reference is marked unique/mutable after diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index ecd3cafd91f..9657bf82a8b 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -10,16 +10,18 @@ #![allow(non_snake_case)] -register_diagnostic!(E0001, r##" +register_diagnostic! { + E0001, +r##" This error suggests that the expression arm corresponding to the noted pattern will never be reached as for all possible values of the expression being matched, one of the preceeding patterns will match. This means that perhaps some of the preceeding patterns are too general, this one is too specific or the ordering is incorrect. -"##) +"## } -register_diagnostics!( +register_diagnostics! { E0002, E0003, E0004, @@ -156,4 +158,4 @@ register_diagnostics!( E0181, E0182, E0183 -) +} diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 6a2929beca2..1e243906b23 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -779,7 +779,7 @@ The counts do not include methods or trait implementations that are visible only through a re-exported type.", stable, unstable, experimental, deprecated, unmarked, name=self.name)); - try!(write!(f, "<table>")) + try!(write!(f, "<table>")); try!(fmt_inner(f, &mut context, self)); write!(f, "</table>") } diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index cba58db7c7f..8b2f644dfe3 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -149,12 +149,12 @@ fn stripped_filtered_line<'a>(s: &'a str) -> Option<&'a str> { thread_local!(static USED_HEADER_MAP: RefCell<HashMap<String, uint>> = { RefCell::new(HashMap::new()) -}) -thread_local!(static TEST_IDX: Cell<uint> = Cell::new(0)) +}); +thread_local!(static TEST_IDX: Cell<uint> = Cell::new(0)); thread_local!(pub static PLAYGROUND_KRATE: RefCell<Option<Option<String>>> = { RefCell::new(None) -}) +}); pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result { extern fn block(ob: *mut hoedown_buffer, orig_text: *const hoedown_buffer, diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 1977b6320d0..3e6cffa1304 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -246,9 +246,9 @@ struct IndexItem { // TLS keys used to carry information around during rendering. -thread_local!(static CACHE_KEY: RefCell<Arc<Cache>> = Default::default()) +thread_local!(static CACHE_KEY: RefCell<Arc<Cache>> = Default::default()); thread_local!(pub static CURRENT_LOCATION_KEY: RefCell<Vec<String>> = - RefCell::new(Vec::new())) + RefCell::new(Vec::new())); /// Generates the documentation for `crate` into the directory `dst` pub fn run(mut krate: clean::Crate, diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 78117c9cb06..5a91298acdf 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -93,7 +93,7 @@ static DEFAULT_PASSES: &'static [&'static str] = &[ thread_local!(pub static ANALYSISKEY: Rc<RefCell<Option<core::CrateAnalysis>>> = { Rc::new(RefCell::new(None)) -}) +}); struct Output { krate: clean::Crate, diff --git a/src/librustrt/macros.rs b/src/librustrt/macros.rs index d4e92736a9d..45144308535 100644 --- a/src/librustrt/macros.rs +++ b/src/librustrt/macros.rs @@ -15,22 +15,22 @@ #![macro_escape] -macro_rules! rterrln ( +macro_rules! rterrln { ($fmt:expr $($arg:tt)*) => ( { format_args!(::util::dumb_print, concat!($fmt, "\n") $($arg)*) } ) -) +} // Some basic logging. Enabled by passing `--cfg rtdebug` to the libstd build. -macro_rules! rtdebug ( +macro_rules! rtdebug { ($($arg:tt)*) => ( { if cfg!(rtdebug) { rterrln!($($arg)*) } }) -) +} -macro_rules! rtassert ( +macro_rules! rtassert { ( $arg:expr ) => ( { if ::util::ENFORCE_SANITY { if !$arg { @@ -38,9 +38,9 @@ macro_rules! rtassert ( } } } ) -) +} -macro_rules! rtabort ( +macro_rules! rtabort { ($($arg:tt)*) => (format_args!(::util::abort, $($arg)*)) -) +} diff --git a/src/libserialize/base64.rs b/src/libserialize/base64.rs index 59faf75c0c3..8ded963b928 100644 --- a/src/libserialize/base64.rs +++ b/src/libserialize/base64.rs @@ -385,7 +385,7 @@ mod tests { #[test] fn test_from_base64_invalid_char() { - assert!("Zm$=".from_base64().is_err()) + assert!("Zm$=".from_base64().is_err()); assert!("Zg==$".from_base64().is_err()); } diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index c811a16e2b1..e7b2d0c8eba 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -1970,7 +1970,7 @@ impl Decoder { } } -macro_rules! expect( +macro_rules! expect { ($e:expr, Null) => ({ match $e { Json::Null => Ok(()), @@ -1987,7 +1987,7 @@ macro_rules! expect( } } }) -) +} macro_rules! read_primitive { ($name:ident, $ty:ty) => { @@ -2020,16 +2020,16 @@ impl ::Decoder<DecoderError> for Decoder { expect!(self.pop(), Null) } - read_primitive!(read_uint, uint) - read_primitive!(read_u8, u8) - read_primitive!(read_u16, u16) - read_primitive!(read_u32, u32) - read_primitive!(read_u64, u64) - read_primitive!(read_int, int) - read_primitive!(read_i8, i8) - read_primitive!(read_i16, i16) - read_primitive!(read_i32, i32) - read_primitive!(read_i64, i64) + read_primitive! { read_uint, uint } + read_primitive! { read_u8, u8 } + read_primitive! { read_u16, u16 } + read_primitive! { read_u32, u32 } + read_primitive! { read_u64, u64 } + read_primitive! { read_int, int } + read_primitive! { read_i8, i8 } + read_primitive! { read_i16, i16 } + read_primitive! { read_i32, i32 } + read_primitive! { read_i64, i64 } fn read_f32(&mut self) -> DecodeResult<f32> { self.read_f64().map(|x| x as f32) } @@ -2298,25 +2298,25 @@ pub trait ToJson for Sized? { fn to_json(&self) -> Json; } -macro_rules! to_json_impl_i64( +macro_rules! to_json_impl_i64 { ($($t:ty), +) => ( $(impl ToJson for $t { fn to_json(&self) -> Json { Json::I64(*self as i64) } })+ ) -) +} -to_json_impl_i64!(int, i8, i16, i32, i64) +to_json_impl_i64! { int, i8, i16, i32, i64 } -macro_rules! to_json_impl_u64( +macro_rules! to_json_impl_u64 { ($($t:ty), +) => ( $(impl ToJson for $t { fn to_json(&self) -> Json { Json::U64(*self as u64) } })+ ) -) +} -to_json_impl_u64!(uint, u8, u16, u32, u64) +to_json_impl_u64! { uint, u8, u16, u32, u64 } impl ToJson for Json { fn to_json(&self) -> Json { self.clone() } @@ -2730,7 +2730,7 @@ mod tests { ); } - macro_rules! check_encoder_for_simple( + macro_rules! check_encoder_for_simple { ($value:expr, $expected:expr) => ({ let s = with_str_writer(|writer| { let mut encoder = Encoder::new(writer); @@ -2744,7 +2744,7 @@ mod tests { }); assert_eq!(s, $expected); }) - ) + } #[test] fn test_write_some() { @@ -2948,7 +2948,7 @@ mod tests { #[test] fn test_decode_tuple() { let t: (uint, uint, uint) = super::decode("[1, 2, 3]").unwrap(); - assert_eq!(t, (1u, 2, 3)) + assert_eq!(t, (1u, 2, 3)); let t: (uint, string::String) = super::decode("[1, \"two\"]").unwrap(); assert_eq!(t, (1u, "two".into_string())); 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, } diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index edf88a84893..c436de0d193 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -638,14 +638,14 @@ mod tests { use char::from_u32; use str::StrPrelude; - macro_rules! v2ascii ( + macro_rules! v2ascii { ( [$($e:expr),*]) => (&[$(Ascii{chr:$e}),*]); (&[$($e:expr),*]) => (&[$(Ascii{chr:$e}),*]); - ) + } - macro_rules! vec2ascii ( + macro_rules! vec2ascii { ($($e:expr),*) => ([$(Ascii{chr:$e}),*].to_vec()); - ) + } #[test] fn test_ascii() { @@ -788,7 +788,7 @@ mod tests { let upper = if 'a' as u32 <= i && i <= 'z' as u32 { i + 'A' as u32 - 'a' as u32 } else { i }; assert_eq!((from_u32(i).unwrap()).to_string().to_ascii_upper(), - (from_u32(upper).unwrap()).to_string()) + (from_u32(upper).unwrap()).to_string()); i += 1; } } @@ -804,7 +804,7 @@ mod tests { let lower = if 'A' as u32 <= i && i <= 'Z' as u32 { i + 'a' as u32 - 'A' as u32 } else { i }; assert_eq!((from_u32(i).unwrap()).to_string().to_ascii_lower(), - (from_u32(lower).unwrap()).to_string()) + (from_u32(lower).unwrap()).to_string()); i += 1; } } @@ -820,7 +820,7 @@ mod tests { let upper = if 'a' as u32 <= i && i <= 'z' as u32 { i + 'A' as u32 - 'a' as u32 } else { i }; assert_eq!((from_u32(i).unwrap()).to_string().into_ascii_upper(), - (from_u32(upper).unwrap()).to_string()) + (from_u32(upper).unwrap()).to_string()); i += 1; } } @@ -837,7 +837,7 @@ mod tests { let lower = if 'A' as u32 <= i && i <= 'Z' as u32 { i + 'a' as u32 - 'A' as u32 } else { i }; assert_eq!((from_u32(i).unwrap()).to_string().into_ascii_lower(), - (from_u32(lower).unwrap()).to_string()) + (from_u32(lower).unwrap()).to_string()); i += 1; } } diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 0ff29a94f2f..04dd5afdfa2 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -1471,7 +1471,7 @@ mod test_map { assert_eq!(*m.get(&2).unwrap(), 4); } - thread_local!(static DROP_VECTOR: RefCell<Vec<int>> = RefCell::new(Vec::new())) + thread_local! { static DROP_VECTOR: RefCell<Vec<int>> = RefCell::new(Vec::new()) } #[deriving(Hash, PartialEq, Eq)] struct Dropable { diff --git a/src/libstd/comm/mod.rs b/src/libstd/comm/mod.rs index 72ddbe19f54..29a7b0dd0cc 100644 --- a/src/libstd/comm/mod.rs +++ b/src/libstd/comm/mod.rs @@ -136,7 +136,7 @@ //! select! { //! val = rx.recv() => println!("Received {}", val), //! () = timeout.recv() => { -//! println!("timed out, total time was more than 10 seconds") +//! println!("timed out, total time was more than 10 seconds"); //! break; //! } //! } @@ -160,7 +160,7 @@ //! select! { //! val = rx.recv() => println!("Received {}", val), //! () = timeout.recv() => { -//! println!("timed out, no message received in 5 seconds") +//! println!("timed out, no message received in 5 seconds"); //! break; //! } //! } @@ -331,7 +331,7 @@ use rustrt::task::BlockedTask; pub use comm::select::{Select, Handle}; -macro_rules! test ( +macro_rules! test { { fn $name:ident() $b:block $(#[$a:meta])*} => ( mod $name { #![allow(unused_imports)] @@ -347,7 +347,7 @@ macro_rules! test ( $(#[$a])* #[test] fn f() { $b } } ) -) +} mod oneshot; mod select; @@ -1036,70 +1036,70 @@ mod test { } } - test!(fn smoke() { + test! { fn smoke() { let (tx, rx) = channel::<int>(); tx.send(1); assert_eq!(rx.recv(), 1); - }) + } } - test!(fn drop_full() { + test! { fn drop_full() { let (tx, _rx) = channel(); tx.send(box 1i); - }) + } } - test!(fn drop_full_shared() { + test! { fn drop_full_shared() { let (tx, _rx) = channel(); drop(tx.clone()); drop(tx.clone()); tx.send(box 1i); - }) + } } - test!(fn smoke_shared() { + test! { fn smoke_shared() { let (tx, rx) = channel::<int>(); tx.send(1); assert_eq!(rx.recv(), 1); let tx = tx.clone(); tx.send(1); assert_eq!(rx.recv(), 1); - }) + } } - test!(fn smoke_threads() { + test! { fn smoke_threads() { let (tx, rx) = channel::<int>(); spawn(move|| { tx.send(1); }); assert_eq!(rx.recv(), 1); - }) + } } - test!(fn smoke_port_gone() { + test! { fn smoke_port_gone() { let (tx, rx) = channel::<int>(); drop(rx); tx.send(1); - } #[should_fail]) + } #[should_fail] } - test!(fn smoke_shared_port_gone() { + test! { fn smoke_shared_port_gone() { let (tx, rx) = channel::<int>(); drop(rx); tx.send(1); - } #[should_fail]) + } #[should_fail] } - test!(fn smoke_shared_port_gone2() { + test! { fn smoke_shared_port_gone2() { let (tx, rx) = channel::<int>(); drop(rx); let tx2 = tx.clone(); drop(tx); tx2.send(1); - } #[should_fail]) + } #[should_fail] } - test!(fn port_gone_concurrent() { + test! { fn port_gone_concurrent() { let (tx, rx) = channel::<int>(); spawn(move|| { rx.recv(); }); loop { tx.send(1) } - } #[should_fail]) + } #[should_fail] } - test!(fn port_gone_concurrent_shared() { + test! { fn port_gone_concurrent_shared() { let (tx, rx) = channel::<int>(); let tx2 = tx.clone(); spawn(move|| { @@ -1109,32 +1109,32 @@ mod test { tx.send(1); tx2.send(1); } - } #[should_fail]) + } #[should_fail] } - test!(fn smoke_chan_gone() { + test! { fn smoke_chan_gone() { let (tx, rx) = channel::<int>(); drop(tx); rx.recv(); - } #[should_fail]) + } #[should_fail] } - test!(fn smoke_chan_gone_shared() { + test! { fn smoke_chan_gone_shared() { let (tx, rx) = channel::<()>(); let tx2 = tx.clone(); drop(tx); drop(tx2); rx.recv(); - } #[should_fail]) + } #[should_fail] } - test!(fn chan_gone_concurrent() { + test! { fn chan_gone_concurrent() { let (tx, rx) = channel::<int>(); spawn(move|| { tx.send(1); tx.send(1); }); loop { rx.recv(); } - } #[should_fail]) + } #[should_fail] } - test!(fn stress() { + test! { fn stress() { let (tx, rx) = channel::<int>(); spawn(move|| { for _ in range(0u, 10000) { tx.send(1i); } @@ -1142,9 +1142,9 @@ mod test { for _ in range(0u, 10000) { assert_eq!(rx.recv(), 1); } - }) + } } - test!(fn stress_shared() { + test! { fn stress_shared() { static AMT: uint = 10000; static NTHREADS: uint = 8; let (tx, rx) = channel::<int>(); @@ -1169,7 +1169,7 @@ mod test { } drop(tx); drx.recv(); - }) + } } #[test] fn send_from_outside_runtime() { @@ -1231,26 +1231,26 @@ mod test { rx3.recv(); } - test!(fn oneshot_single_thread_close_port_first() { + test! { fn oneshot_single_thread_close_port_first() { // Simple test of closing without sending let (_tx, rx) = channel::<int>(); drop(rx); - }) + } } - test!(fn oneshot_single_thread_close_chan_first() { + test! { fn oneshot_single_thread_close_chan_first() { // Simple test of closing without sending let (tx, _rx) = channel::<int>(); drop(tx); - }) + } } - test!(fn oneshot_single_thread_send_port_close() { + test! { fn oneshot_single_thread_send_port_close() { // Testing that the sender cleans up the payload if receiver is closed let (tx, rx) = channel::<Box<int>>(); drop(rx); tx.send(box 0); - } #[should_fail]) + } #[should_fail] } - test!(fn oneshot_single_thread_recv_chan_close() { + test! { fn oneshot_single_thread_recv_chan_close() { // Receiving on a closed chan will panic let res = task::try(move|| { let (tx, rx) = channel::<int>(); @@ -1259,67 +1259,67 @@ mod test { }); // What is our res? assert!(res.is_err()); - }) + } } - test!(fn oneshot_single_thread_send_then_recv() { + test! { fn oneshot_single_thread_send_then_recv() { let (tx, rx) = channel::<Box<int>>(); tx.send(box 10); assert!(rx.recv() == box 10); - }) + } } - test!(fn oneshot_single_thread_try_send_open() { + test! { fn oneshot_single_thread_try_send_open() { let (tx, rx) = channel::<int>(); assert!(tx.send_opt(10).is_ok()); assert!(rx.recv() == 10); - }) + } } - test!(fn oneshot_single_thread_try_send_closed() { + test! { fn oneshot_single_thread_try_send_closed() { let (tx, rx) = channel::<int>(); drop(rx); assert!(tx.send_opt(10).is_err()); - }) + } } - test!(fn oneshot_single_thread_try_recv_open() { + test! { fn oneshot_single_thread_try_recv_open() { let (tx, rx) = channel::<int>(); tx.send(10); assert!(rx.recv_opt() == Ok(10)); - }) + } } - test!(fn oneshot_single_thread_try_recv_closed() { + test! { fn oneshot_single_thread_try_recv_closed() { let (tx, rx) = channel::<int>(); drop(tx); assert!(rx.recv_opt() == Err(())); - }) + } } - test!(fn oneshot_single_thread_peek_data() { + test! { fn oneshot_single_thread_peek_data() { let (tx, rx) = channel::<int>(); - assert_eq!(rx.try_recv(), Err(Empty)) + assert_eq!(rx.try_recv(), Err(Empty)); tx.send(10); assert_eq!(rx.try_recv(), Ok(10)); - }) + } } - test!(fn oneshot_single_thread_peek_close() { + test! { fn oneshot_single_thread_peek_close() { let (tx, rx) = channel::<int>(); drop(tx); assert_eq!(rx.try_recv(), Err(Disconnected)); assert_eq!(rx.try_recv(), Err(Disconnected)); - }) + } } - test!(fn oneshot_single_thread_peek_open() { + test! { fn oneshot_single_thread_peek_open() { let (_tx, rx) = channel::<int>(); assert_eq!(rx.try_recv(), Err(Empty)); - }) + } } - test!(fn oneshot_multi_task_recv_then_send() { + test! { fn oneshot_multi_task_recv_then_send() { let (tx, rx) = channel::<Box<int>>(); spawn(move|| { assert!(rx.recv() == box 10); }); tx.send(box 10); - }) + } } - test!(fn oneshot_multi_task_recv_then_close() { + test! { fn oneshot_multi_task_recv_then_close() { let (tx, rx) = channel::<Box<int>>(); spawn(move|| { drop(tx); @@ -1328,9 +1328,9 @@ mod test { assert!(rx.recv() == box 10); }); assert!(res.is_err()); - }) + } } - test!(fn oneshot_multi_thread_close_stress() { + test! { fn oneshot_multi_thread_close_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = channel::<int>(); spawn(move|| { @@ -1338,9 +1338,9 @@ mod test { }); drop(tx); } - }) + } } - test!(fn oneshot_multi_thread_send_close_stress() { + test! { fn oneshot_multi_thread_send_close_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = channel::<int>(); spawn(move|| { @@ -1350,9 +1350,9 @@ mod test { tx.send(1); }); } - }) + } } - test!(fn oneshot_multi_thread_recv_close_stress() { + test! { fn oneshot_multi_thread_recv_close_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = channel::<int>(); spawn(move|| { @@ -1367,9 +1367,9 @@ mod test { }); }); } - }) + } } - test!(fn oneshot_multi_thread_send_recv_stress() { + test! { fn oneshot_multi_thread_send_recv_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = channel(); spawn(move|| { @@ -1379,9 +1379,9 @@ mod test { assert!(rx.recv() == box 10i); }); } - }) + } } - test!(fn stream_send_recv_stress() { + test! { fn stream_send_recv_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = channel(); @@ -1406,16 +1406,16 @@ mod test { }); } } - }) + } } - test!(fn recv_a_lot() { + test! { fn recv_a_lot() { // Regression test that we don't run out of stack in scheduler context let (tx, rx) = channel(); for _ in range(0i, 10000) { tx.send(()); } for _ in range(0i, 10000) { rx.recv(); } - }) + } } - test!(fn shared_chan_stress() { + test! { fn shared_chan_stress() { let (tx, rx) = channel(); let total = stress_factor() + 100; for _ in range(0, total) { @@ -1428,9 +1428,9 @@ mod test { for _ in range(0, total) { rx.recv(); } - }) + } } - test!(fn test_nested_recv_iter() { + test! { fn test_nested_recv_iter() { let (tx, rx) = channel::<int>(); let (total_tx, total_rx) = channel::<int>(); @@ -1447,9 +1447,9 @@ mod test { tx.send(2); drop(tx); assert_eq!(total_rx.recv(), 6); - }) + } } - test!(fn test_recv_iter_break() { + test! { fn test_recv_iter_break() { let (tx, rx) = channel::<int>(); let (count_tx, count_rx) = channel(); @@ -1471,9 +1471,9 @@ mod test { let _ = tx.send_opt(2); drop(tx); assert_eq!(count_rx.recv(), 4); - }) + } } - test!(fn try_recv_states() { + test! { fn try_recv_states() { let (tx1, rx1) = channel::<int>(); let (tx2, rx2) = channel::<()>(); let (tx3, rx3) = channel::<()>(); @@ -1494,11 +1494,11 @@ mod test { tx2.send(()); rx3.recv(); assert_eq!(rx1.try_recv(), Err(Disconnected)); - }) + } } // This bug used to end up in a livelock inside of the Receiver destructor // because the internal state of the Shared packet was corrupted - test!(fn destroy_upgraded_shared_port_when_sender_still_active() { + test! { fn destroy_upgraded_shared_port_when_sender_still_active() { let (tx, rx) = channel(); let (tx2, rx2) = channel(); spawn(move|| { @@ -1516,9 +1516,9 @@ mod test { // wait for the child task to exit before we exit rx2.recv(); - }) + } } - test!(fn sends_off_the_runtime() { + test! { fn sends_off_the_runtime() { use rustrt::thread::Thread; let (tx, rx) = channel(); @@ -1531,9 +1531,9 @@ mod test { rx.recv(); } t.join(); - }) + } } - test!(fn try_recvs_off_the_runtime() { + test! { fn try_recvs_off_the_runtime() { use rustrt::thread::Thread; let (tx, rx) = channel(); @@ -1554,7 +1554,7 @@ mod test { } t.join(); pdone.recv(); - }) + } } } #[cfg(test)] @@ -1569,57 +1569,57 @@ mod sync_tests { } } - test!(fn smoke() { + test! { fn smoke() { let (tx, rx) = sync_channel::<int>(1); tx.send(1); assert_eq!(rx.recv(), 1); - }) + } } - test!(fn drop_full() { + test! { fn drop_full() { let (tx, _rx) = sync_channel(1); tx.send(box 1i); - }) + } } - test!(fn smoke_shared() { + test! { fn smoke_shared() { let (tx, rx) = sync_channel::<int>(1); tx.send(1); assert_eq!(rx.recv(), 1); let tx = tx.clone(); tx.send(1); assert_eq!(rx.recv(), 1); - }) + } } - test!(fn smoke_threads() { + test! { fn smoke_threads() { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { tx.send(1); }); assert_eq!(rx.recv(), 1); - }) + } } - test!(fn smoke_port_gone() { + test! { fn smoke_port_gone() { let (tx, rx) = sync_channel::<int>(0); drop(rx); tx.send(1); - } #[should_fail]) + } #[should_fail] } - test!(fn smoke_shared_port_gone2() { + test! { fn smoke_shared_port_gone2() { let (tx, rx) = sync_channel::<int>(0); drop(rx); let tx2 = tx.clone(); drop(tx); tx2.send(1); - } #[should_fail]) + } #[should_fail] } - test!(fn port_gone_concurrent() { + test! { fn port_gone_concurrent() { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { rx.recv(); }); loop { tx.send(1) } - } #[should_fail]) + } #[should_fail] } - test!(fn port_gone_concurrent_shared() { + test! { fn port_gone_concurrent_shared() { let (tx, rx) = sync_channel::<int>(0); let tx2 = tx.clone(); spawn(move|| { @@ -1629,32 +1629,32 @@ mod sync_tests { tx.send(1); tx2.send(1); } - } #[should_fail]) + } #[should_fail] } - test!(fn smoke_chan_gone() { + test! { fn smoke_chan_gone() { let (tx, rx) = sync_channel::<int>(0); drop(tx); rx.recv(); - } #[should_fail]) + } #[should_fail] } - test!(fn smoke_chan_gone_shared() { + test! { fn smoke_chan_gone_shared() { let (tx, rx) = sync_channel::<()>(0); let tx2 = tx.clone(); drop(tx); drop(tx2); rx.recv(); - } #[should_fail]) + } #[should_fail] } - test!(fn chan_gone_concurrent() { + test! { fn chan_gone_concurrent() { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { tx.send(1); tx.send(1); }); loop { rx.recv(); } - } #[should_fail]) + } #[should_fail] } - test!(fn stress() { + test! { fn stress() { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { for _ in range(0u, 10000) { tx.send(1); } @@ -1662,9 +1662,9 @@ mod sync_tests { for _ in range(0u, 10000) { assert_eq!(rx.recv(), 1); } - }) + } } - test!(fn stress_shared() { + test! { fn stress_shared() { static AMT: uint = 1000; static NTHREADS: uint = 8; let (tx, rx) = sync_channel::<int>(0); @@ -1689,28 +1689,28 @@ mod sync_tests { } drop(tx); drx.recv(); - }) + } } - test!(fn oneshot_single_thread_close_port_first() { + test! { fn oneshot_single_thread_close_port_first() { // Simple test of closing without sending let (_tx, rx) = sync_channel::<int>(0); drop(rx); - }) + } } - test!(fn oneshot_single_thread_close_chan_first() { + test! { fn oneshot_single_thread_close_chan_first() { // Simple test of closing without sending let (tx, _rx) = sync_channel::<int>(0); drop(tx); - }) + } } - test!(fn oneshot_single_thread_send_port_close() { + test! { fn oneshot_single_thread_send_port_close() { // Testing that the sender cleans up the payload if receiver is closed let (tx, rx) = sync_channel::<Box<int>>(0); drop(rx); tx.send(box 0); - } #[should_fail]) + } #[should_fail] } - test!(fn oneshot_single_thread_recv_chan_close() { + test! { fn oneshot_single_thread_recv_chan_close() { // Receiving on a closed chan will panic let res = task::try(move|| { let (tx, rx) = sync_channel::<int>(0); @@ -1719,72 +1719,72 @@ mod sync_tests { }); // What is our res? assert!(res.is_err()); - }) + } } - test!(fn oneshot_single_thread_send_then_recv() { + test! { fn oneshot_single_thread_send_then_recv() { let (tx, rx) = sync_channel::<Box<int>>(1); tx.send(box 10); assert!(rx.recv() == box 10); - }) + } } - test!(fn oneshot_single_thread_try_send_open() { + test! { fn oneshot_single_thread_try_send_open() { let (tx, rx) = sync_channel::<int>(1); assert_eq!(tx.try_send(10), Ok(())); assert!(rx.recv() == 10); - }) + } } - test!(fn oneshot_single_thread_try_send_closed() { + test! { fn oneshot_single_thread_try_send_closed() { let (tx, rx) = sync_channel::<int>(0); drop(rx); assert_eq!(tx.try_send(10), Err(RecvDisconnected(10))); - }) + } } - test!(fn oneshot_single_thread_try_send_closed2() { + test! { fn oneshot_single_thread_try_send_closed2() { let (tx, _rx) = sync_channel::<int>(0); assert_eq!(tx.try_send(10), Err(Full(10))); - }) + } } - test!(fn oneshot_single_thread_try_recv_open() { + test! { fn oneshot_single_thread_try_recv_open() { let (tx, rx) = sync_channel::<int>(1); tx.send(10); assert!(rx.recv_opt() == Ok(10)); - }) + } } - test!(fn oneshot_single_thread_try_recv_closed() { + test! { fn oneshot_single_thread_try_recv_closed() { let (tx, rx) = sync_channel::<int>(0); drop(tx); assert!(rx.recv_opt() == Err(())); - }) + } } - test!(fn oneshot_single_thread_peek_data() { + test! { fn oneshot_single_thread_peek_data() { let (tx, rx) = sync_channel::<int>(1); - assert_eq!(rx.try_recv(), Err(Empty)) + assert_eq!(rx.try_recv(), Err(Empty)); tx.send(10); assert_eq!(rx.try_recv(), Ok(10)); - }) + } } - test!(fn oneshot_single_thread_peek_close() { + test! { fn oneshot_single_thread_peek_close() { let (tx, rx) = sync_channel::<int>(0); drop(tx); assert_eq!(rx.try_recv(), Err(Disconnected)); assert_eq!(rx.try_recv(), Err(Disconnected)); - }) + } } - test!(fn oneshot_single_thread_peek_open() { + test! { fn oneshot_single_thread_peek_open() { let (_tx, rx) = sync_channel::<int>(0); assert_eq!(rx.try_recv(), Err(Empty)); - }) + } } - test!(fn oneshot_multi_task_recv_then_send() { + test! { fn oneshot_multi_task_recv_then_send() { let (tx, rx) = sync_channel::<Box<int>>(0); spawn(move|| { assert!(rx.recv() == box 10); }); tx.send(box 10); - }) + } } - test!(fn oneshot_multi_task_recv_then_close() { + test! { fn oneshot_multi_task_recv_then_close() { let (tx, rx) = sync_channel::<Box<int>>(0); spawn(move|| { drop(tx); @@ -1793,9 +1793,9 @@ mod sync_tests { assert!(rx.recv() == box 10); }); assert!(res.is_err()); - }) + } } - test!(fn oneshot_multi_thread_close_stress() { + test! { fn oneshot_multi_thread_close_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { @@ -1803,9 +1803,9 @@ mod sync_tests { }); drop(tx); } - }) + } } - test!(fn oneshot_multi_thread_send_close_stress() { + test! { fn oneshot_multi_thread_send_close_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { @@ -1815,9 +1815,9 @@ mod sync_tests { tx.send(1); }); } - }) + } } - test!(fn oneshot_multi_thread_recv_close_stress() { + test! { fn oneshot_multi_thread_recv_close_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { @@ -1832,9 +1832,9 @@ mod sync_tests { }); }); } - }) + } } - test!(fn oneshot_multi_thread_send_recv_stress() { + test! { fn oneshot_multi_thread_send_recv_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = sync_channel::<Box<int>>(0); spawn(move|| { @@ -1844,9 +1844,9 @@ mod sync_tests { assert!(rx.recv() == box 10i); }); } - }) + } } - test!(fn stream_send_recv_stress() { + test! { fn stream_send_recv_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = sync_channel::<Box<int>>(0); @@ -1871,16 +1871,16 @@ mod sync_tests { }); } } - }) + } } - test!(fn recv_a_lot() { + test! { fn recv_a_lot() { // Regression test that we don't run out of stack in scheduler context let (tx, rx) = sync_channel(10000); for _ in range(0u, 10000) { tx.send(()); } for _ in range(0u, 10000) { rx.recv(); } - }) + } } - test!(fn shared_chan_stress() { + test! { fn shared_chan_stress() { let (tx, rx) = sync_channel(0); let total = stress_factor() + 100; for _ in range(0, total) { @@ -1893,9 +1893,9 @@ mod sync_tests { for _ in range(0, total) { rx.recv(); } - }) + } } - test!(fn test_nested_recv_iter() { + test! { fn test_nested_recv_iter() { let (tx, rx) = sync_channel::<int>(0); let (total_tx, total_rx) = sync_channel::<int>(0); @@ -1912,9 +1912,9 @@ mod sync_tests { tx.send(2); drop(tx); assert_eq!(total_rx.recv(), 6); - }) + } } - test!(fn test_recv_iter_break() { + test! { fn test_recv_iter_break() { let (tx, rx) = sync_channel::<int>(0); let (count_tx, count_rx) = sync_channel(0); @@ -1936,9 +1936,9 @@ mod sync_tests { let _ = tx.try_send(2); drop(tx); assert_eq!(count_rx.recv(), 4); - }) + } } - test!(fn try_recv_states() { + test! { fn try_recv_states() { let (tx1, rx1) = sync_channel::<int>(1); let (tx2, rx2) = sync_channel::<()>(1); let (tx3, rx3) = sync_channel::<()>(1); @@ -1959,11 +1959,11 @@ mod sync_tests { tx2.send(()); rx3.recv(); assert_eq!(rx1.try_recv(), Err(Disconnected)); - }) + } } // This bug used to end up in a livelock inside of the Receiver destructor // because the internal state of the Shared packet was corrupted - test!(fn destroy_upgraded_shared_port_when_sender_still_active() { + test! { fn destroy_upgraded_shared_port_when_sender_still_active() { let (tx, rx) = sync_channel::<()>(0); let (tx2, rx2) = sync_channel::<()>(0); spawn(move|| { @@ -1981,9 +1981,9 @@ mod sync_tests { // wait for the child task to exit before we exit rx2.recv(); - }) + } } - test!(fn try_recvs_off_the_runtime() { + test! { fn try_recvs_off_the_runtime() { use rustrt::thread::Thread; let (tx, rx) = sync_channel::<()>(0); @@ -2004,28 +2004,28 @@ mod sync_tests { } t.join(); pdone.recv(); - }) + } } - test!(fn send_opt1() { + test! { fn send_opt1() { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { rx.recv(); }); assert_eq!(tx.send_opt(1), Ok(())); - }) + } } - test!(fn send_opt2() { + test! { fn send_opt2() { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { drop(rx); }); assert_eq!(tx.send_opt(1), Err(1)); - }) + } } - test!(fn send_opt3() { + test! { fn send_opt3() { let (tx, rx) = sync_channel::<int>(1); assert_eq!(tx.send_opt(1), Ok(())); spawn(move|| { drop(rx); }); assert_eq!(tx.send_opt(1), Err(1)); - }) + } } - test!(fn send_opt4() { + test! { fn send_opt4() { let (tx, rx) = sync_channel::<int>(0); let tx2 = tx.clone(); let (done, donerx) = channel(); @@ -2041,36 +2041,36 @@ mod sync_tests { drop(rx); donerx.recv(); donerx.recv(); - }) + } } - test!(fn try_send1() { + test! { fn try_send1() { let (tx, _rx) = sync_channel::<int>(0); assert_eq!(tx.try_send(1), Err(Full(1))); - }) + } } - test!(fn try_send2() { + test! { fn try_send2() { let (tx, _rx) = sync_channel::<int>(1); assert_eq!(tx.try_send(1), Ok(())); assert_eq!(tx.try_send(1), Err(Full(1))); - }) + } } - test!(fn try_send3() { + test! { fn try_send3() { let (tx, rx) = sync_channel::<int>(1); assert_eq!(tx.try_send(1), Ok(())); drop(rx); assert_eq!(tx.try_send(1), Err(RecvDisconnected(1))); - }) + } } - test!(fn try_send4() { + test! { fn try_send4() { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { for _ in range(0u, 1000) { task::deschedule(); } assert_eq!(tx.try_send(1), Ok(())); }); assert_eq!(rx.recv(), 1); - } #[ignore(reason = "flaky on libnative")]) + } #[ignore(reason = "flaky on libnative")] } - test!(fn issue_15761() { + test! { fn issue_15761() { fn repro() { let (tx1, rx1) = sync_channel::<()>(3); let (tx2, rx2) = sync_channel::<()>(3); @@ -2087,5 +2087,5 @@ mod sync_tests { for _ in range(0u, 100) { repro() } - }) + } } } diff --git a/src/libstd/comm/select.rs b/src/libstd/comm/select.rs index e145b0df7f3..de2b84b083c 100644 --- a/src/libstd/comm/select.rs +++ b/src/libstd/comm/select.rs @@ -347,58 +347,58 @@ mod test { }) } - test!(fn smoke() { + test! { fn smoke() { let (tx1, rx1) = channel::<int>(); let (tx2, rx2) = channel::<int>(); tx1.send(1); - select! ( + select! { foo = rx1.recv() => { assert_eq!(foo, 1); }, _bar = rx2.recv() => { panic!() } - ) + } tx2.send(2); - select! ( + select! { _foo = rx1.recv() => { panic!() }, bar = rx2.recv() => { assert_eq!(bar, 2) } - ) + } drop(tx1); - select! ( + select! { foo = rx1.recv_opt() => { assert_eq!(foo, Err(())); }, _bar = rx2.recv() => { panic!() } - ) + } drop(tx2); - select! ( + select! { bar = rx2.recv_opt() => { assert_eq!(bar, Err(())); } - ) - }) + } + } } - test!(fn smoke2() { + test! { fn smoke2() { let (_tx1, rx1) = channel::<int>(); let (_tx2, rx2) = channel::<int>(); let (_tx3, rx3) = channel::<int>(); let (_tx4, rx4) = channel::<int>(); let (tx5, rx5) = channel::<int>(); tx5.send(4); - select! ( + select! { _foo = rx1.recv() => { panic!("1") }, _foo = rx2.recv() => { panic!("2") }, _foo = rx3.recv() => { panic!("3") }, _foo = rx4.recv() => { panic!("4") }, foo = rx5.recv() => { assert_eq!(foo, 4); } - ) - }) + } + } } - test!(fn closed() { + test! { fn closed() { let (_tx1, rx1) = channel::<int>(); let (tx2, rx2) = channel::<int>(); drop(tx2); - select! ( + select! { _a1 = rx1.recv_opt() => { panic!() }, a2 = rx2.recv_opt() => { assert_eq!(a2, Err(())); } - ) - }) + } + } } - test!(fn unblocks() { + test! { fn unblocks() { let (tx1, rx1) = channel::<int>(); let (_tx2, rx2) = channel::<int>(); let (tx3, rx3) = channel::<int>(); @@ -410,18 +410,18 @@ mod test { for _ in range(0u, 20) { task::deschedule(); } }); - select! ( + select! { a = rx1.recv() => { assert_eq!(a, 1); }, _b = rx2.recv() => { panic!() } - ) + } tx3.send(1); - select! ( + select! { a = rx1.recv_opt() => { assert_eq!(a, Err(())); }, _b = rx2.recv() => { panic!() } - ) - }) + } + } } - test!(fn both_ready() { + test! { fn both_ready() { let (tx1, rx1) = channel::<int>(); let (tx2, rx2) = channel::<int>(); let (tx3, rx3) = channel::<()>(); @@ -433,20 +433,20 @@ mod test { rx3.recv(); }); - select! ( + select! { a = rx1.recv() => { assert_eq!(a, 1); }, a = rx2.recv() => { assert_eq!(a, 2); } - ) - select! ( + } + select! { a = rx1.recv() => { assert_eq!(a, 1); }, a = rx2.recv() => { assert_eq!(a, 2); } - ) + } assert_eq!(rx1.try_recv(), Err(Empty)); assert_eq!(rx2.try_recv(), Err(Empty)); tx3.send(()); - }) + } } - test!(fn stress() { + test! { fn stress() { static AMT: int = 10000; let (tx1, rx1) = channel::<int>(); let (tx2, rx2) = channel::<int>(); @@ -464,15 +464,15 @@ mod test { }); for i in range(0, AMT) { - select! ( + select! { i1 = rx1.recv() => { assert!(i % 2 == 0 && i == i1); }, i2 = rx2.recv() => { assert!(i % 2 == 1 && i == i2); } - ) + } tx3.send(()); } - }) + } } - test!(fn cloning() { + test! { fn cloning() { let (tx1, rx1) = channel::<int>(); let (_tx2, rx2) = channel::<int>(); let (tx3, rx3) = channel::<()>(); @@ -486,14 +486,14 @@ mod test { }); tx3.send(()); - select!( + select! { _i1 = rx1.recv() => {}, _i2 = rx2.recv() => panic!() - ) + } tx3.send(()); - }) + } } - test!(fn cloning2() { + test! { fn cloning2() { let (tx1, rx1) = channel::<int>(); let (_tx2, rx2) = channel::<int>(); let (tx3, rx3) = channel::<()>(); @@ -507,14 +507,14 @@ mod test { }); tx3.send(()); - select!( + select! { _i1 = rx1.recv() => {}, _i2 = rx2.recv() => panic!() - ) + } tx3.send(()); - }) + } } - test!(fn cloning3() { + test! { fn cloning3() { let (tx1, rx1) = channel::<()>(); let (tx2, rx2) = channel::<()>(); let (tx3, rx3) = channel::<()>(); @@ -532,44 +532,44 @@ mod test { drop(tx1.clone()); tx2.send(()); rx3.recv(); - }) + } } - test!(fn preflight1() { + test! { fn preflight1() { let (tx, rx) = channel(); tx.send(()); - select!( + select! { () = rx.recv() => {} - ) - }) + } + } } - test!(fn preflight2() { + test! { fn preflight2() { let (tx, rx) = channel(); tx.send(()); tx.send(()); - select!( + select! { () = rx.recv() => {} - ) - }) + } + } } - test!(fn preflight3() { + test! { fn preflight3() { let (tx, rx) = channel(); drop(tx.clone()); tx.send(()); - select!( + select! { () = rx.recv() => {} - ) - }) + } + } } - test!(fn preflight4() { + test! { fn preflight4() { let (tx, rx) = channel(); tx.send(()); let s = Select::new(); let mut h = s.handle(&rx); unsafe { h.add(); } assert_eq!(s.wait2(false), h.id); - }) + } } - test!(fn preflight5() { + test! { fn preflight5() { let (tx, rx) = channel(); tx.send(()); tx.send(()); @@ -577,9 +577,9 @@ mod test { let mut h = s.handle(&rx); unsafe { h.add(); } assert_eq!(s.wait2(false), h.id); - }) + } } - test!(fn preflight6() { + test! { fn preflight6() { let (tx, rx) = channel(); drop(tx.clone()); tx.send(()); @@ -587,18 +587,18 @@ mod test { let mut h = s.handle(&rx); unsafe { h.add(); } assert_eq!(s.wait2(false), h.id); - }) + } } - test!(fn preflight7() { + test! { fn preflight7() { let (tx, rx) = channel::<()>(); drop(tx); let s = Select::new(); let mut h = s.handle(&rx); unsafe { h.add(); } assert_eq!(s.wait2(false), h.id); - }) + } } - test!(fn preflight8() { + test! { fn preflight8() { let (tx, rx) = channel(); tx.send(()); drop(tx); @@ -607,9 +607,9 @@ mod test { let mut h = s.handle(&rx); unsafe { h.add(); } assert_eq!(s.wait2(false), h.id); - }) + } } - test!(fn preflight9() { + test! { fn preflight9() { let (tx, rx) = channel(); drop(tx.clone()); tx.send(()); @@ -619,9 +619,9 @@ mod test { let mut h = s.handle(&rx); unsafe { h.add(); } assert_eq!(s.wait2(false), h.id); - }) + } } - test!(fn oneshot_data_waiting() { + test! { fn oneshot_data_waiting() { let (tx1, rx1) = channel(); let (tx2, rx2) = channel(); spawn(move|| { @@ -634,9 +634,9 @@ mod test { for _ in range(0u, 100) { task::deschedule() } tx1.send(()); rx2.recv(); - }) + } } - test!(fn stream_data_waiting() { + test! { fn stream_data_waiting() { let (tx1, rx1) = channel(); let (tx2, rx2) = channel(); tx1.send(()); @@ -653,9 +653,9 @@ mod test { for _ in range(0u, 100) { task::deschedule() } tx1.send(()); rx2.recv(); - }) + } } - test!(fn shared_data_waiting() { + test! { fn shared_data_waiting() { let (tx1, rx1) = channel(); let (tx2, rx2) = channel(); drop(tx1.clone()); @@ -671,17 +671,17 @@ mod test { for _ in range(0u, 100) { task::deschedule() } tx1.send(()); rx2.recv(); - }) + } } - test!(fn sync1() { + test! { fn sync1() { let (tx, rx) = sync_channel::<int>(1); tx.send(1); select! { n = rx.recv() => { assert_eq!(n, 1); } } - }) + } } - test!(fn sync2() { + test! { fn sync2() { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { for _ in range(0u, 100) { task::deschedule() } @@ -690,9 +690,9 @@ mod test { select! { n = rx.recv() => { assert_eq!(n, 1); } } - }) + } } - test!(fn sync3() { + test! { fn sync3() { let (tx1, rx1) = sync_channel::<int>(0); let (tx2, rx2): (Sender<int>, Receiver<int>) = channel(); spawn(move|| { tx1.send(1); }); @@ -707,5 +707,5 @@ mod test { assert_eq!(rx1.recv(), 1); } } - }) + } } } diff --git a/src/libstd/failure.rs b/src/libstd/failure.rs index 58a41f4d7d5..89bccb8b99f 100644 --- a/src/libstd/failure.rs +++ b/src/libstd/failure.rs @@ -27,9 +27,11 @@ use str::Str; use string::String; // Defined in this module instead of io::stdio so that the unwinding -thread_local!(pub static LOCAL_STDERR: RefCell<Option<Box<Writer + Send>>> = { - RefCell::new(None) -}) +thread_local! { + pub static LOCAL_STDERR: RefCell<Option<Box<Writer + Send>>> = { + RefCell::new(None) + } +} impl Writer for Stdio { fn write(&mut self, bytes: &[u8]) -> IoResult<()> { diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs index 24a000adef2..c1f1a5b7869 100644 --- a/src/libstd/io/extensions.rs +++ b/src/libstd/io/extensions.rs @@ -511,7 +511,7 @@ mod bench { use self::test::Bencher; // why is this a macro? wouldn't an inlined function work just as well? - macro_rules! u64_from_be_bytes_bench_impl( + macro_rules! u64_from_be_bytes_bench_impl { ($b:expr, $size:expr, $stride:expr, $start_index:expr) => ({ use super::u64_from_be_bytes; @@ -526,7 +526,7 @@ mod bench { } }); }) - ) + } #[bench] fn u64_from_be_bytes_4_aligned(b: &mut Bencher) { diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index f8df7e9b1f3..fd3bae73cd3 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -828,20 +828,20 @@ mod test { use ops::Drop; use str::StrPrelude; - macro_rules! check( ($e:expr) => ( + macro_rules! check { ($e:expr) => ( match $e { Ok(t) => t, Err(e) => panic!("{} failed with: {}", stringify!($e), e), } - ) ) + ) } - macro_rules! error( ($e:expr, $s:expr) => ( + macro_rules! error { ($e:expr, $s:expr) => ( match $e { Ok(_) => panic!("Unexpected success. Should've been: {}", $s), Err(ref err) => assert!(err.to_string().contains($s.as_slice()), format!("`{}` did not contain `{}`", err, $s)) } - ) ) + ) } pub struct TempDir(Path); diff --git a/src/libstd/io/net/ip.rs b/src/libstd/io/net/ip.rs index 092410fbc8e..5a3f5bd4668 100644 --- a/src/libstd/io/net/ip.rs +++ b/src/libstd/io/net/ip.rs @@ -478,7 +478,7 @@ fn resolve_socket_addr(s: &str, p: u16) -> IoResult<Vec<SocketAddr>> { } fn parse_and_resolve_socket_addr(s: &str) -> IoResult<Vec<SocketAddr>> { - macro_rules! try_opt( + macro_rules! try_opt { ($e:expr, $msg:expr) => ( match $e { Some(r) => r, @@ -489,7 +489,7 @@ fn parse_and_resolve_socket_addr(s: &str) -> IoResult<Vec<SocketAddr>> { }) } ) - ) + } // split the string by ':' and convert the second part to u16 let mut parts_iter = s.rsplitn(2, ':'); diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index 844814fbfdd..73be389bb91 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -95,9 +95,11 @@ fn src<T, F>(fd: libc::c_int, _readable: bool, f: F) -> T where } } -thread_local!(static LOCAL_STDOUT: RefCell<Option<Box<Writer + Send>>> = { - RefCell::new(None) -}) +thread_local! { + static LOCAL_STDOUT: RefCell<Option<Box<Writer + Send>>> = { + RefCell::new(None) + } +} /// A synchronized wrapper around a buffered reader from stdin #[deriving(Clone)] diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index a02b37fcfd1..798dac1a72f 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -37,7 +37,7 @@ /// panic!("this is a {} {message}", "fancy", message = "message"); /// ``` #[macro_export] -macro_rules! panic( +macro_rules! panic { () => ({ panic!("explicit panic") }); @@ -70,7 +70,7 @@ macro_rules! panic( } format_args!(_run_fmt, $fmt, $($arg)*) }); -) +} /// Ensure that a boolean expression is `true` at runtime. /// @@ -93,7 +93,7 @@ macro_rules! panic( /// assert!(a + b == 30, "a = {}, b = {}", a, b); /// ``` #[macro_export] -macro_rules! assert( +macro_rules! assert { ($cond:expr) => ( if !$cond { panic!(concat!("assertion failed: ", stringify!($cond))) @@ -104,7 +104,7 @@ macro_rules! assert( panic!($($arg),+) } ); -) +} /// Asserts that two expressions are equal to each other, testing equality in /// both directions. @@ -119,7 +119,7 @@ macro_rules! assert( /// assert_eq!(a, b); /// ``` #[macro_export] -macro_rules! assert_eq( +macro_rules! assert_eq { ($left:expr , $right:expr) => ({ match (&($left), &($right)) { (left_val, right_val) => { @@ -132,7 +132,7 @@ macro_rules! assert_eq( } } }) -) +} /// Ensure that a boolean expression is `true` at runtime. /// @@ -160,9 +160,9 @@ macro_rules! assert_eq( /// debug_assert!(a + b == 30, "a = {}, b = {}", a, b); /// ``` #[macro_export] -macro_rules! debug_assert( +macro_rules! debug_assert { ($($arg:tt)*) => (if cfg!(not(ndebug)) { assert!($($arg)*); }) -) +} /// Asserts that two expressions are equal to each other, testing equality in /// both directions. @@ -182,9 +182,9 @@ macro_rules! debug_assert( /// debug_assert_eq!(a, b); /// ``` #[macro_export] -macro_rules! debug_assert_eq( +macro_rules! debug_assert_eq { ($($arg:tt)*) => (if cfg!(not(ndebug)) { assert_eq!($($arg)*); }) -) +} /// A utility macro for indicating unreachable code. /// @@ -226,7 +226,7 @@ macro_rules! debug_assert_eq( /// } /// ``` #[macro_export] -macro_rules! unreachable( +macro_rules! unreachable { () => ({ panic!("internal error: entered unreachable code") }); @@ -236,14 +236,14 @@ macro_rules! unreachable( ($fmt:expr, $($arg:tt)*) => ({ panic!(concat!("internal error: entered unreachable code: ", $fmt), $($arg)*) }); -) +} /// A standardised placeholder for marking unfinished code. It panics with the /// message `"not yet implemented"` when executed. #[macro_export] -macro_rules! unimplemented( +macro_rules! unimplemented { () => (panic!("not yet implemented")) -) +} /// Use the syntax described in `std::fmt` to create a value of type `String`. /// See `std::fmt` for more information. @@ -257,11 +257,11 @@ macro_rules! unimplemented( /// ``` #[macro_export] #[stable] -macro_rules! format( +macro_rules! format { ($($arg:tt)*) => ( format_args!(::std::fmt::format, $($arg)*) ) -) +} /// Use the `format!` syntax to write data into a buffer of type `&mut Writer`. /// See `std::fmt` for more information. @@ -277,30 +277,30 @@ macro_rules! format( /// ``` #[macro_export] #[stable] -macro_rules! write( +macro_rules! write { ($dst:expr, $($arg:tt)*) => ({ let dst = &mut *$dst; format_args!(|args| { dst.write_fmt(args) }, $($arg)*) }) -) +} /// Equivalent to the `write!` macro, except that a newline is appended after /// the message is written. #[macro_export] #[stable] -macro_rules! writeln( +macro_rules! writeln { ($dst:expr, $fmt:expr $($arg:tt)*) => ( write!($dst, concat!($fmt, "\n") $($arg)*) ) -) +} /// Equivalent to the `println!` macro except that a newline is not printed at /// the end of the message. #[macro_export] #[stable] -macro_rules! print( +macro_rules! print { ($($arg:tt)*) => (format_args!(::std::io::stdio::print_args, $($arg)*)) -) +} /// Macro for printing to a task's stdout handle. /// @@ -316,33 +316,33 @@ macro_rules! print( /// ``` #[macro_export] #[stable] -macro_rules! println( +macro_rules! println { ($($arg:tt)*) => (format_args!(::std::io::stdio::println_args, $($arg)*)) -) +} /// Helper macro for unwrapping `Result` values while returning early with an /// error if the value of the expression is `Err`. For more information, see /// `std::io`. #[macro_export] -macro_rules! try ( +macro_rules! try { ($expr:expr) => ({ match $expr { Ok(val) => val, Err(err) => return Err(::std::error::FromError::from_error(err)) } }) -) +} /// Create a `std::vec::Vec` containing the arguments. #[macro_export] -macro_rules! vec[ +macro_rules! vec { ($($x:expr),*) => ({ use std::slice::BoxedSliceExt; let xs: ::std::boxed::Box<[_]> = box [$($x),*]; xs.into_vec() }); ($($x:expr,)*) => (vec![$($x),*]) -] +} /// A macro to select an event from a number of receivers. /// @@ -394,11 +394,11 @@ macro_rules! select { // uses. To get around this difference, we redefine the log!() macro here to be // just a dumb version of what it should be. #[cfg(test)] -macro_rules! log ( +macro_rules! log { ($lvl:expr, $($args:tt)*) => ( if log_enabled!($lvl) { println!($($args)*) } ) -) +} /// Built-in macros to the compiler itself. /// @@ -430,9 +430,9 @@ pub mod builtin { /// }, "hello {}", "world"); /// ``` #[macro_export] - macro_rules! format_args( ($closure:expr, $fmt:expr $($args:tt)*) => ({ + macro_rules! format_args { ($closure:expr, $fmt:expr $($args:tt)*) => ({ /* compiler built-in */ - }) ) + }) } /// Inspect an environment variable at compile time. /// @@ -450,7 +450,7 @@ pub mod builtin { /// println!("the $PATH variable at the time of compiling was: {}", path); /// ``` #[macro_export] - macro_rules! env( ($name:expr) => ({ /* compiler built-in */ }) ) + macro_rules! env { ($name:expr) => ({ /* compiler built-in */ }) } /// Optionally inspect an environment variable at compile time. /// @@ -469,7 +469,7 @@ pub mod builtin { /// println!("the secret key might be: {}", key); /// ``` #[macro_export] - macro_rules! option_env( ($name:expr) => ({ /* compiler built-in */ }) ) + macro_rules! option_env { ($name:expr) => ({ /* compiler built-in */ }) } /// Concatenate literals into a static byte slice. /// @@ -489,7 +489,7 @@ pub mod builtin { /// assert_eq!(rust[4], 255); /// ``` #[macro_export] - macro_rules! bytes( ($($e:expr),*) => ({ /* compiler built-in */ }) ) + macro_rules! bytes { ($($e:expr),*) => ({ /* compiler built-in */ }) } /// Concatenate identifiers into one identifier. /// @@ -513,7 +513,9 @@ pub mod builtin { /// # } /// ``` #[macro_export] - macro_rules! concat_idents( ($($e:ident),*) => ({ /* compiler built-in */ }) ) + macro_rules! concat_idents { + ($($e:ident),*) => ({ /* compiler built-in */ }) + } /// Concatenates literals into a static string slice. /// @@ -531,7 +533,7 @@ pub mod builtin { /// assert_eq!(s, "test10btrue"); /// ``` #[macro_export] - macro_rules! concat( ($($e:expr),*) => ({ /* compiler built-in */ }) ) + macro_rules! concat { ($($e:expr),*) => ({ /* compiler built-in */ }) } /// A macro which expands to the line number on which it was invoked. /// @@ -546,7 +548,7 @@ pub mod builtin { /// println!("defined on line: {}", current_line); /// ``` #[macro_export] - macro_rules! line( () => ({ /* compiler built-in */ }) ) + macro_rules! line { () => ({ /* compiler built-in */ }) } /// A macro which expands to the column number on which it was invoked. /// @@ -561,7 +563,7 @@ pub mod builtin { /// println!("defined on column: {}", current_col); /// ``` #[macro_export] - macro_rules! column( () => ({ /* compiler built-in */ }) ) + macro_rules! column { () => ({ /* compiler built-in */ }) } /// A macro which expands to the file name from which it was invoked. /// @@ -577,7 +579,7 @@ pub mod builtin { /// println!("defined in file: {}", this_file); /// ``` #[macro_export] - macro_rules! file( () => ({ /* compiler built-in */ }) ) + macro_rules! file { () => ({ /* compiler built-in */ }) } /// A macro which stringifies its argument. /// @@ -592,7 +594,7 @@ pub mod builtin { /// assert_eq!(one_plus_one, "1 + 1"); /// ``` #[macro_export] - macro_rules! stringify( ($t:tt) => ({ /* compiler built-in */ }) ) + macro_rules! stringify { ($t:tt) => ({ /* compiler built-in */ }) } /// Includes a utf8-encoded file as a string. /// @@ -606,7 +608,7 @@ pub mod builtin { /// let secret_key = include_str!("secret-key.ascii"); /// ``` #[macro_export] - macro_rules! include_str( ($file:expr) => ({ /* compiler built-in */ }) ) + macro_rules! include_str { ($file:expr) => ({ /* compiler built-in */ }) } /// Includes a file as a byte slice. /// @@ -620,7 +622,7 @@ pub mod builtin { /// let secret_key = include_bin!("secret-key.bin"); /// ``` #[macro_export] - macro_rules! include_bin( ($file:expr) => ({ /* compiler built-in */ }) ) + macro_rules! include_bin { ($file:expr) => ({ /* compiler built-in */ }) } /// Expands to a string that represents the current module path. /// @@ -640,7 +642,7 @@ pub mod builtin { /// test::foo(); /// ``` #[macro_export] - macro_rules! module_path( () => ({ /* compiler built-in */ }) ) + macro_rules! module_path { () => ({ /* compiler built-in */ }) } /// Boolean evaluation of configuration flags. /// @@ -661,5 +663,5 @@ pub mod builtin { /// }; /// ``` #[macro_export] - macro_rules! cfg( ($cfg:tt) => ({ /* compiler built-in */ }) ) + macro_rules! cfg { ($cfg:tt) => ({ /* compiler built-in */ }) } } 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 { } } -)) +) } diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index bea51712253..f872aa8e9a4 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -447,7 +447,7 @@ mod tests { use str; use str::StrPrelude; - macro_rules! t( + macro_rules! t { (s: $path:expr, $exp:expr) => ( { let path = $path; @@ -460,7 +460,7 @@ mod tests { assert!(path.as_vec() == $exp); } ) - ) + } #[test] fn test_paths() { @@ -533,14 +533,14 @@ mod tests { #[test] fn test_display_str() { - macro_rules! t( + macro_rules! t { ($path:expr, $disp:ident, $exp:expr) => ( { let path = Path::new($path); assert!(path.$disp().to_string() == $exp); } ) - ) + } t!("foo", display, "foo"); t!(b"foo\x80", display, "foo\u{FFFD}"); t!(b"foo\xFFbar", display, "foo\u{FFFD}bar"); @@ -563,7 +563,7 @@ mod tests { assert!(mo.as_slice() == $exp); } ) - ) + ); t!("foo", "foo"); t!(b"foo\x80", "foo\u{FFFD}"); @@ -585,7 +585,7 @@ mod tests { assert!(f == $expf); } ) - ) + ); t!(b"foo", "foo", "foo"); t!(b"foo/bar", "foo/bar", "bar"); @@ -619,7 +619,7 @@ mod tests { assert!(path.$op() == $exp); } ); - ) + ); t!(v: b"a/b/c", filename, Some(b"c")); t!(v: b"a/b/c\xFF", filename, Some(b"c\xFF")); @@ -693,7 +693,7 @@ mod tests { assert!(p1 == p2.join(join)); } ) - ) + ); t!(s: "a/b/c", ".."); t!(s: "/a/b/c", "d"); @@ -712,7 +712,7 @@ mod tests { assert!(p.as_str() == Some($exp)); } ) - ) + ); t!(s: "a/b/c", "d", "a/b/c/d"); t!(s: "/a/b/c", "d", "/a/b/c/d"); @@ -739,7 +739,7 @@ mod tests { assert!(p.as_vec() == $exp); } ) - ) + ); t!(s: "a/b/c", ["d", "e"], "a/b/c/d/e"); t!(s: "a/b/c", ["d", "/e"], "/e"); @@ -769,7 +769,7 @@ mod tests { assert!(result == $right); } ) - ) + ); t!(b: b"a/b/c", b"a/b", true); t!(b: b"a", b".", true); @@ -817,7 +817,7 @@ mod tests { assert!(res.as_str() == Some($exp)); } ) - ) + ); t!(s: "a/b/c", "..", "a/b"); t!(s: "/a/b/c", "d", "/a/b/c/d"); @@ -844,7 +844,7 @@ mod tests { assert!(res.as_vec() == $exp); } ) - ) + ); t!(s: "a/b/c", ["d", "e"], "a/b/c/d/e"); t!(s: "a/b/c", ["..", "d"], "a/b/d"); @@ -928,7 +928,7 @@ mod tests { assert!(p1 == p2.$with(arg)); } ) - ) + ); t!(v: b"a/b/c", set_filename, with_filename, b"d"); t!(v: b"/", set_filename, with_filename, b"foo"); @@ -982,7 +982,7 @@ mod tests { assert!(path.extension() == $ext); } ) - ) + ); t!(v: Path::new(b"a/b/c"), Some(b"c"), b"a/b", Some(b"c"), None); t!(v: Path::new(b"a/b/\xFF"), Some(b"\xFF"), b"a/b", Some(b"\xFF"), None); @@ -1029,7 +1029,7 @@ mod tests { assert_eq!(path.is_relative(), $rel); } ) - ) + ); t!(s: "a/b/c", false, true); t!(s: "/a/b/c", true, false); t!(s: "a", false, true); @@ -1050,7 +1050,7 @@ mod tests { assert_eq!(path.is_ancestor_of(&dest), $exp); } ) - ) + ); t!(s: "a/b/c", "a/b/c/d", true); t!(s: "a/b/c", "a/b/c", true); @@ -1091,7 +1091,7 @@ mod tests { assert_eq!(path.ends_with_path(&child), $exp); } ) - ) + ); t!(s: "a/b/c", "c", true); t!(s: "a/b/c", "d", false); @@ -1124,7 +1124,7 @@ mod tests { assert_eq!(res.as_ref().and_then(|x| x.as_str()), $exp); } ) - ) + ); t!(s: "a/b/c", "a/b", Some("c")); t!(s: "a/b/c", "a/b/d", Some("../c")); @@ -1186,7 +1186,7 @@ mod tests { assert_eq!(comps, exp) } ) - ) + ); t!(b: b"a/b/c", [b"a", b"b", b"c"]); t!(b: b"/\xFF/a/\x80", [b"\xFF", b"a", b"\x80"]); @@ -1218,7 +1218,7 @@ mod tests { assert_eq!(comps, exp); } ) - ) + ); t!(b: b"a/b/c", [Some("a"), Some("b"), Some("c")]); t!(b: b"/\xFF/a/\x80", [None, Some("a"), None]); diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index 8b18d1d8cd4..b376f6d0d5b 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -1122,7 +1122,7 @@ mod tests { use super::*; use super::parse_prefix; - macro_rules! t( + macro_rules! t { (s: $path:expr, $exp:expr) => ( { let path = $path; @@ -1135,7 +1135,7 @@ mod tests { assert!(path.as_vec() == $exp); } ) - ) + } #[test] fn test_parse_prefix() { @@ -1149,7 +1149,7 @@ mod tests { "parse_prefix(\"{}\"): expected {}, found {}", path, exp, res); } ) - ) + ); t!("\\\\SERVER\\share\\foo", Some(UNCPrefix(6,5))); t!("\\\\", None); @@ -1348,7 +1348,7 @@ mod tests { assert_eq!(f, $expf); } ) - ) + ); t!("foo", "foo", "foo"); t!("foo\\bar", "foo\\bar", "bar"); @@ -1380,7 +1380,7 @@ mod tests { assert!(path.$op() == $exp); } ) - ) + ); t!(v: b"a\\b\\c", filename, Some(b"c")); t!(s: "a\\b\\c", filename_str, "c"); @@ -1491,7 +1491,7 @@ mod tests { assert!(p1 == p2.join(join)); } ) - ) + ); t!(s: "a\\b\\c", ".."); t!(s: "\\a\\b\\c", "d"); @@ -1524,7 +1524,7 @@ mod tests { assert_eq!(p.as_str(), Some($exp)); } ) - ) + ); t!(s: "a\\b\\c", "d", "a\\b\\c\\d"); t!(s: "\\a\\b\\c", "d", "\\a\\b\\c\\d"); @@ -1582,7 +1582,7 @@ mod tests { assert_eq!(p.as_vec(), $exp); } ) - ) + ); t!(s: "a\\b\\c", ["d", "e"], "a\\b\\c\\d\\e"); t!(s: "a\\b\\c", ["d", "\\e"], "\\e"); @@ -1617,7 +1617,7 @@ mod tests { assert!(result == $right); } ) - ) + ); t!(s: "a\\b\\c", "a\\b", true); t!(s: "a", ".", true); @@ -1694,7 +1694,7 @@ mod tests { assert_eq!(res.as_str(), Some($exp)); } ) - ) + ); t!(s: "a\\b\\c", "..", "a\\b"); t!(s: "\\a\\b\\c", "d", "\\a\\b\\c\\d"); @@ -1723,7 +1723,7 @@ mod tests { assert_eq!(res.as_vec(), $exp); } ) - ) + ); t!(s: "a\\b\\c", ["d", "e"], "a\\b\\c\\d\\e"); t!(s: "a\\b\\c", ["..", "d"], "a\\b\\d"); @@ -1749,7 +1749,7 @@ mod tests { pstr, stringify!($op), arg, exp, res.as_str().unwrap()); } ) - ) + ); t!(s: "a\\b\\c", with_filename, "d", "a\\b\\d"); t!(s: ".", with_filename, "foo", "foo"); @@ -1842,7 +1842,7 @@ mod tests { assert!(p1 == p2.$with(arg)); } ) - ) + ); t!(v: b"a\\b\\c", set_filename, with_filename, b"d"); t!(v: b"\\", set_filename, with_filename, b"foo"); @@ -1897,7 +1897,7 @@ mod tests { assert!(path.extension() == $ext); } ) - ) + ); t!(v: Path::new(b"a\\b\\c"), Some(b"c"), b"a\\b", Some(b"c"), None); t!(s: Path::new("a\\b\\c"), Some("c"), Some("a\\b"), Some("c"), None); @@ -1951,7 +1951,7 @@ mod tests { path.as_str().unwrap(), rel, b); } ) - ) + ); t!("a\\b\\c", false, false, false, true); t!("\\a\\b\\c", false, true, false, false); t!("a", false, false, false, true); @@ -1984,7 +1984,7 @@ mod tests { path.as_str().unwrap(), dest.as_str().unwrap(), exp, res); } ) - ) + ); t!(s: "a\\b\\c", "a\\b\\c\\d", true); t!(s: "a\\b\\c", "a\\b\\c", true); @@ -2083,7 +2083,7 @@ mod tests { assert_eq!(path.ends_with_path(&child), $exp); } ); - ) + ); t!(s: "a\\b\\c", "c", true); t!(s: "a\\b\\c", "d", false); @@ -2120,7 +2120,7 @@ mod tests { res.as_ref().and_then(|x| x.as_str())); } ) - ) + ); t!(s: "a\\b\\c", "a\\b", Some("c")); t!(s: "a\\b\\c", "a\\b\\d", Some("..\\c")); @@ -2255,7 +2255,7 @@ mod tests { assert_eq!(comps, exp); } ); - ) + ); t!(s: b"a\\b\\c", ["a", "b", "c"]); t!(s: "a\\b\\c", ["a", "b", "c"]); @@ -2311,7 +2311,7 @@ mod tests { assert_eq!(comps, exp); } ) - ) + ); t!(s: "a\\b\\c", [b"a", b"b", b"c"]); t!(s: ".", [b"."]); @@ -2329,7 +2329,7 @@ mod tests { assert!(make_non_verbatim(&path) == exp); } ) - ) + ); t!(r"\a\b\c", Some(r"\a\b\c")); t!(r"a\b\c", Some(r"a\b\c")); diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs index 5b5fa2952e6..d8e1fc25654 100644 --- a/src/libstd/rand/mod.rs +++ b/src/libstd/rand/mod.rs @@ -350,7 +350,7 @@ pub fn task_rng() -> TaskRng { TASK_RNG_RESEED_THRESHOLD, TaskRngReseeder); Rc::new(RefCell::new(rng)) - }) + }); TaskRng { rng: TASK_RNG_KEY.with(|t| t.clone()) } } diff --git a/src/libstd/rt/backtrace.rs b/src/libstd/rt/backtrace.rs index ad4695eb7fe..c2fc7653b09 100644 --- a/src/libstd/rt/backtrace.rs +++ b/src/libstd/rt/backtrace.rs @@ -109,7 +109,7 @@ fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> { rest = rest.slice_to(i); while rest.len() > 0 { if rest.starts_with("$") { - macro_rules! demangle( + macro_rules! demangle { ($($pat:expr => $demangled:expr),*) => ({ $(if rest.starts_with($pat) { try!(writer.write_str($demangled)); @@ -121,7 +121,8 @@ fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> { } }) - ) + } + // see src/librustc/back/link.rs for these mappings demangle! ( "$SP$" => "@", @@ -933,12 +934,12 @@ mod imp { Err(..) => return Ok(()), }; - macro_rules! sym( ($e:expr, $t:ident) => (unsafe { + macro_rules! sym { ($e:expr, $t:ident) => (unsafe { match lib.symbol($e) { Ok(f) => mem::transmute::<*mut u8, $t>(f), Err(..) => return Ok(()) } - }) ) + }) } // Fetch the symbols necessary from dbghelp.dll let SymFromAddr = sym!("SymFromAddr", SymFromAddrFn); @@ -1003,11 +1004,13 @@ mod imp { #[cfg(test)] mod test { use prelude::*; - macro_rules! t( ($a:expr, $b:expr) => ({ + use io::MemWriter; + + macro_rules! t { ($a:expr, $b:expr) => ({ let mut m = Vec::new(); super::demangle(&mut m, $a).unwrap(); assert_eq!(String::from_utf8(m).unwrap(), $b); - }) ) + }) } #[test] fn demangle() { diff --git a/src/libstd/sys/unix/mod.rs b/src/libstd/sys/unix/mod.rs index 107263c31a7..acbf2096326 100644 --- a/src/libstd/sys/unix/mod.rs +++ b/src/libstd/sys/unix/mod.rs @@ -23,7 +23,7 @@ use prelude::*; use io::{mod, IoResult, IoError}; use sys_common::mkerr_libc; -macro_rules! helper_init( (static $name:ident: Helper<$m:ty>) => ( +macro_rules! helper_init { (static $name:ident: Helper<$m:ty>) => ( static $name: Helper<$m> = Helper { lock: ::sync::MUTEX_INIT, cond: ::sync::CONDVAR_INIT, @@ -32,7 +32,7 @@ macro_rules! helper_init( (static $name:ident: Helper<$m:ty>) => ( initialized: ::cell::UnsafeCell { value: false }, shutdown: ::cell::UnsafeCell { value: false }, }; -) ) +) } pub mod c; pub mod ext; diff --git a/src/libstd/sys/unix/process.rs b/src/libstd/sys/unix/process.rs index 4ef1757cc3a..835f4279d9b 100644 --- a/src/libstd/sys/unix/process.rs +++ b/src/libstd/sys/unix/process.rs @@ -28,7 +28,7 @@ use sys_common::{AsInner, mkerr_libc, timeout}; pub use sys_common::ProcessConfig; -helper_init!(static HELPER: Helper<Req>) +helper_init! { static HELPER: Helper<Req> } /// The unique id of the process (this should never be negative). pub struct Process { diff --git a/src/libstd/sys/unix/timer.rs b/src/libstd/sys/unix/timer.rs index 6ebbedb8e90..79a6a871f8d 100644 --- a/src/libstd/sys/unix/timer.rs +++ b/src/libstd/sys/unix/timer.rs @@ -60,7 +60,7 @@ use sys_common::helper_thread::Helper; use prelude::*; use io::IoResult; -helper_init!(static HELPER: Helper<Req>) +helper_init! { static HELPER: Helper<Req> } pub trait Callback { fn call(&mut self); diff --git a/src/libstd/sys/windows/c.rs b/src/libstd/sys/windows/c.rs index e46765f25b8..d1cb91bcdb3 100644 --- a/src/libstd/sys/windows/c.rs +++ b/src/libstd/sys/windows/c.rs @@ -169,7 +169,7 @@ pub mod compat { /// /// Note that arguments unused by the fallback implementation should not be called `_` as /// they are used to be passed to the real function if available. - macro_rules! compat_fn( + macro_rules! compat_fn { ($module:ident::$symbol:ident($($argname:ident: $argtype:ty),*) -> $rettype:ty $fallback:block) => ( #[inline(always)] @@ -195,7 +195,7 @@ pub mod compat { ($module:ident::$symbol:ident($($argname:ident: $argtype:ty),*) $fallback:block) => ( compat_fn!($module::$symbol($($argname: $argtype),*) -> () $fallback) ) - ) + } /// Compatibility layer for functions in `kernel32.dll` /// @@ -211,20 +211,20 @@ pub mod compat { fn SetLastError(dwErrCode: DWORD); } - compat_fn!(kernel32::CreateSymbolicLinkW(_lpSymlinkFileName: LPCWSTR, + compat_fn! { kernel32::CreateSymbolicLinkW(_lpSymlinkFileName: LPCWSTR, _lpTargetFileName: LPCWSTR, _dwFlags: DWORD) -> BOOLEAN { unsafe { SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); } 0 - }) + } } - compat_fn!(kernel32::GetFinalPathNameByHandleW(_hFile: HANDLE, + compat_fn! { kernel32::GetFinalPathNameByHandleW(_hFile: HANDLE, _lpszFilePath: LPCWSTR, _cchFilePath: DWORD, _dwFlags: DWORD) -> DWORD { unsafe { SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); } 0 - }) + } } } } diff --git a/src/libstd/sys/windows/mod.rs b/src/libstd/sys/windows/mod.rs index 41361a0cde6..d22d4e0f534 100644 --- a/src/libstd/sys/windows/mod.rs +++ b/src/libstd/sys/windows/mod.rs @@ -24,7 +24,7 @@ use prelude::*; use io::{mod, IoResult, IoError}; use sync::{Once, ONCE_INIT}; -macro_rules! helper_init( (static $name:ident: Helper<$m:ty>) => ( +macro_rules! helper_init { (static $name:ident: Helper<$m:ty>) => ( static $name: Helper<$m> = Helper { lock: ::sync::MUTEX_INIT, cond: ::sync::CONDVAR_INIT, @@ -33,7 +33,7 @@ macro_rules! helper_init( (static $name:ident: Helper<$m:ty>) => ( initialized: ::cell::UnsafeCell { value: false }, shutdown: ::cell::UnsafeCell { value: false }, }; -) ) +) } pub mod c; pub mod ext; diff --git a/src/libstd/sys/windows/timer.rs b/src/libstd/sys/windows/timer.rs index 9af3a7c8b6e..e2f9e2a9201 100644 --- a/src/libstd/sys/windows/timer.rs +++ b/src/libstd/sys/windows/timer.rs @@ -32,7 +32,7 @@ use sys_common::helper_thread::Helper; use prelude::*; use io::IoResult; -helper_init!(static HELPER: Helper<Req>) +helper_init! { static HELPER: Helper<Req> } pub trait Callback { fn call(&mut self); diff --git a/src/libstd/thread_local/mod.rs b/src/libstd/thread_local/mod.rs index 76fb703514b..1268ab8e0cf 100644 --- a/src/libstd/thread_local/mod.rs +++ b/src/libstd/thread_local/mod.rs @@ -109,7 +109,7 @@ pub struct Key<T> { /// Declare a new thread local storage key of type `std::thread_local::Key`. #[macro_export] #[doc(hidden)] -macro_rules! thread_local( +macro_rules! thread_local { (static $name:ident: $t:ty = $init:expr) => ( static $name: ::std::thread_local::Key<$t> = { use std::cell::UnsafeCell as __UnsafeCell; @@ -119,7 +119,7 @@ macro_rules! thread_local( __thread_local_inner!(static __KEY: __UnsafeCell<__Option<$t>> = { __UnsafeCell { value: __None } - }) + }); fn __init() -> $t { $init } fn __getit() -> &'static __KeyInner<__UnsafeCell<__Option<$t>>> { &__KEY @@ -136,7 +136,7 @@ macro_rules! thread_local( __thread_local_inner!(static __KEY: __UnsafeCell<__Option<$t>> = { __UnsafeCell { value: __None } - }) + }); fn __init() -> $t { $init } fn __getit() -> &'static __KeyInner<__UnsafeCell<__Option<$t>>> { &__KEY @@ -144,7 +144,7 @@ macro_rules! thread_local( ::std::thread_local::Key { inner: __getit, init: __init } }; ); -) +} // Macro pain #4586: // @@ -167,7 +167,7 @@ macro_rules! thread_local( // itself. Woohoo. #[macro_export] -macro_rules! __thread_local_inner( +macro_rules! __thread_local_inner { (static $name:ident: $t:ty = $init:expr) => ( #[cfg_attr(any(target_os = "macos", target_os = "linux"), thread_local)] static $name: ::std::thread_local::KeyInner<$t> = @@ -204,7 +204,7 @@ macro_rules! __thread_local_inner( INIT }); -) +} impl<T: 'static> Key<T> { /// Acquire a reference to the value in this TLS key. @@ -459,7 +459,7 @@ mod tests { #[test] fn smoke_no_dtor() { - thread_local!(static FOO: UnsafeCell<int> = UnsafeCell { value: 1 }) + thread_local!(static FOO: UnsafeCell<int> = UnsafeCell { value: 1 }); FOO.with(|f| unsafe { assert_eq!(*f.get(), 1); @@ -483,7 +483,7 @@ mod tests { fn smoke_dtor() { thread_local!(static FOO: UnsafeCell<Option<Foo>> = UnsafeCell { value: None - }) + }); let (tx, rx) = channel(); spawn(move|| unsafe { @@ -501,10 +501,10 @@ mod tests { struct S2; thread_local!(static K1: UnsafeCell<Option<S1>> = UnsafeCell { value: None - }) + }); thread_local!(static K2: UnsafeCell<Option<S2>> = UnsafeCell { value: None - }) + }); static mut HITS: uint = 0; impl Drop for S1 { @@ -544,7 +544,7 @@ mod tests { struct S1; thread_local!(static K1: UnsafeCell<Option<S1>> = UnsafeCell { value: None - }) + }); impl Drop for S1 { fn drop(&mut self) { @@ -562,10 +562,10 @@ mod tests { struct S1(Sender<()>); thread_local!(static K1: UnsafeCell<Option<S1>> = UnsafeCell { value: None - }) + }); thread_local!(static K2: UnsafeCell<Option<Foo>> = UnsafeCell { value: None - }) + }); impl Drop for S1 { fn drop(&mut self) { @@ -597,7 +597,7 @@ mod dynamic_tests { #[test] fn smoke() { fn square(i: int) -> int { i * i } - thread_local!(static FOO: int = square(3)) + thread_local!(static FOO: int = square(3)); FOO.with(|f| { assert_eq!(*f, 9); @@ -611,7 +611,7 @@ mod dynamic_tests { m.insert(1, 2); RefCell::new(m) } - thread_local!(static FOO: RefCell<HashMap<int, int>> = map()) + thread_local!(static FOO: RefCell<HashMap<int, int>> = map()); FOO.with(|map| { assert_eq!(map.borrow()[1], 2); @@ -620,7 +620,7 @@ mod dynamic_tests { #[test] fn refcell_vec() { - thread_local!(static FOO: RefCell<Vec<uint>> = RefCell::new(vec![1, 2, 3])) + thread_local!(static FOO: RefCell<Vec<uint>> = RefCell::new(vec![1, 2, 3])); FOO.with(|vec| { assert_eq!(vec.borrow().len(), 3); diff --git a/src/libstd/thread_local/scoped.rs b/src/libstd/thread_local/scoped.rs index ee742ab8375..7762d225b9a 100644 --- a/src/libstd/thread_local/scoped.rs +++ b/src/libstd/thread_local/scoped.rs @@ -24,7 +24,7 @@ //! # Example //! //! ``` -//! scoped_thread_local!(static FOO: uint) +//! scoped_thread_local!(static FOO: uint); //! //! // Initially each scoped slot is empty. //! assert!(!FOO.is_set()); @@ -60,18 +60,18 @@ pub struct Key<T> { #[doc(hidden)] pub inner: KeyInner<T> } /// This macro declares a `static` item on which methods are used to get and /// set the value stored within. #[macro_export] -macro_rules! scoped_thread_local( +macro_rules! scoped_thread_local { (static $name:ident: $t:ty) => ( __scoped_thread_local_inner!(static $name: $t) ); (pub static $name:ident: $t:ty) => ( __scoped_thread_local_inner!(pub static $name: $t) ); -) +} #[macro_export] #[doc(hidden)] -macro_rules! __scoped_thread_local_inner( +macro_rules! __scoped_thread_local_inner { (static $name:ident: $t:ty) => ( #[cfg_attr(not(any(windows, target_os = "android", target_os = "ios")), thread_local)] @@ -104,7 +104,7 @@ macro_rules! __scoped_thread_local_inner( INIT }) -) +} impl<T> Key<T> { /// Insert a value into this scoped thread local storage slot for a @@ -119,7 +119,7 @@ impl<T> Key<T> { /// # Example /// /// ``` - /// scoped_thread_local!(static FOO: uint) + /// scoped_thread_local!(static FOO: uint); /// /// FOO.set(&100, || { /// let val = FOO.with(|v| *v); @@ -171,7 +171,7 @@ impl<T> Key<T> { /// # Example /// /// ```no_run - /// scoped_thread_local!(static FOO: uint) + /// scoped_thread_local!(static FOO: uint); /// /// FOO.with(|slot| { /// // work with `slot` @@ -239,7 +239,7 @@ mod tests { #[test] fn smoke() { - scoped_thread_local!(static BAR: uint) + scoped_thread_local!(static BAR: uint); assert!(!BAR.is_set()); BAR.set(&1, || { @@ -253,7 +253,7 @@ mod tests { #[test] fn cell_allowed() { - scoped_thread_local!(static BAR: Cell<uint>) + scoped_thread_local!(static BAR: Cell<uint>); BAR.set(&Cell::new(1), || { BAR.with(|slot| { diff --git a/src/libstd/time/duration.rs b/src/libstd/time/duration.rs index f98cebd9675..8c4a5a6b8c7 100644 --- a/src/libstd/time/duration.rs +++ b/src/libstd/time/duration.rs @@ -40,9 +40,9 @@ const SECS_PER_DAY: i64 = 86400; /// The number of (non-leap) seconds in a week. const SECS_PER_WEEK: i64 = 604800; -macro_rules! try_opt( +macro_rules! try_opt { ($e:expr) => (match $e { Some(v) => v, None => return None }) -) +} /// ISO 8601 time duration with nanosecond precision. diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 98d858babb1..d4860766d47 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -31,6 +31,7 @@ pub use self::Lit_::*; pub use self::LitIntType::*; pub use self::LocalSource::*; pub use self::Mac_::*; +pub use self::MacStmtStyle::*; pub use self::MatchSource::*; pub use self::MetaItem_::*; pub use self::Method_::*; @@ -615,8 +616,20 @@ pub enum Stmt_ { /// Expr with trailing semi-colon (may have any type): StmtSemi(P<Expr>, NodeId), - /// bool: is there a trailing semi-colon? - StmtMac(Mac, bool), + StmtMac(Mac, MacStmtStyle), +} + +#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +pub enum MacStmtStyle { + /// The macro statement had a trailing semicolon, e.g. `foo! { ... };` + /// `foo!(...);`, `foo![...];` + MacStmtWithSemicolon, + /// The macro statement had braces; e.g. foo! { ... } + MacStmtWithBraces, + /// The macro statement had parentheses or brackets and no semicolon; e.g. + /// `foo!(...)`. All of these will end up being converted into macro + /// expressions. + MacStmtWithoutBraces, } /// Where a local declaration came from: either a true `let ... = diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 2e097d45515..aaa172633be 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -753,16 +753,20 @@ macro_rules! mf_method{ impl PostExpansionMethod for Method { - mf_method!(pe_ident,ast::Ident,MethDecl(ident,_,_,_,_,_,_,_),ident) - mf_method!(pe_generics,&'a ast::Generics, - MethDecl(_,ref generics,_,_,_,_,_,_),generics) - mf_method!(pe_abi,Abi,MethDecl(_,_,abi,_,_,_,_,_),abi) - mf_method!(pe_explicit_self,&'a ast::ExplicitSelf, - MethDecl(_,_,_,ref explicit_self,_,_,_,_),explicit_self) - mf_method!(pe_unsafety,ast::Unsafety,MethDecl(_,_,_,_,unsafety,_,_,_),unsafety) - mf_method!(pe_fn_decl,&'a ast::FnDecl,MethDecl(_,_,_,_,_,ref decl,_,_),&**decl) - mf_method!(pe_body,&'a ast::Block,MethDecl(_,_,_,_,_,_,ref body,_),&**body) - mf_method!(pe_vis,ast::Visibility,MethDecl(_,_,_,_,_,_,_,vis),vis) + mf_method! { pe_ident,ast::Ident,MethDecl(ident,_,_,_,_,_,_,_),ident } + mf_method! { + pe_generics,&'a ast::Generics, + MethDecl(_,ref generics,_,_,_,_,_,_),generics + } + mf_method! { pe_abi,Abi,MethDecl(_,_,abi,_,_,_,_,_),abi } + mf_method! { + pe_explicit_self,&'a ast::ExplicitSelf, + MethDecl(_,_,_,ref explicit_self,_,_,_,_),explicit_self + } + mf_method! { pe_unsafety,ast::Unsafety,MethDecl(_,_,_,_,unsafety,_,_,_),unsafety } + mf_method! { pe_fn_decl,&'a ast::FnDecl,MethDecl(_,_,_,_,_,ref decl,_,_),&**decl } + mf_method! { pe_body,&'a ast::Block,MethDecl(_,_,_,_,_,_,ref body,_),&**body } + mf_method! { pe_vis,ast::Visibility,MethDecl(_,_,_,_,_,_,_,vis),vis } } #[cfg(test)] diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 8248eae4b8c..598da6a5df0 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -29,7 +29,7 @@ use std::cell::{RefCell, Cell}; use std::collections::BitvSet; use std::collections::HashSet; -thread_local!(static USED_ATTRS: RefCell<BitvSet> = RefCell::new(BitvSet::new())) +thread_local! { static USED_ATTRS: RefCell<BitvSet> = RefCell::new(BitvSet::new()) } pub fn mark_used(attr: &Attribute) { let AttrId(id) = attr.node.id; @@ -169,7 +169,7 @@ pub fn mk_word_item(name: InternedString) -> P<MetaItem> { P(dummy_spanned(MetaWord(name))) } -thread_local!(static NEXT_ATTR_ID: Cell<uint> = Cell::new(0)) +thread_local! { static NEXT_ATTR_ID: Cell<uint> = Cell::new(0) } pub fn mk_attr_id() -> AttrId { let id = NEXT_ATTR_ID.with(|slot| { diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 592fdd7207c..17cafc2441f 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -329,7 +329,7 @@ impl FileMap { // the new charpos must be > the last one (or it's the first one). let mut lines = self.lines.borrow_mut(); let line_len = lines.len(); - assert!(line_len == 0 || ((*lines)[line_len - 1] < pos)) + assert!(line_len == 0 || ((*lines)[line_len - 1] < pos)); lines.push(pos); } diff --git a/src/libsyntax/diagnostics/macros.rs b/src/libsyntax/diagnostics/macros.rs index b4bf793d4e1..3107508a96a 100644 --- a/src/libsyntax/diagnostics/macros.rs +++ b/src/libsyntax/diagnostics/macros.rs @@ -11,44 +11,45 @@ #![macro_escape] #[macro_export] -macro_rules! register_diagnostic( - ($code:tt, $description:tt) => (__register_diagnostic!($code, $description)); - ($code:tt) => (__register_diagnostic!($code)) -) +macro_rules! register_diagnostic { + ($code:tt, $description:tt) => (__register_diagnostic! { $code, $description }); + ($code:tt) => (__register_diagnostic! { $code }) +} #[macro_export] -macro_rules! span_err( +macro_rules! span_err { ($session:expr, $span:expr, $code:ident, $($message:tt)*) => ({ __diagnostic_used!($code); $session.span_err_with_code($span, format!($($message)*).as_slice(), stringify!($code)) }) -) +} #[macro_export] -macro_rules! span_warn( +macro_rules! span_warn { ($session:expr, $span:expr, $code:ident, $($message:tt)*) => ({ __diagnostic_used!($code); $session.span_warn_with_code($span, format!($($message)*).as_slice(), stringify!($code)) }) -) +} #[macro_export] -macro_rules! span_note( +macro_rules! span_note { ($session:expr, $span:expr, $($message:tt)*) => ({ ($session).span_note($span, format!($($message)*).as_slice()) }) -) +} #[macro_export] -macro_rules! span_help( +macro_rules! span_help { ($session:expr, $span:expr, $($message:tt)*) => ({ ($session).span_help($span, format!($($message)*).as_slice()) }) -) +} #[macro_export] -macro_rules! register_diagnostics( +macro_rules! register_diagnostics { ($($code:tt),*) => ( - $(register_diagnostic!($code))* + $(register_diagnostic! { $code })* ) -) +} + diff --git a/src/libsyntax/diagnostics/plugin.rs b/src/libsyntax/diagnostics/plugin.rs index cb2a1f8acd8..bcce5538314 100644 --- a/src/libsyntax/diagnostics/plugin.rs +++ b/src/libsyntax/diagnostics/plugin.rs @@ -18,12 +18,16 @@ use ext::build::AstBuilder; use parse::token; use ptr::P; -thread_local!(static REGISTERED_DIAGNOSTICS: RefCell<HashMap<Name, Option<Name>>> = { - RefCell::new(HashMap::new()) -}) -thread_local!(static USED_DIAGNOSTICS: RefCell<HashMap<Name, Span>> = { - RefCell::new(HashMap::new()) -}) +thread_local! { + static REGISTERED_DIAGNOSTICS: RefCell<HashMap<Name, Option<Name>>> = { + RefCell::new(HashMap::new()) + } +} +thread_local! { + static USED_DIAGNOSTICS: RefCell<HashMap<Name, Span>> = { + RefCell::new(HashMap::new()) + } +} fn with_registered_diagnostics<T, F>(f: F) -> T where F: FnOnce(&mut HashMap<Name, Option<Name>>) -> T, diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index e280e6e4491..20c8ff20b71 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -11,7 +11,8 @@ use self::Either::*; use ast::{Block, Crate, DeclLocal, ExprMac, PatMac}; use ast::{Local, Ident, MacInvocTT}; -use ast::{ItemMac, Mrk, Stmt, StmtDecl, StmtMac, StmtExpr, StmtSemi}; +use ast::{ItemMac, MacStmtWithSemicolon, Mrk, Stmt, StmtDecl, StmtMac}; +use ast::{StmtExpr, StmtSemi}; use ast::TokenTree; use ast; use ext::mtwt; @@ -354,7 +355,7 @@ fn expand_loop_block(loop_block: P<Block>, // eval $e with a new exts frame. // must be a macro so that $e isn't evaluated too early. -macro_rules! with_exts_frame ( +macro_rules! with_exts_frame { ($extsboxexpr:expr,$macros_escape:expr,$e:expr) => ({$extsboxexpr.push_frame(); $extsboxexpr.info().macros_escape = $macros_escape; @@ -362,7 +363,7 @@ macro_rules! with_exts_frame ( $extsboxexpr.pop_frame(); result }) -) +} // When we enter a module, record it, for the sake of `module!` pub fn expand_item(it: P<ast::Item>, fld: &mut MacroExpander) @@ -636,8 +637,8 @@ pub fn expand_item_mac(it: P<ast::Item>, fld: &mut MacroExpander) // I don't understand why this returns a vector... it looks like we're // half done adding machinery to allow macros to expand into multiple statements. fn expand_stmt(s: Stmt, fld: &mut MacroExpander) -> SmallVector<P<Stmt>> { - let (mac, semi) = match s.node { - StmtMac(mac, semi) => (mac, semi), + let (mac, style) = match s.node { + StmtMac(mac, style) => (mac, style), _ => return expand_non_macro_stmt(s, fld) }; let expanded_stmt = match expand_mac_invoc(mac, s.span, @@ -653,7 +654,7 @@ fn expand_stmt(s: Stmt, fld: &mut MacroExpander) -> SmallVector<P<Stmt>> { let fully_expanded = fld.fold_stmt(expanded_stmt); fld.cx.bt_pop(); - if semi { + if style == MacStmtWithSemicolon { fully_expanded.into_iter().map(|s| s.map(|Spanned {node, span}| { Spanned { node: match node { @@ -1324,7 +1325,7 @@ mod test { // make sure that macros can't escape fns #[should_fail] #[test] fn macros_cant_escape_fns_test () { - let src = "fn bogus() {macro_rules! z (() => (3+4))}\ + let src = "fn bogus() {macro_rules! z (() => (3+4));}\ fn inty() -> int { z!() }".to_string(); let sess = parse::new_parse_sess(); let crate_ast = parse::parse_crate_from_source_str( @@ -1338,7 +1339,7 @@ mod test { // make sure that macros can't escape modules #[should_fail] #[test] fn macros_cant_escape_mods_test () { - let src = "mod foo {macro_rules! z (() => (3+4))}\ + let src = "mod foo {macro_rules! z (() => (3+4));}\ fn inty() -> int { z!() }".to_string(); let sess = parse::new_parse_sess(); let crate_ast = parse::parse_crate_from_source_str( @@ -1350,7 +1351,7 @@ mod test { // macro_escape modules should allow macros to escape #[test] fn macros_can_escape_flattened_mods_test () { - let src = "#[macro_escape] mod foo {macro_rules! z (() => (3+4))}\ + let src = "#[macro_escape] mod foo {macro_rules! z (() => (3+4));}\ fn inty() -> int { z!() }".to_string(); let sess = parse::new_parse_sess(); let crate_ast = parse::parse_crate_from_source_str( @@ -1402,13 +1403,13 @@ mod test { #[test] fn macro_tokens_should_match(){ expand_crate_str( - "macro_rules! m((a)=>(13)) fn main(){m!(a);}".to_string()); + "macro_rules! m((a)=>(13)) ;fn main(){m!(a);}".to_string()); } // should be able to use a bound identifier as a literal in a macro definition: #[test] fn self_macro_parsing(){ expand_crate_str( - "macro_rules! foo ((zz) => (287u;)) + "macro_rules! foo ((zz) => (287u;)); fn f(zz : int) {foo!(zz);}".to_string() ); } @@ -1451,16 +1452,16 @@ mod test { ("fn main () {let x: int = 13;x;}", vec!(vec!(0)), false), // the use of b after the + should be renamed, the other one not: - ("macro_rules! f (($x:ident) => (b + $x)) fn a() -> int { let b = 13; f!(b)}", + ("macro_rules! f (($x:ident) => (b + $x)); fn a() -> int { let b = 13; f!(b)}", vec!(vec!(1)), false), // the b before the plus should not be renamed (requires marks) - ("macro_rules! f (($x:ident) => ({let b=9; ($x + b)})) fn a() -> int { f!(b)}", + ("macro_rules! f (($x:ident) => ({let b=9; ($x + b)})); fn a() -> int { f!(b)}", vec!(vec!(1)), false), // the marks going in and out of letty should cancel, allowing that $x to // capture the one following the semicolon. // this was an awesome test case, and caught a *lot* of bugs. - ("macro_rules! letty(($x:ident) => (let $x = 15;)) - macro_rules! user(($x:ident) => ({letty!($x); $x})) + ("macro_rules! letty(($x:ident) => (let $x = 15;)); + macro_rules! user(($x:ident) => ({letty!($x); $x})); fn main() -> int {user!(z)}", vec!(vec!(0)), false) ); @@ -1488,7 +1489,7 @@ mod test { #[test] fn issue_6994(){ run_renaming_test( &("macro_rules! g (($x:ident) => - ({macro_rules! f(($y:ident)=>({let $y=3;$x}));f!($x)})) + ({macro_rules! f(($y:ident)=>({let $y=3;$x}));f!($x)})); fn a(){g!(z)}", vec!(vec!(0)),false), 0) @@ -1498,7 +1499,7 @@ mod test { // fn z() {match 8 {x_1 => {match 9 {x_2 | x_2 if x_2 == x_1 => x_2 + x_1}}}} #[test] fn issue_9384(){ run_renaming_test( - &("macro_rules! bad_macro (($ex:expr) => ({match 9 {x | x if x == $ex => x + $ex}})) + &("macro_rules! bad_macro (($ex:expr) => ({match 9 {x | x if x == $ex => x + $ex}})); fn z() {match 8 {x => bad_macro!(x)}}", // NB: the third "binding" is the repeat of the second one. vec!(vec!(1,3),vec!(0,2),vec!(0,2)), @@ -1511,8 +1512,8 @@ mod test { // fn main(){let g1_1 = 13; g1_1}} #[test] fn pat_expand_issue_15221(){ run_renaming_test( - &("macro_rules! inner ( ($e:pat ) => ($e)) - macro_rules! outer ( ($e:pat ) => (inner!($e))) + &("macro_rules! inner ( ($e:pat ) => ($e)); + macro_rules! outer ( ($e:pat ) => (inner!($e))); fn main() { let outer!(g) = 13; g;}", vec!(vec!(0)), true), @@ -1527,8 +1528,8 @@ mod test { // method expands to fn get_x(&self_0, x_1:int) {self_0 + self_2 + x_3 + x_1} #[test] fn method_arg_hygiene(){ run_renaming_test( - &("macro_rules! inject_x (()=>(x)) - macro_rules! inject_self (()=>(self)) + &("macro_rules! inject_x (()=>(x)); + macro_rules! inject_self (()=>(self)); struct A; impl A{fn get_x(&self, x: int) {self + inject_self!() + inject_x!() + x;} }", vec!(vec!(0),vec!(3)), @@ -1542,8 +1543,8 @@ mod test { run_renaming_test( &("struct A; macro_rules! add_method (($T:ty) => - (impl $T { fn thingy(&self) {self;} })) - add_method!(A)", + (impl $T { fn thingy(&self) {self;} })); + add_method!(A);", vec!(vec!(0)), true), 0) @@ -1553,7 +1554,7 @@ mod test { // expands to fn q(x_1:int){fn g(x_2:int){x_2 + x_1};} #[test] fn issue_9383(){ run_renaming_test( - &("macro_rules! bad_macro (($ex:expr) => (fn g(x:int){ x + $ex })) + &("macro_rules! bad_macro (($ex:expr) => (fn g(x:int){ x + $ex })); fn q(x:int) { bad_macro!(x); }", vec!(vec!(1),vec!(0)),true), 0) @@ -1563,7 +1564,7 @@ mod test { // expands to fn f(){(|x_1 : int| {(x_2 + x_1)})(3);} #[test] fn closure_arg_hygiene(){ run_renaming_test( - &("macro_rules! inject_x (()=>(x)) + &("macro_rules! inject_x (()=>(x)); fn f(){(|x : int| {(inject_x!() + x)})(3);}", vec!(vec!(1)), true), @@ -1573,9 +1574,9 @@ mod test { // macro_rules in method position. Sadly, unimplemented. #[test] fn macro_in_method_posn(){ expand_crate_str( - "macro_rules! my_method (() => (fn thirteen(&self) -> int {13})) + "macro_rules! my_method (() => (fn thirteen(&self) -> int {13})); struct A; - impl A{ my_method!()} + impl A{ my_method!(); } fn f(){A.thirteen;}".to_string()); } @@ -1586,7 +1587,7 @@ mod test { &("macro_rules! item { ($i:item) => {$i}} struct Entries; macro_rules! iterator_impl { - () => { item!( impl Entries { fn size_hint(&self) { self;}})}} + () => { item!( impl Entries { fn size_hint(&self) { self;}});}} iterator_impl! { }", vec!(vec!(0)), true), 0) @@ -1666,9 +1667,9 @@ mod test { } #[test] fn fmt_in_macro_used_inside_module_macro() { - let crate_str = "macro_rules! fmt_wrap(($b:expr)=>($b.to_string())) -macro_rules! foo_module (() => (mod generated { fn a() { let xx = 147; fmt_wrap!(xx);}})) -foo_module!() + let crate_str = "macro_rules! fmt_wrap(($b:expr)=>($b.to_string())); +macro_rules! foo_module (() => (mod generated { fn a() { let xx = 147; fmt_wrap!(xx);}})); +foo_module!(); ".to_string(); let cr = expand_crate_str(crate_str); // find the xx binding diff --git a/src/libsyntax/ext/mtwt.rs b/src/libsyntax/ext/mtwt.rs index a4e06aeaf63..33936e6213f 100644 --- a/src/libsyntax/ext/mtwt.rs +++ b/src/libsyntax/ext/mtwt.rs @@ -108,7 +108,7 @@ pub fn apply_renames(renames: &RenameList, ctxt: SyntaxContext) -> SyntaxContext pub fn with_sctable<T, F>(op: F) -> T where F: FnOnce(&SCTable) -> T, { - thread_local!(static SCTABLE_KEY: SCTable = new_sctable_internal()) + thread_local!(static SCTABLE_KEY: SCTable = new_sctable_internal()); SCTABLE_KEY.with(move |slot| op(slot)) } @@ -174,7 +174,7 @@ fn with_resolve_table_mut<T, F>(op: F) -> T where { thread_local!(static RESOLVE_TABLE_KEY: RefCell<ResolveTable> = { RefCell::new(HashMap::new()) - }) + }); RESOLVE_TABLE_KEY.with(move |slot| op(&mut *slot.borrow_mut())) } diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 45752499ad5..14e13feac98 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -100,7 +100,7 @@ pub mod rt { fn to_source_with_hygiene(&self) -> String; } - macro_rules! impl_to_source( + macro_rules! impl_to_source { (P<$t:ty>, $pp:ident) => ( impl ToSource for P<$t> { fn to_source(&self) -> String { @@ -125,7 +125,7 @@ pub mod rt { } } ); - ) + } fn slice_to_source<'a, T: ToSource>(sep: &'static str, xs: &'a [T]) -> String { xs.iter() @@ -144,7 +144,7 @@ pub mod rt { .to_string() } - macro_rules! impl_to_source_slice( + macro_rules! impl_to_source_slice { ($t:ty, $sep:expr) => ( impl ToSource for [$t] { fn to_source(&self) -> String { @@ -158,7 +158,7 @@ pub mod rt { } } ) - ) + } impl ToSource for ast::Ident { fn to_source(&self) -> String { @@ -172,18 +172,18 @@ pub mod rt { } } - impl_to_source!(ast::Ty, ty_to_string) - impl_to_source!(ast::Block, block_to_string) - impl_to_source!(ast::Arg, arg_to_string) - impl_to_source!(Generics, generics_to_string) - impl_to_source!(P<ast::Item>, item_to_string) - impl_to_source!(P<ast::Method>, method_to_string) - impl_to_source!(P<ast::Stmt>, stmt_to_string) - impl_to_source!(P<ast::Expr>, expr_to_string) - impl_to_source!(P<ast::Pat>, pat_to_string) - impl_to_source!(ast::Arm, arm_to_string) - impl_to_source_slice!(ast::Ty, ", ") - impl_to_source_slice!(P<ast::Item>, "\n\n") + impl_to_source! { ast::Ty, ty_to_string } + impl_to_source! { ast::Block, block_to_string } + impl_to_source! { ast::Arg, arg_to_string } + impl_to_source! { Generics, generics_to_string } + impl_to_source! { P<ast::Item>, item_to_string } + impl_to_source! { P<ast::Method>, method_to_string } + impl_to_source! { P<ast::Stmt>, stmt_to_string } + impl_to_source! { P<ast::Expr>, expr_to_string } + impl_to_source! { P<ast::Pat>, pat_to_string } + impl_to_source! { ast::Arm, arm_to_string } + impl_to_source_slice! { ast::Ty, ", " } + impl_to_source_slice! { P<ast::Item>, "\n\n" } impl ToSource for ast::Attribute_ { fn to_source(&self) -> String { @@ -244,7 +244,7 @@ pub mod rt { } } - macro_rules! impl_to_source_int( + macro_rules! impl_to_source_int { (signed, $t:ty, $tag:ident) => ( impl ToSource for $t { fn to_source(&self) -> String { @@ -272,23 +272,23 @@ pub mod rt { } } ); - ) + } - impl_to_source_int!(signed, int, TyI) - impl_to_source_int!(signed, i8, TyI8) - impl_to_source_int!(signed, i16, TyI16) - impl_to_source_int!(signed, i32, TyI32) - impl_to_source_int!(signed, i64, TyI64) + impl_to_source_int! { signed, int, TyI } + impl_to_source_int! { signed, i8, TyI8 } + impl_to_source_int! { signed, i16, TyI16 } + impl_to_source_int! { signed, i32, TyI32 } + impl_to_source_int! { signed, i64, TyI64 } - impl_to_source_int!(unsigned, uint, TyU) - impl_to_source_int!(unsigned, u8, TyU8) - impl_to_source_int!(unsigned, u16, TyU16) - impl_to_source_int!(unsigned, u32, TyU32) - impl_to_source_int!(unsigned, u64, TyU64) + impl_to_source_int! { unsigned, uint, TyU } + impl_to_source_int! { unsigned, u8, TyU8 } + impl_to_source_int! { unsigned, u16, TyU16 } + impl_to_source_int! { unsigned, u32, TyU32 } + impl_to_source_int! { unsigned, u64, TyU64 } // Alas ... we write these out instead. All redundant. - macro_rules! impl_to_tokens( + macro_rules! impl_to_tokens { ($t:ty) => ( impl ToTokens for $t { fn to_tokens(&self, cx: &ExtCtxt) -> Vec<TokenTree> { @@ -296,9 +296,9 @@ pub mod rt { } } ) - ) + } - macro_rules! impl_to_tokens_lifetime( + macro_rules! impl_to_tokens_lifetime { ($t:ty) => ( impl<'a> ToTokens for $t { fn to_tokens(&self, cx: &ExtCtxt) -> Vec<TokenTree> { @@ -306,36 +306,36 @@ pub mod rt { } } ) - ) - - impl_to_tokens!(ast::Ident) - impl_to_tokens!(P<ast::Item>) - impl_to_tokens!(P<ast::Pat>) - impl_to_tokens!(ast::Arm) - impl_to_tokens!(P<ast::Method>) - impl_to_tokens_lifetime!(&'a [P<ast::Item>]) - impl_to_tokens!(ast::Ty) - impl_to_tokens_lifetime!(&'a [ast::Ty]) - impl_to_tokens!(Generics) - impl_to_tokens!(P<ast::Stmt>) - impl_to_tokens!(P<ast::Expr>) - impl_to_tokens!(ast::Block) - impl_to_tokens!(ast::Arg) - impl_to_tokens!(ast::Attribute_) - impl_to_tokens_lifetime!(&'a str) - impl_to_tokens!(()) - impl_to_tokens!(char) - impl_to_tokens!(bool) - impl_to_tokens!(int) - impl_to_tokens!(i8) - impl_to_tokens!(i16) - impl_to_tokens!(i32) - impl_to_tokens!(i64) - impl_to_tokens!(uint) - impl_to_tokens!(u8) - impl_to_tokens!(u16) - impl_to_tokens!(u32) - impl_to_tokens!(u64) + } + + impl_to_tokens! { ast::Ident } + impl_to_tokens! { P<ast::Item> } + impl_to_tokens! { P<ast::Pat> } + impl_to_tokens! { ast::Arm } + impl_to_tokens! { P<ast::Method> } + impl_to_tokens_lifetime! { &'a [P<ast::Item>] } + impl_to_tokens! { ast::Ty } + impl_to_tokens_lifetime! { &'a [ast::Ty] } + impl_to_tokens! { Generics } + impl_to_tokens! { P<ast::Stmt> } + impl_to_tokens! { P<ast::Expr> } + impl_to_tokens! { ast::Block } + impl_to_tokens! { ast::Arg } + impl_to_tokens! { ast::Attribute_ } + impl_to_tokens_lifetime! { &'a str } + impl_to_tokens! { () } + impl_to_tokens! { char } + impl_to_tokens! { bool } + impl_to_tokens! { int } + impl_to_tokens! { i8 } + impl_to_tokens! { i16 } + impl_to_tokens! { i32 } + impl_to_tokens! { i64 } + impl_to_tokens! { uint } + impl_to_tokens! { u8 } + impl_to_tokens! { u16 } + impl_to_tokens! { u32 } + impl_to_tokens! { u64 } pub trait ExtParseUtils { fn parse_item(&self, s: String) -> P<ast::Item>; diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 7d2acd08d94..10860ee5e01 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -1485,7 +1485,7 @@ mod test { } // maybe add to expand.rs... - macro_rules! assert_pred ( + macro_rules! assert_pred { ($pred:expr, $predname:expr, $a:expr , $b:expr) => ( { let pred_val = $pred; @@ -1497,7 +1497,7 @@ mod test { } } ) - ) + } // make sure idents get transformed everywhere #[test] fn ident_transformation () { @@ -1523,6 +1523,6 @@ mod test { matches_codepattern, "matches_codepattern", pprust::to_string(|s| fake_print_crate(s, &folded_crate)), - "zz!zz((zz$zz:zz$(zz $zz:zz)zz+=>(zz$(zz$zz$zz)+)))".to_string()); + "zz!zz((zz$zz:zz$(zz $zz:zz)zz+=>(zz$(zz$zz$zz)+)));".to_string()); } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 6e3cfe5854a..c234c172fd8 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -40,9 +40,10 @@ use ast::{ItemMac, ItemMod, ItemStruct, ItemTrait, ItemTy}; use ast::{LifetimeDef, Lit, Lit_}; use ast::{LitBool, LitChar, LitByte, LitBinary}; use ast::{LitStr, LitInt, Local, LocalLet}; +use ast::{MacStmtWithBraces, MacStmtWithSemicolon, MacStmtWithoutBraces}; use ast::{MutImmutable, MutMutable, Mac_, MacInvocTT, MatchNormal}; use ast::{Method, MutTy, BiMul, Mutability}; -use ast::{MethodImplItem, NamedField, UnNeg, NoReturn, UnNot}; +use ast::{MethodImplItem, NamedField, UnNeg, NoReturn, NodeId, UnNot}; use ast::{Pat, PatEnum, PatIdent, PatLit, PatRange, PatRegion, PatStruct}; use ast::{PatTup, PatBox, PatWild, PatWildMulti, PatWildSingle}; use ast::{PolyTraitRef}; @@ -132,7 +133,7 @@ enum ItemOrViewItem { /// macro expansion). Placement of these is not as complex as I feared it would /// be. The important thing is to make sure that lookahead doesn't balk at /// `token::Interpolated` tokens. -macro_rules! maybe_whole_expr ( +macro_rules! maybe_whole_expr { ($p:expr) => ( { let found = match $p.token { @@ -170,10 +171,10 @@ macro_rules! maybe_whole_expr ( } } ) -) +} /// As maybe_whole_expr, but for things other than expressions -macro_rules! maybe_whole ( +macro_rules! maybe_whole { ($p:expr, $constructor:ident) => ( { let found = match ($p).token { @@ -252,7 +253,7 @@ macro_rules! maybe_whole ( } } ) -) +} fn maybe_append(mut lhs: Vec<Attribute>, rhs: Option<Vec<Attribute>>) @@ -3708,21 +3709,32 @@ impl<'a> Parser<'a> { ); let hi = self.span.hi; + let style = if delim == token::Brace { + MacStmtWithBraces + } else { + MacStmtWithoutBraces + }; + if id.name == token::special_idents::invalid.name { - if self.check(&token::Dot) { - let span = self.span; - let token_string = self.this_token_to_string(); - self.span_err(span, - format!("expected statement, found `{}`", - token_string).as_slice()); - let mac_span = mk_sp(lo, hi); - self.span_help(mac_span, "try parenthesizing this macro invocation"); - self.abort_if_errors(); - } - P(spanned(lo, hi, StmtMac( - spanned(lo, hi, MacInvocTT(pth, tts, EMPTY_CTXT)), false))) + P(spanned(lo, + hi, + StmtMac(spanned(lo, + hi, + MacInvocTT(pth, tts, EMPTY_CTXT)), + style))) } else { // if it has a special ident, it's definitely an item + // + // Require a semicolon or braces. + if style != MacStmtWithBraces { + if !self.eat(&token::Semi) { + let last_span = self.last_span; + self.span_err(last_span, + "macros that expand to items must \ + either be surrounded with braces or \ + followed by a semicolon"); + } + } P(spanned(lo, hi, StmtDecl( P(spanned(lo, hi, DeclItem( self.mk_item( @@ -3731,7 +3743,6 @@ impl<'a> Parser<'a> { Inherited, Vec::new(/*no attrs*/))))), ast::DUMMY_NODE_ID))) } - } else { let found_attrs = !item_attrs.is_empty(); let item_err = Parser::expected_item_err(item_attrs.as_slice()); @@ -3851,43 +3862,46 @@ impl<'a> Parser<'a> { attributes_box = Vec::new(); stmt.and_then(|Spanned {node, span}| match node { StmtExpr(e, stmt_id) => { - // expression without semicolon - if classify::expr_requires_semi_to_be_stmt(&*e) { - // Just check for errors and recover; do not eat semicolon yet. - self.commit_stmt(&[], &[token::Semi, - token::CloseDelim(token::Brace)]); - } - + self.handle_expression_like_statement(e, + stmt_id, + span, + &mut stmts, + &mut expr); + } + StmtMac(macro, MacStmtWithoutBraces) => { + // statement macro without braces; might be an + // expr depending on whether a semicolon follows match self.token { token::Semi => { - self.bump(); - let span_with_semi = Span { - lo: span.lo, - hi: self.last_span.hi, - expn_id: span.expn_id, - }; stmts.push(P(Spanned { - node: StmtSemi(e, stmt_id), - span: span_with_semi, + node: StmtMac(macro, + MacStmtWithSemicolon), + span: span, })); - } - token::CloseDelim(token::Brace) => { - expr = Some(e); + self.bump(); } _ => { - stmts.push(P(Spanned { - node: StmtExpr(e, stmt_id), - span: span - })); + let e = self.mk_mac_expr(span.lo, + span.hi, + macro.node); + let e = + self.parse_dot_or_call_expr_with(e); + self.handle_expression_like_statement( + e, + ast::DUMMY_NODE_ID, + span, + &mut stmts, + &mut expr); } } } - StmtMac(m, semi) => { + StmtMac(m, style) => { // statement macro; might be an expr match self.token { token::Semi => { stmts.push(P(Spanned { - node: StmtMac(m, true), + node: StmtMac(m, + MacStmtWithSemicolon), span: span, })); self.bump(); @@ -3902,7 +3916,7 @@ impl<'a> Parser<'a> { } _ => { stmts.push(P(Spanned { - node: StmtMac(m, semi), + node: StmtMac(m, style), span: span })); } @@ -3941,6 +3955,43 @@ impl<'a> Parser<'a> { }) } + fn handle_expression_like_statement( + &mut self, + e: P<Expr>, + stmt_id: NodeId, + span: Span, + stmts: &mut Vec<P<Stmt>>, + last_block_expr: &mut Option<P<Expr>>) { + // expression without semicolon + if classify::expr_requires_semi_to_be_stmt(&*e) { + // Just check for errors and recover; do not eat semicolon yet. + self.commit_stmt(&[], + &[token::Semi, token::CloseDelim(token::Brace)]); + } + + match self.token { + token::Semi => { + self.bump(); + let span_with_semi = Span { + lo: span.lo, + hi: self.last_span.hi, + expn_id: span.expn_id, + }; + stmts.push(P(Spanned { + node: StmtSemi(e, stmt_id), + span: span_with_semi, + })); + } + token::CloseDelim(token::Brace) => *last_block_expr = Some(e), + _ => { + stmts.push(P(Spanned { + node: StmtExpr(e, stmt_id), + span: span + })); + } + } + } + // Parses a sequence of bounds if a `:` is found, // otherwise returns empty list. fn parse_colon_then_ty_param_bounds(&mut self) @@ -4591,6 +4642,9 @@ impl<'a> Parser<'a> { let m: ast::Mac = codemap::Spanned { node: m_, span: mk_sp(self.span.lo, self.span.hi) }; + if delim != token::Brace { + self.expect(&token::Semi) + } (ast::MethMac(m), self.span.hi, attrs) } else { let unsafety = self.parse_unsafety(); @@ -5747,6 +5801,17 @@ impl<'a> Parser<'a> { let m: ast::Mac = codemap::Spanned { node: m, span: mk_sp(self.span.lo, self.span.hi) }; + + if delim != token::Brace { + if !self.eat(&token::Semi) { + let last_span = self.last_span; + self.span_err(last_span, + "macros that expand to items must either \ + be surrounded with braces or followed by \ + a semicolon"); + } + } + let item_ = ItemMac(m); let last_span = self.last_span; let item = self.mk_item(lo, diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 1bdcd73d847..641239f1f8b 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -570,7 +570,7 @@ pub type IdentInterner = StrInterner; pub fn get_ident_interner() -> Rc<IdentInterner> { thread_local!(static KEY: Rc<::parse::token::IdentInterner> = { Rc::new(mk_fresh_ident_interner()) - }) + }); KEY.with(|k| k.clone()) } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index cbbfcfef72e..1dd61a5ce19 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -409,12 +409,12 @@ pub fn arg_to_string(arg: &ast::Arg) -> String { } pub fn mac_to_string(arg: &ast::Mac) -> String { - $to_string(|s| s.print_mac(arg)) + $to_string(|s| s.print_mac(arg, ::parse::token::Paren)) } } } -thing_to_string_impls!(to_string) +thing_to_string_impls! { to_string } // FIXME (Issue #16472): the whole `with_hygiene` mod should go away // after we revise the syntax::ext::quote::ToToken impls to go directly @@ -437,7 +437,7 @@ pub mod with_hygiene { }) } - thing_to_string_impls!(to_string_hyg) + thing_to_string_impls! { to_string_hyg } } pub fn visibility_qualified(vis: ast::Visibility, s: &str) -> String { @@ -992,6 +992,7 @@ impl<'a> State<'a> { try!(self.popen()); try!(self.print_tts(tts.as_slice())); try!(self.pclose()); + try!(word(&mut self.s, ";")); try!(self.end()); } } @@ -1258,6 +1259,7 @@ impl<'a> State<'a> { try!(self.popen()); try!(self.print_tts(tts.as_slice())); try!(self.pclose()); + try!(word(&mut self.s, ";")); self.end() } } @@ -1330,11 +1332,16 @@ impl<'a> State<'a> { try!(self.print_expr(&**expr)); try!(word(&mut self.s, ";")); } - ast::StmtMac(ref mac, semi) => { + ast::StmtMac(ref mac, style) => { try!(self.space_if_not_bol()); - try!(self.print_mac(mac)); - if semi { - try!(word(&mut self.s, ";")); + let delim = match style { + ast::MacStmtWithBraces => token::Brace, + _ => token::Paren + }; + try!(self.print_mac(mac, delim)); + match style { + ast::MacStmtWithBraces => {} + _ => try!(word(&mut self.s, ";")), } } } @@ -1461,15 +1468,24 @@ impl<'a> State<'a> { self.print_else(elseopt) } - pub fn print_mac(&mut self, m: &ast::Mac) -> IoResult<()> { + pub fn print_mac(&mut self, m: &ast::Mac, delim: token::DelimToken) + -> IoResult<()> { match m.node { // I think it's reasonable to hide the ctxt here: ast::MacInvocTT(ref pth, ref tts, _) => { try!(self.print_path(pth, false)); try!(word(&mut self.s, "!")); - try!(self.popen()); + match delim { + token::Paren => try!(self.popen()), + token::Bracket => try!(word(&mut self.s, "[")), + token::Brace => try!(self.bopen()), + } try!(self.print_tts(tts.as_slice())); - self.pclose() + match delim { + token::Paren => self.pclose(), + token::Bracket => word(&mut self.s, "]"), + token::Brace => self.bclose(m.span), + } } } } @@ -1817,7 +1833,7 @@ impl<'a> State<'a> { })); try!(self.pclose()); } - ast::ExprMac(ref m) => try!(self.print_mac(m)), + ast::ExprMac(ref m) => try!(self.print_mac(m, token::Paren)), ast::ExprParen(ref e) => { try!(self.popen()); try!(self.print_expr(&**e)); @@ -2098,7 +2114,7 @@ impl<'a> State<'a> { |s, p| s.print_pat(&**p))); try!(word(&mut self.s, "]")); } - ast::PatMac(ref m) => try!(self.print_mac(m)), + ast::PatMac(ref m) => try!(self.print_mac(m, token::Paren)), } self.ann.post(self, NodePat(pat)) } @@ -2187,7 +2203,7 @@ impl<'a> State<'a> { try!(self.nbsp()); try!(self.print_ident(name)); try!(self.print_generics(generics)); - try!(self.print_fn_args_and_ret(decl, opt_explicit_self)) + try!(self.print_fn_args_and_ret(decl, opt_explicit_self)); self.print_where_clause(generics) } diff --git a/src/libterm/terminfo/parser/compiled.rs b/src/libterm/terminfo/parser/compiled.rs index 9b5e6f5cc9f..fe96d7b8b7d 100644 --- a/src/libterm/terminfo/parser/compiled.rs +++ b/src/libterm/terminfo/parser/compiled.rs @@ -165,7 +165,7 @@ pub fn parse(file: &mut io::Reader, longnames: bool) Ok(e) => e, Err(e) => return Err(format!("{}", e)) } - ) ) + ) ); let bnames; let snames; diff --git a/src/libtest/stats.rs b/src/libtest/stats.rs index f9e6907f0e8..7441b39f35b 100644 --- a/src/libtest/stats.rs +++ b/src/libtest/stats.rs @@ -459,14 +459,14 @@ mod tests { use std::io; use std::f64; - macro_rules! assert_approx_eq( + macro_rules! assert_approx_eq { ($a:expr, $b:expr) => ({ use std::num::Float; let (a, b) = (&$a, &$b); assert!((*a - *b).abs() < 1.0e-6, "{} is not approximately equal to {}", *a, *b); }) - ) + } fn check(samples: &[f64], summ: &Summary<f64>) { diff --git a/src/test/auxiliary/lint_group_plugin_test.rs b/src/test/auxiliary/lint_group_plugin_test.rs index 4790ae11b21..add54ed01e0 100644 --- a/src/test/auxiliary/lint_group_plugin_test.rs +++ b/src/test/auxiliary/lint_group_plugin_test.rs @@ -23,11 +23,9 @@ use syntax::parse::token; use rustc::lint::{Context, LintPass, LintPassObject, LintArray}; use rustc::plugin::Registry; -declare_lint!(TEST_LINT, Warn, - "Warn about items named 'lintme'") +declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'"); -declare_lint!(PLEASE_LINT, Warn, - "Warn about items named 'pleaselintme'") +declare_lint!(PLEASE_LINT, Warn, "Warn about items named 'pleaselintme'"); struct Pass; diff --git a/src/test/auxiliary/lint_plugin_test.rs b/src/test/auxiliary/lint_plugin_test.rs index e18cef6d136..6c78cdce28a 100644 --- a/src/test/auxiliary/lint_plugin_test.rs +++ b/src/test/auxiliary/lint_plugin_test.rs @@ -23,8 +23,7 @@ use syntax::parse::token; use rustc::lint::{Context, LintPass, LintPassObject, LintArray}; use rustc::plugin::Registry; -declare_lint!(TEST_LINT, Warn, - "Warn about items named 'lintme'") +declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'"); struct Pass; diff --git a/src/test/auxiliary/lint_stability.rs b/src/test/auxiliary/lint_stability.rs index 0be2f31e282..82af18b189b 100644 --- a/src/test/auxiliary/lint_stability.rs +++ b/src/test/auxiliary/lint_stability.rs @@ -183,14 +183,14 @@ pub struct LockedTupleStruct(pub int); #[macro_export] macro_rules! macro_test( () => (deprecated()); -) +); #[macro_export] macro_rules! macro_test_arg( ($func:expr) => ($func); -) +); #[macro_export] macro_rules! macro_test_arg_nested( ($func:ident) => (macro_test_arg!($func())); -) +); diff --git a/src/test/auxiliary/macro_crate_def_only.rs b/src/test/auxiliary/macro_crate_def_only.rs index 56053a0cd75..ad3e72f5fa2 100644 --- a/src/test/auxiliary/macro_crate_def_only.rs +++ b/src/test/auxiliary/macro_crate_def_only.rs @@ -13,4 +13,4 @@ #[macro_export] macro_rules! make_a_5( () => (5) -) +); diff --git a/src/test/auxiliary/macro_crate_test.rs b/src/test/auxiliary/macro_crate_test.rs index 1c26ac26d7c..b82cfcbc8fc 100644 --- a/src/test/auxiliary/macro_crate_test.rs +++ b/src/test/auxiliary/macro_crate_test.rs @@ -24,9 +24,9 @@ use syntax::ptr::P; use rustc::plugin::Registry; #[macro_export] -macro_rules! exported_macro (() => (2i)) +macro_rules! exported_macro (() => (2i)); -macro_rules! unexported_macro (() => (3i)) +macro_rules! unexported_macro (() => (3i)); #[plugin_registrar] pub fn plugin_registrar(reg: &mut Registry) { diff --git a/src/test/auxiliary/macro_export_inner_module.rs b/src/test/auxiliary/macro_export_inner_module.rs index 1e8c15f6b44..9b4b1ceb5c1 100644 --- a/src/test/auxiliary/macro_export_inner_module.rs +++ b/src/test/auxiliary/macro_export_inner_module.rs @@ -14,5 +14,5 @@ pub mod inner { #[macro_export] macro_rules! foo( () => (1) - ) + ); } diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs index 6e2cd508291..16129593485 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -31,7 +31,7 @@ fn main() { ($id:ident) => (maybe_run_test(argv.as_slice(), stringify!($id).to_string(), - $id))) + $id))); bench!(shift_push); bench!(read_line); diff --git a/src/test/compile-fail/const-block-non-item-statement.rs b/src/test/compile-fail/const-block-non-item-statement.rs index d8f771cfb5a..0a004c101ee 100644 --- a/src/test/compile-fail/const-block-non-item-statement.rs +++ b/src/test/compile-fail/const-block-non-item-statement.rs @@ -19,7 +19,7 @@ static B: uint = { { } 2 }; macro_rules! foo { () => (()) //~ ERROR: blocks in constants are limited to items and tail expressions } -static C: uint = { foo!() 2 }; +static C: uint = { foo!(); 2 }; static D: uint = { let x = 4u; 2 }; //~^ ERROR: blocks in constants are limited to items and tail expressions diff --git a/src/test/compile-fail/gated-macro-rules.rs b/src/test/compile-fail/gated-macro-rules.rs index 7f771c72416..ae2f03fd5f7 100644 --- a/src/test/compile-fail/gated-macro-rules.rs +++ b/src/test/compile-fail/gated-macro-rules.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -macro_rules! foo(() => ()) +macro_rules! foo(() => ()); //~^ ERROR: macro definitions are not stable enough for use fn main() {} diff --git a/src/test/compile-fail/infinite-macro-expansion.rs b/src/test/compile-fail/infinite-macro-expansion.rs index 67a7cdf1024..22ac2eb1f7d 100644 --- a/src/test/compile-fail/infinite-macro-expansion.rs +++ b/src/test/compile-fail/infinite-macro-expansion.rs @@ -14,7 +14,7 @@ macro_rules! recursive( () => ( recursive!() //~ ERROR recursion limit reached while expanding the macro `recursive` ) - ) + ); fn main() { recursive!() diff --git a/src/test/compile-fail/issue-19734.rs b/src/test/compile-fail/issue-19734.rs index cee92cae2aa..ab88b580ba1 100644 --- a/src/test/compile-fail/issue-19734.rs +++ b/src/test/compile-fail/issue-19734.rs @@ -11,5 +11,5 @@ fn main() {} impl Type { - undef!() //~ ERROR macro undefined: 'undef!' + undef!(); //~ ERROR macro undefined: 'undef!' } diff --git a/src/test/compile-fail/issue-6596.rs b/src/test/compile-fail/issue-6596.rs index 267b30677a1..3222b2cd537 100644 --- a/src/test/compile-fail/issue-6596.rs +++ b/src/test/compile-fail/issue-6596.rs @@ -16,7 +16,7 @@ macro_rules! e( ($inp:ident) => ( $nonexistent ); -) +); fn main() { e!(foo); diff --git a/src/test/compile-fail/liveness-return-last-stmt-semi.rs b/src/test/compile-fail/liveness-return-last-stmt-semi.rs index f2ea2ca96a5..e92faa6bdaf 100644 --- a/src/test/compile-fail/liveness-return-last-stmt-semi.rs +++ b/src/test/compile-fail/liveness-return-last-stmt-semi.rs @@ -12,7 +12,7 @@ #![feature(macro_rules)] -macro_rules! test ( () => { fn foo() -> int { 1i; } } ) +macro_rules! test ( () => { fn foo() -> int { 1i; } } ); //~^ ERROR not all control paths return a value //~^^ HELP consider removing this semicolon diff --git a/src/test/compile-fail/macro-incomplete-parse.rs b/src/test/compile-fail/macro-incomplete-parse.rs index 94386858d29..71b656d0bbb 100644 --- a/src/test/compile-fail/macro-incomplete-parse.rs +++ b/src/test/compile-fail/macro-incomplete-parse.rs @@ -26,10 +26,10 @@ macro_rules! ignored_pat { () => ( 1, 2 ) //~ ERROR macro expansion ignores token `,` } -ignored_item!() +ignored_item!(); fn main() { - ignored_expr!() + ignored_expr!(); match 1 { ignored_pat!() => (), _ => (), diff --git a/src/test/compile-fail/macro-inner-attributes.rs b/src/test/compile-fail/macro-inner-attributes.rs index 4c4fb5572d6..f64b7be50e3 100644 --- a/src/test/compile-fail/macro-inner-attributes.rs +++ b/src/test/compile-fail/macro-inner-attributes.rs @@ -12,15 +12,15 @@ macro_rules! test ( ($nm:ident, #[$a:meta], - $i:item) => (mod $nm { #![$a] $i }); ) + $i:item) => (mod $nm { #![$a] $i }); ); test!(a, #[cfg(qux)], - pub fn bar() { }) + pub fn bar() { }); test!(b, #[cfg(not(qux))], - pub fn bar() { }) + pub fn bar() { }); #[qux] fn main() { diff --git a/src/test/compile-fail/macro-local-data-key-priv.rs b/src/test/compile-fail/macro-local-data-key-priv.rs index 3f2ecd86abe..3818c8f7754 100644 --- a/src/test/compile-fail/macro-local-data-key-priv.rs +++ b/src/test/compile-fail/macro-local-data-key-priv.rs @@ -11,7 +11,7 @@ // check that the local data keys are private by default. mod bar { - thread_local!(static baz: f64 = 0.0) + thread_local!(static baz: f64 = 0.0); } fn main() { diff --git a/src/test/compile-fail/macro-match-nonterminal.rs b/src/test/compile-fail/macro-match-nonterminal.rs index d6d32d94a29..150187aa07d 100644 --- a/src/test/compile-fail/macro-match-nonterminal.rs +++ b/src/test/compile-fail/macro-match-nonterminal.rs @@ -10,7 +10,7 @@ #![feature(macro_rules)] -macro_rules! test ( ($a, $b) => (()); ) //~ ERROR Cannot transcribe +macro_rules! test ( ($a, $b) => (()); ); //~ ERROR Cannot transcribe fn main() { test!() diff --git a/src/test/compile-fail/macro-outer-attributes.rs b/src/test/compile-fail/macro-outer-attributes.rs index e41f1bd369a..6d59c203d14 100644 --- a/src/test/compile-fail/macro-outer-attributes.rs +++ b/src/test/compile-fail/macro-outer-attributes.rs @@ -12,15 +12,15 @@ macro_rules! test ( ($nm:ident, #[$a:meta], - $i:item) => (mod $nm { #[$a] $i }); ) + $i:item) => (mod $nm { #[$a] $i }); ); test!(a, #[cfg(qux)], - pub fn bar() { }) + pub fn bar() { }); test!(b, #[cfg(not(qux))], - pub fn bar() { }) + pub fn bar() { }); // test1!(#[bar]) #[qux] diff --git a/src/test/compile-fail/macro-invocation-dot-help.rs b/src/test/compile-fail/macros-no-semicolon-items.rs index bd45b76dd5a..f1f31a99e97 100644 --- a/src/test/compile-fail/macro-invocation-dot-help.rs +++ b/src/test/compile-fail/macros-no-semicolon-items.rs @@ -8,7 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +macro_rules! foo() //~ ERROR semicolon + fn main() { - foo!() //~ HELP try parenthesizing this macro invocation - .bar //~ ERROR expected statement } + diff --git a/src/test/compile-fail/macros-no-semicolon.rs b/src/test/compile-fail/macros-no-semicolon.rs new file mode 100644 index 00000000000..fd5f5866f09 --- /dev/null +++ b/src/test/compile-fail/macros-no-semicolon.rs @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + assert!(1 == 2) + assert!(3 == 4) //~ ERROR expected one of `.`, `;`, or `}`, found `assert` + println!("hello"); +} + diff --git a/src/test/compile-fail/method-macro-backtrace.rs b/src/test/compile-fail/method-macro-backtrace.rs index dc41e2e02a8..747b4815ac2 100644 --- a/src/test/compile-fail/method-macro-backtrace.rs +++ b/src/test/compile-fail/method-macro-backtrace.rs @@ -14,20 +14,20 @@ macro_rules! make_method ( ($name:ident) => ( fn $name(&self) { } -)) +)); struct S; impl S { // We had a bug where these wouldn't clean up macro backtrace frames. - make_method!(foo1) - make_method!(foo2) - make_method!(foo3) - make_method!(foo4) - make_method!(foo5) - make_method!(foo6) - make_method!(foo7) - make_method!(foo8) + make_method!(foo1); + make_method!(foo2); + make_method!(foo3); + make_method!(foo4); + make_method!(foo5); + make_method!(foo6); + make_method!(foo7); + make_method!(foo8); // Cause an error. It shouldn't have any macro backtrace frames. fn bar(&self) { } diff --git a/src/test/compile-fail/pattern-macro-hygeine.rs b/src/test/compile-fail/pattern-macro-hygiene.rs index 0b6a14c0fc9..3322fecf950 100644 --- a/src/test/compile-fail/pattern-macro-hygeine.rs +++ b/src/test/compile-fail/pattern-macro-hygiene.rs @@ -10,7 +10,7 @@ #![feature(macro_rules)] -macro_rules! foo ( () => ( x ) ) +macro_rules! foo ( () => ( x ) ); fn main() { let foo!() = 2; diff --git a/src/test/compile-fail/recursion_limit.rs b/src/test/compile-fail/recursion_limit.rs index 1da7f47677a..de0d5c90fdd 100644 --- a/src/test/compile-fail/recursion_limit.rs +++ b/src/test/compile-fail/recursion_limit.rs @@ -22,19 +22,19 @@ macro_rules! link { } } -link!(A,B) -link!(B,C) -link!(C,D) -link!(D,E) -link!(E,F) -link!(F,G) -link!(G,H) -link!(H,I) -link!(I,J) -link!(J,K) -link!(K,L) -link!(L,M) -link!(M,N) +link! { A, B } +link! { B, C } +link! { C, D } +link! { D, E } +link! { E, F } +link! { F, G } +link! { G, H } +link! { H, I } +link! { I, J } +link! { J, K } +link! { K, L } +link! { L, M } +link! { M, N } enum N { N(uint) } diff --git a/src/test/debuginfo/lexical-scope-with-macro.rs b/src/test/debuginfo/lexical-scope-with-macro.rs index 5a59ed5b2f3..2c76f2ca7df 100644 --- a/src/test/debuginfo/lexical-scope-with-macro.rs +++ b/src/test/debuginfo/lexical-scope-with-macro.rs @@ -113,23 +113,23 @@ #![feature(macro_rules)] -macro_rules! trivial( +macro_rules! trivial { ($e1:expr) => ($e1) -) +} -macro_rules! no_new_scope( +macro_rules! no_new_scope { ($e1:expr) => (($e1 + 2) - 1) -) +} -macro_rules! new_scope( +macro_rules! new_scope { () => ({ let a = 890242i; zzz(); // #break sentinel(); }) -) +} -macro_rules! shadow_within_macro( +macro_rules! shadow_within_macro { ($e1:expr) => ({ let a = $e1 + 2; @@ -141,12 +141,12 @@ macro_rules! shadow_within_macro( zzz(); // #break sentinel(); }) -) +} -macro_rules! dup_expr( +macro_rules! dup_expr { ($e1:expr) => (($e1) + ($e1)) -) +} fn main() { diff --git a/src/test/run-pass-fulldeps/issue_16723_multiple_items_syntax_ext.rs b/src/test/run-pass-fulldeps/issue_16723_multiple_items_syntax_ext.rs index c5cfabd74e1..08c9f8b4aa7 100644 --- a/src/test/run-pass-fulldeps/issue_16723_multiple_items_syntax_ext.rs +++ b/src/test/run-pass-fulldeps/issue_16723_multiple_items_syntax_ext.rs @@ -15,7 +15,7 @@ #[phase(plugin)] extern crate issue_16723_multiple_items_syntax_ext; -multiple_items!() +multiple_items!(); impl Struct1 { fn foo() {} diff --git a/src/test/run-pass/cleanup-rvalue-scopes.rs b/src/test/run-pass/cleanup-rvalue-scopes.rs index 35c69705925..42f6914e081 100644 --- a/src/test/run-pass/cleanup-rvalue-scopes.rs +++ b/src/test/run-pass/cleanup-rvalue-scopes.rs @@ -74,7 +74,7 @@ macro_rules! end_of_block( check_flags(1); } ) -) +); macro_rules! end_of_stmt( ($pat:pat, $expr:expr) => ( @@ -91,7 +91,7 @@ macro_rules! end_of_stmt( check_flags(0); } ) -) +); pub fn main() { diff --git a/src/test/run-pass/const-binops.rs b/src/test/run-pass/const-binops.rs index f4dba3f6c7f..cac805189b8 100644 --- a/src/test/run-pass/const-binops.rs +++ b/src/test/run-pass/const-binops.rs @@ -17,7 +17,7 @@ macro_rules! assert_approx_eq( assert!((*a - *b).abs() < 1.0e-6, "{} is not approximately equal to {}", *a, *b); }) -) +); static A: int = -4 + 3; static A2: uint = 3 + 3; diff --git a/src/test/run-pass/core-run-destroy.rs b/src/test/run-pass/core-run-destroy.rs index 4e625ce1d1f..a0fa2d178b9 100644 --- a/src/test/run-pass/core-run-destroy.rs +++ b/src/test/run-pass/core-run-destroy.rs @@ -26,7 +26,7 @@ use std::str; macro_rules! succeed( ($e:expr) => ( match $e { Ok(..) => {}, Err(e) => panic!("panic: {}", e) } -) ) +) ); fn test_destroy_once() { let mut p = sleeper(); diff --git a/src/test/run-pass/deriving-in-macro.rs b/src/test/run-pass/deriving-in-macro.rs index 218216e3a34..52b5c040d86 100644 --- a/src/test/run-pass/deriving-in-macro.rs +++ b/src/test/run-pass/deriving-in-macro.rs @@ -17,8 +17,8 @@ macro_rules! define_vec ( pub struct bar; } ) -) +); -define_vec!() +define_vec!(); pub fn main() {} diff --git a/src/test/run-pass/exponential-notation.rs b/src/test/run-pass/exponential-notation.rs index 318305b7ec3..f63ab7fb7c9 100644 --- a/src/test/run-pass/exponential-notation.rs +++ b/src/test/run-pass/exponential-notation.rs @@ -13,22 +13,22 @@ use std::num::strconv as s; use std::num::strconv::float_to_str_common as to_string; -macro_rules! t(($a:expr, $b:expr) => { { let (r, _) = $a; assert_eq!(r, $b.to_string()) } }) +macro_rules! t(($a:expr, $b:expr) => { { let (r, _) = $a; assert_eq!(r, $b.to_string()); } }); pub fn main() { // Basic usage t!(to_string(1.2345678e-5f64, 10u, true, s::SignNeg, s::DigMax(6), s::ExpDec, false), - "1.234568e-5") + "1.234568e-5"); // Hexadecimal output t!(to_string(7.281738281250e+01f64, 16u, true, s::SignAll, s::DigMax(6), s::ExpBin, false), - "+1.2345p+6") + "+1.2345p+6"); t!(to_string(-1.777768135071e-02f64, 16u, true, s::SignAll, s::DigMax(6), s::ExpBin, false), - "-1.2345p-6") + "-1.2345p-6"); // Some denormals t!(to_string(4.9406564584124654e-324f64, 10u, true, s::SignNeg, s::DigMax(6), s::ExpBin, false), - "1p-1074") + "1p-1074"); t!(to_string(2.2250738585072009e-308f64, 10u, true, s::SignNeg, s::DigMax(6), s::ExpBin, false), - "1p-1022") + "1p-1022"); } diff --git a/src/test/run-pass/html-literals.rs b/src/test/run-pass/html-literals.rs index 18e35e72c02..0d56f28e8fa 100644 --- a/src/test/run-pass/html-literals.rs +++ b/src/test/run-pass/html-literals.rs @@ -31,7 +31,7 @@ macro_rules! html ( ( $($body:tt)* ) => ( parse_node!( []; []; $($body)* ) ) -) +); macro_rules! parse_node ( ( @@ -85,7 +85,7 @@ macro_rules! parse_node ( ); ( []; [:$e:expr]; ) => ( $e ); -) +); pub fn main() { let _page = html! ( diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index b78371c51e4..9eac9c30dc8 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -38,7 +38,7 @@ impl fmt::Show for C { } } -macro_rules! t(($a:expr, $b:expr) => { assert_eq!($a.as_slice(), $b) }) +macro_rules! t(($a:expr, $b:expr) => { assert_eq!($a.as_slice(), $b) }); pub fn main() { // Various edge cases without formats diff --git a/src/test/run-pass/intrinsics-math.rs b/src/test/run-pass/intrinsics-math.rs index c3ba7ca12d0..9f2fe155cdf 100644 --- a/src/test/run-pass/intrinsics-math.rs +++ b/src/test/run-pass/intrinsics-math.rs @@ -18,7 +18,7 @@ macro_rules! assert_approx_eq( assert!((*a - *b).abs() < 1.0e-6, "{} is not approximately equal to {}", *a, *b); }) -) +); mod rusti { extern "rust-intrinsic" { diff --git a/src/test/run-pass/issue-15189.rs b/src/test/run-pass/issue-15189.rs index 16212b5f529..01c96b7563a 100644 --- a/src/test/run-pass/issue-15189.rs +++ b/src/test/run-pass/issue-15189.rs @@ -12,7 +12,7 @@ #![feature(macro_rules)] -macro_rules! third(($e:expr)=>({let x = 2; $e[x]})) +macro_rules! third(($e:expr)=>({let x = 2; $e[x]})); fn main() { let x = vec!(10u,11u,12u,13u); diff --git a/src/test/run-pass/issue-15221.rs b/src/test/run-pass/issue-15221.rs index 378fd4a222e..a11b34e4762 100644 --- a/src/test/run-pass/issue-15221.rs +++ b/src/test/run-pass/issue-15221.rs @@ -11,10 +11,10 @@ #![feature(macro_rules)] macro_rules! inner ( - ($e:pat ) => ($e)) + ($e:pat ) => ($e)); macro_rules! outer ( - ($e:pat ) => (inner!($e))) + ($e:pat ) => (inner!($e))); fn main() { let outer!(g1) = 13i; diff --git a/src/test/run-pass/issue-5060.rs b/src/test/run-pass/issue-5060.rs index adf1d1e614a..0cd25bc2c71 100644 --- a/src/test/run-pass/issue-5060.rs +++ b/src/test/run-pass/issue-5060.rs @@ -21,7 +21,7 @@ macro_rules! print_hd_tl ( // FIXME: #9970 print!("{}", "]\n"); }) -) +); pub fn main() { print_hd_tl!(x, y, z, w) diff --git a/src/test/run-pass/issue-7911.rs b/src/test/run-pass/issue-7911.rs index d8bb61477a0..c69b66f4dbd 100644 --- a/src/test/run-pass/issue-7911.rs +++ b/src/test/run-pass/issue-7911.rs @@ -37,9 +37,9 @@ macro_rules! generate_test(($type_:path, $slf:ident, $field:expr) => ( &mut $field as &mut FooBar } } -)) +)); -generate_test!(Foo, self, self.bar) +generate_test!(Foo, self, self.bar); pub fn main() { let mut foo: Foo = Foo { bar: Bar(42) }; diff --git a/src/test/run-pass/issue-8709.rs b/src/test/run-pass/issue-8709.rs index 9f2aaa4d005..d4ea05004a0 100644 --- a/src/test/run-pass/issue-8709.rs +++ b/src/test/run-pass/issue-8709.rs @@ -12,13 +12,13 @@ macro_rules! sty( ($t:ty) => (stringify!($t)) -) +); macro_rules! spath( ($t:path) => (stringify!($t)) -) +); fn main() { - assert_eq!(sty!(int), "int") - assert_eq!(spath!(std::option), "std::option") + assert_eq!(sty!(int), "int"); + assert_eq!(spath!(std::option), "std::option"); } diff --git a/src/test/run-pass/issue-8851.rs b/src/test/run-pass/issue-8851.rs index bf84721c984..5826a5f9919 100644 --- a/src/test/run-pass/issue-8851.rs +++ b/src/test/run-pass/issue-8851.rs @@ -29,9 +29,9 @@ macro_rules! test( } } ) -) +); -test!(y, 10 + (y as int)) +test!(y, 10 + (y as int)); pub fn main() { foo(T::A(20)); diff --git a/src/test/run-pass/issue-9110.rs b/src/test/run-pass/issue-9110.rs index ff086355f9d..60011281d42 100644 --- a/src/test/run-pass/issue-9110.rs +++ b/src/test/run-pass/issue-9110.rs @@ -17,8 +17,8 @@ macro_rules! silly_macro( pub fn bar(_foo : Foo) {} } ); -) +); -silly_macro!() +silly_macro!(); pub fn main() {} diff --git a/src/test/run-pass/issue-9129.rs b/src/test/run-pass/issue-9129.rs index b61263d1754..a6746f45206 100644 --- a/src/test/run-pass/issue-9129.rs +++ b/src/test/run-pass/issue-9129.rs @@ -20,7 +20,7 @@ impl bomb for S { fn boom(&self, _: Ident) { } } pub struct Ident { name: uint } // macro_rules! int3( () => ( unsafe { asm!( "int3" ); } ) ) -macro_rules! int3( () => ( { } ) ) +macro_rules! int3( () => ( { } ) ); fn Ident_new() -> Ident { int3!(); diff --git a/src/test/run-pass/let-var-hygiene.rs b/src/test/run-pass/let-var-hygiene.rs index 7b9fa3bcf7f..5eed791e058 100644 --- a/src/test/run-pass/let-var-hygiene.rs +++ b/src/test/run-pass/let-var-hygiene.rs @@ -11,7 +11,7 @@ #![feature(macro_rules)] // shouldn't affect evaluation of $ex: -macro_rules! bad_macro (($ex:expr) => ({let _x = 9i; $ex})) +macro_rules! bad_macro (($ex:expr) => ({let _x = 9i; $ex})); pub fn main() { let _x = 8i; assert_eq!(bad_macro!(_x),8i) diff --git a/src/test/run-pass/log_syntax-trace_macros-macro-locations.rs b/src/test/run-pass/log_syntax-trace_macros-macro-locations.rs index afcd154f647..95a5f1003b6 100644 --- a/src/test/run-pass/log_syntax-trace_macros-macro-locations.rs +++ b/src/test/run-pass/log_syntax-trace_macros-macro-locations.rs @@ -14,8 +14,8 @@ // macros can occur. // items -trace_macros!(false) -log_syntax!() +trace_macros!(false); +log_syntax!(); fn main() { diff --git a/src/test/run-pass/macro-2.rs b/src/test/run-pass/macro-2.rs index 0daa405fc6b..7b4d376993a 100644 --- a/src/test/run-pass/macro-2.rs +++ b/src/test/run-pass/macro-2.rs @@ -19,7 +19,7 @@ pub fn main() { fn f($x: int) -> int { return $body; }; f }) - ) + ); - assert!(mylambda_tt!(y, y * 2)(8) == 16) + assert!(mylambda_tt!(y, y * 2)(8) == 16); } diff --git a/src/test/run-pass/macro-attribute-expansion.rs b/src/test/run-pass/macro-attribute-expansion.rs index 6cf5dc8dec4..3c170634c22 100644 --- a/src/test/run-pass/macro-attribute-expansion.rs +++ b/src/test/run-pass/macro-attribute-expansion.rs @@ -22,8 +22,8 @@ macro_rules! descriptions { } // item -descriptions!(DOG is "an animal") -descriptions!(RUST is "a language") +descriptions! { DOG is "an animal" } +descriptions! { RUST is "a language" } pub fn main() { } diff --git a/src/test/run-pass/macro-attributes.rs b/src/test/run-pass/macro-attributes.rs index e09ca68f6d1..4df3b94c1c9 100644 --- a/src/test/run-pass/macro-attributes.rs +++ b/src/test/run-pass/macro-attributes.rs @@ -27,7 +27,7 @@ macro_rules! compiles_fine { } // item -compiles_fine!(#[foo]) +compiles_fine!(#[foo]); pub fn main() { // statement diff --git a/src/test/run-pass/macro-delimiter-significance.rs b/src/test/run-pass/macro-delimiter-significance.rs new file mode 100644 index 00000000000..fcf2dff66a5 --- /dev/null +++ b/src/test/run-pass/macro-delimiter-significance.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + vec![1u, 2, 3].len(); +} + diff --git a/src/test/run-pass/macro-include-items.rs b/src/test/run-pass/macro-include-items.rs index 0e7e6e247f5..5c95f67257c 100644 --- a/src/test/run-pass/macro-include-items.rs +++ b/src/test/run-pass/macro-include-items.rs @@ -12,7 +12,7 @@ fn bar() {} -include!(concat!("", "", "../auxiliary/", "macro-include-items-item.rs")) +include!(concat!("", "", "../auxiliary/", "macro-include-items-item.rs")); fn main() { foo(); diff --git a/src/test/run-pass/macro-interpolation.rs b/src/test/run-pass/macro-interpolation.rs index 672efa68398..45712f5c62a 100644 --- a/src/test/run-pass/macro-interpolation.rs +++ b/src/test/run-pass/macro-interpolation.rs @@ -22,7 +22,8 @@ macro_rules! overly_complicated ( } }) -) +); + pub fn main() { assert!(overly_complicated!(f, x, Option<uint>, { return Some(x); }, Some(8u), Some(y), y) == 8u) diff --git a/src/test/run-pass/macro-invocation-in-count-expr-fixed-array-type.rs b/src/test/run-pass/macro-invocation-in-count-expr-fixed-array-type.rs index 847024d42ba..4c124d85eee 100644 --- a/src/test/run-pass/macro-invocation-in-count-expr-fixed-array-type.rs +++ b/src/test/run-pass/macro-invocation-in-count-expr-fixed-array-type.rs @@ -12,7 +12,8 @@ macro_rules! four ( () => (4) -) +); + fn main() { let _x: [u16, ..four!()]; } diff --git a/src/test/run-pass/macro-meta-items.rs b/src/test/run-pass/macro-meta-items.rs index 91f67abd8af..4b01fdf8162 100644 --- a/src/test/run-pass/macro-meta-items.rs +++ b/src/test/run-pass/macro-meta-items.rs @@ -27,8 +27,8 @@ macro_rules! emit { } // item -compiles_fine!(bar) -emit!(foo) +compiles_fine!(bar); +emit!(foo); fn foo() { println!("{}", MISTYPED); diff --git a/src/test/run-pass/macro-method-issue-4621.rs b/src/test/run-pass/macro-method-issue-4621.rs index b5400edb41f..aa6de9acf6b 100644 --- a/src/test/run-pass/macro-method-issue-4621.rs +++ b/src/test/run-pass/macro-method-issue-4621.rs @@ -13,7 +13,7 @@ struct A; macro_rules! make_thirteen_method {() => (fn thirteen(&self)->int {13})} -impl A { make_thirteen_method!() } +impl A { make_thirteen_method!(); } fn main() { assert_eq!(A.thirteen(),13); diff --git a/src/test/run-pass/macro-multiple-items.rs b/src/test/run-pass/macro-multiple-items.rs index d56d211b606..4fb130f0e13 100644 --- a/src/test/run-pass/macro-multiple-items.rs +++ b/src/test/run-pass/macro-multiple-items.rs @@ -20,9 +20,9 @@ macro_rules! make_foo( fn bar(&self) {} } ) -) +); -make_foo!() +make_foo!(); pub fn main() { Foo.bar() diff --git a/src/test/run-pass/macro-nt-list.rs b/src/test/run-pass/macro-nt-list.rs index 2a00e5b8616..9367a231d4f 100644 --- a/src/test/run-pass/macro-nt-list.rs +++ b/src/test/run-pass/macro-nt-list.rs @@ -14,11 +14,11 @@ macro_rules! list ( ( ($($id:ident),*) ) => (()); ( [$($id:ident),*] ) => (()); ( {$($id:ident),*} ) => (()); -) +); macro_rules! tt_list ( ( ($($tt:tt),*) ) => (()); -) +); pub fn main() { list!( () ); diff --git a/src/test/run-pass/macro-of-higher-order.rs b/src/test/run-pass/macro-of-higher-order.rs index 561933d7599..c47b5e11089 100644 --- a/src/test/run-pass/macro-of-higher-order.rs +++ b/src/test/run-pass/macro-of-higher-order.rs @@ -12,10 +12,10 @@ macro_rules! higher_order ( (subst $lhs:tt => $rhs:tt) => ({ - macro_rules! anon ( $lhs => $rhs ) + macro_rules! anon ( $lhs => $rhs ); anon!(1u, 2u, "foo") }); -) +); fn main() { let val = higher_order!(subst ($x:expr, $y:expr, $foo:expr) => (($x + $y, $foo))); diff --git a/src/test/run-pass/macro-pat.rs b/src/test/run-pass/macro-pat.rs index 3e89466bc0f..496cef9d644 100644 --- a/src/test/run-pass/macro-pat.rs +++ b/src/test/run-pass/macro-pat.rs @@ -14,31 +14,31 @@ macro_rules! mypat( () => ( Some('y') ) -) +); macro_rules! char_x( () => ( 'x' ) -) +); macro_rules! some( ($x:pat) => ( Some($x) ) -) +); macro_rules! indirect( () => ( some!(char_x!()) ) -) +); macro_rules! ident_pat( ($x:ident) => ( $x ) -) +); fn f(c: Option<char>) -> uint { match c { diff --git a/src/test/run-pass/macro-stmt.rs b/src/test/run-pass/macro-stmt.rs index 49e146cb0cf..7be49e1acd8 100644 --- a/src/test/run-pass/macro-stmt.rs +++ b/src/test/run-pass/macro-stmt.rs @@ -16,9 +16,9 @@ macro_rules! myfn( ( $f:ident, ( $( $x:ident ),* ), $body:block ) => ( fn $f( $( $x : int),* ) -> int $body ) -) +); -myfn!(add, (a,b), { return a+b; } ) +myfn!(add, (a,b), { return a+b; } ); pub fn main() { @@ -37,7 +37,7 @@ pub fn main() { macro_rules! actually_an_expr_macro ( () => ( 16i ) - ) + ); assert_eq!({ actually_an_expr_macro!() }, 16i); diff --git a/src/test/run-pass/macro-with-attrs1.rs b/src/test/run-pass/macro-with-attrs1.rs index aaa2be66ff4..631fc866671 100644 --- a/src/test/run-pass/macro-with-attrs1.rs +++ b/src/test/run-pass/macro-with-attrs1.rs @@ -13,10 +13,10 @@ #![feature(macro_rules)] #[cfg(foo)] -macro_rules! foo( () => (1i) ) +macro_rules! foo( () => (1i) ); #[cfg(not(foo))] -macro_rules! foo( () => (2i) ) +macro_rules! foo( () => (2i) ); pub fn main() { assert_eq!(foo!(), 1i); diff --git a/src/test/run-pass/macro-with-attrs2.rs b/src/test/run-pass/macro-with-attrs2.rs index 4a191b2fa66..3ac0d47e61a 100644 --- a/src/test/run-pass/macro-with-attrs2.rs +++ b/src/test/run-pass/macro-with-attrs2.rs @@ -11,10 +11,10 @@ #![feature(macro_rules)] #[cfg(foo)] -macro_rules! foo( () => (1i) ) +macro_rules! foo( () => (1i) ); #[cfg(not(foo))] -macro_rules! foo( () => (2i) ) +macro_rules! foo( () => (2i) ); pub fn main() { assert_eq!(foo!(), 2i); diff --git a/src/test/run-pass/macro-with-braces-in-expr-position.rs b/src/test/run-pass/macro-with-braces-in-expr-position.rs index 8b59f26d869..024dc4c03e1 100644 --- a/src/test/run-pass/macro-with-braces-in-expr-position.rs +++ b/src/test/run-pass/macro-with-braces-in-expr-position.rs @@ -10,7 +10,7 @@ #![feature(macro_rules)] -macro_rules! expr (($e: expr) => { $e }) +macro_rules! expr (($e: expr) => { $e }); macro_rules! spawn { ($($code: tt)*) => { diff --git a/src/test/run-pass/match-in-macro.rs b/src/test/run-pass/match-in-macro.rs index 2f8e184033a..a776999ec8a 100644 --- a/src/test/run-pass/match-in-macro.rs +++ b/src/test/run-pass/match-in-macro.rs @@ -20,7 +20,7 @@ macro_rules! match_inside_expansion( Foo::B { b1:b2 , bb1:bb2 } => b2+bb2 } ) -) +); pub fn main() { assert_eq!(match_inside_expansion!(),129); diff --git a/src/test/run-pass/non-built-in-quote.rs b/src/test/run-pass/non-built-in-quote.rs index c6dd3736857..9151564b340 100644 --- a/src/test/run-pass/non-built-in-quote.rs +++ b/src/test/run-pass/non-built-in-quote.rs @@ -10,7 +10,7 @@ #![feature(macro_rules)] -macro_rules! quote_tokens ( () => (()) ) +macro_rules! quote_tokens ( () => (()) ); pub fn main() { quote_tokens!(); diff --git a/src/test/run-pass/overloaded-index-assoc-list.rs b/src/test/run-pass/overloaded-index-assoc-list.rs index 7c6ad45a9ef..c0359a34186 100644 --- a/src/test/run-pass/overloaded-index-assoc-list.rs +++ b/src/test/run-pass/overloaded-index-assoc-list.rs @@ -47,9 +47,9 @@ pub fn main() { list.push(foo.clone(), 22i); list.push(bar.clone(), 44i); - assert!(list[foo] == 22) - assert!(list[bar] == 44) + assert!(list[foo] == 22); + assert!(list[bar] == 44); - assert!(list[foo] == 22) - assert!(list[bar] == 44) + assert!(list[foo] == 22); + assert!(list[bar] == 44); } diff --git a/src/test/run-pass/slice-2.rs b/src/test/run-pass/slice-2.rs index 768c28cb8de..f03b4609637 100644 --- a/src/test/run-pass/slice-2.rs +++ b/src/test/run-pass/slice-2.rs @@ -15,57 +15,57 @@ fn main() { let x: &[int] = &[1, 2, 3, 4, 5]; let cmp: &[int] = &[1, 2, 3, 4, 5]; - assert!(x[] == cmp) + assert!(x[] == cmp); let cmp: &[int] = &[3, 4, 5]; - assert!(x[2..] == cmp) + assert!(x[2..] == cmp); let cmp: &[int] = &[1, 2, 3]; - assert!(x[..3] == cmp) + assert!(x[..3] == cmp); let cmp: &[int] = &[2, 3, 4]; - assert!(x[1..4] == cmp) + assert!(x[1..4] == cmp); let x: Vec<int> = vec![1, 2, 3, 4, 5]; let cmp: &[int] = &[1, 2, 3, 4, 5]; - assert!(x[] == cmp) + assert!(x[] == cmp); let cmp: &[int] = &[3, 4, 5]; - assert!(x[2..] == cmp) + assert!(x[2..] == cmp); let cmp: &[int] = &[1, 2, 3]; - assert!(x[..3] == cmp) + assert!(x[..3] == cmp); let cmp: &[int] = &[2, 3, 4]; - assert!(x[1..4] == cmp) + assert!(x[1..4] == cmp); let x: &mut [int] = &mut [1, 2, 3, 4, 5]; { let cmp: &mut [int] = &mut [1, 2, 3, 4, 5]; - assert!(x[mut] == cmp) + assert!(x[mut] == cmp); } { let cmp: &mut [int] = &mut [3, 4, 5]; - assert!(x[mut 2..] == cmp) + assert!(x[mut 2..] == cmp); } { let cmp: &mut [int] = &mut [1, 2, 3]; - assert!(x[mut ..3] == cmp) + assert!(x[mut ..3] == cmp); } { let cmp: &mut [int] = &mut [2, 3, 4]; - assert!(x[mut 1..4] == cmp) + assert!(x[mut 1..4] == cmp); } let mut x: Vec<int> = vec![1, 2, 3, 4, 5]; { let cmp: &mut [int] = &mut [1, 2, 3, 4, 5]; - assert!(x[mut] == cmp) + assert!(x[mut] == cmp); } { let cmp: &mut [int] = &mut [3, 4, 5]; - assert!(x[mut 2..] == cmp) + assert!(x[mut 2..] == cmp); } { let cmp: &mut [int] = &mut [1, 2, 3]; - assert!(x[mut ..3] == cmp) + assert!(x[mut ..3] == cmp); } { let cmp: &mut [int] = &mut [2, 3, 4]; - assert!(x[mut 1..4] == cmp) + assert!(x[mut 1..4] == cmp); } } diff --git a/src/test/run-pass/syntax-extension-source-utils.rs b/src/test/run-pass/syntax-extension-source-utils.rs index 2761d0cbcce..104a47e1afe 100644 --- a/src/test/run-pass/syntax-extension-source-utils.rs +++ b/src/test/run-pass/syntax-extension-source-utils.rs @@ -21,7 +21,7 @@ pub mod m1 { } } -macro_rules! indirect_line( () => ( line!() ) ) +macro_rules! indirect_line( () => ( line!() ) ); pub fn main() { assert_eq!(line!(), 27); diff --git a/src/test/run-pass/typeck-macro-interaction-issue-8852.rs b/src/test/run-pass/typeck-macro-interaction-issue-8852.rs index 1b08955adfc..4dec227d520 100644 --- a/src/test/run-pass/typeck-macro-interaction-issue-8852.rs +++ b/src/test/run-pass/typeck-macro-interaction-issue-8852.rs @@ -30,9 +30,9 @@ macro_rules! test( } } ) -) +); -test!(x,y,x + y) +test!(x,y,x + y); pub fn main() { foo(T::A(1), T::A(2)); diff --git a/src/test/run-pass/vec-macro-with-brackets.rs b/src/test/run-pass/vec-macro-with-brackets.rs index d06e3dc0633..2c784dade57 100644 --- a/src/test/run-pass/vec-macro-with-brackets.rs +++ b/src/test/run-pass/vec-macro-with-brackets.rs @@ -16,7 +16,7 @@ macro_rules! vec [ $(_temp.push($e);)* _temp }) -] +]; pub fn main() { let my_vec = vec![1i, 2, 3, 4, 5]; |
