diff --git a/src/doc/guide-macros.md b/src/doc/guide-macros.md index 65b6014b496e8..ae8047f555f0a 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 826af961fce06..ea7f51c86f817 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 0529bb8904ab9..5d5fadca18e6a 100644 --- a/src/libcollections/bit.rs +++ b/src/libcollections/bit.rs @@ -2073,7 +2073,7 @@ mod tests { let bools = vec![true, false, true, true]; let bitv: Bitv = bools.iter().map(|n| *n).collect(); - assert_eq!(bitv.iter().collect::>(), bools) + assert_eq!(bitv.iter().collect::>(), bools); let long = Vec::from_fn(10000, |i| i % 2 == 0); let bitv: Bitv = long.iter().map(|n| *n).collect(); @@ -2102,8 +2102,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)) } } @@ -2311,12 +2311,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/btree/node.rs b/src/libcollections/btree/node.rs index b40ff35cca1c6..066c2515c42f0 100644 --- a/src/libcollections/btree/node.rs +++ b/src/libcollections/btree/node.rs @@ -455,7 +455,7 @@ impl Node { /// Take all the values from right, separated by the given key and value fn absorb(&mut self, key: K, val: V, right: Node) { // Just as a sanity check, make sure we can fit this guy in - debug_assert!(self.len() + right.len() <= self.capacity()) + debug_assert!(self.len() + right.len() <= self.capacity()); self.keys.push(key); self.vals.push(val); diff --git a/src/libcollections/enum_set.rs b/src/libcollections/enum_set.rs index 3d750a30c2960..c4d778279209a 100644 --- a/src/libcollections/enum_set.rs +++ b/src/libcollections/enum_set.rs @@ -373,7 +373,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)) } @@ -400,23 +400,23 @@ mod test { let mut e1: EnumSet = EnumSet::new(); let elems: Vec = e1.iter().collect(); - assert!(elems.is_empty()) + assert!(elems.is_empty()); e1.insert(A); let elems = e1.iter().collect(); - assert_eq!(vec![A], elems) + assert_eq!(vec![A], elems); e1.insert(C); let elems = e1.iter().collect(); - assert_eq!(vec![A,C], elems) + assert_eq!(vec![A,C], elems); e1.insert(C); let elems = e1.iter().collect(); - assert_eq!(vec![A,C], elems) + assert_eq!(vec![A,C], elems); e1.insert(B); let elems = e1.iter().collect(); - assert_eq!(vec![A,B,C], elems) + assert_eq!(vec![A,B,C], elems); } /////////////////////////////////////////////////////////////////////////// @@ -434,35 +434,35 @@ mod test { let e_union = e1 | e2; let elems = 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 = 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 = e_intersection.iter().collect(); - assert_eq!(vec![C], elems) + assert_eq!(vec![C], elems); let e_subtract = e1 - e2; let elems = 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 = 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 = 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 = e_symmetric_diff.iter().collect(); - assert_eq!(vec![A,B], elems) + assert_eq!(vec![A,B], elems); } #[test] diff --git a/src/libcollections/hash/mod.rs b/src/libcollections/hash/mod.rs index b1ff3da947b70..c3db0155a3c17 100644 --- a/src/libcollections/hash/mod.rs +++ b/src/libcollections/hash/mod.rs @@ -113,16 +113,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 Hash for bool { #[inline] @@ -146,7 +146,7 @@ impl Hash for str { } } -macro_rules! impl_hash_tuple( +macro_rules! impl_hash_tuple { () => ( impl Hash for () { #[inline] @@ -171,21 +171,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> Hash for [T] { #[inline] diff --git a/src/libcollections/hash/sip.rs b/src/libcollections/hash/sip.rs index 67ac73bf0b9f6..e11674bd06be9 100644 --- a/src/libcollections/hash/sip.rs +++ b/src/libcollections/hash/sip.rs @@ -47,7 +47,7 @@ pub struct 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 | @@ -67,14 +67,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; @@ -84,7 +84,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/libcollections/macros.rs b/src/libcollections/macros.rs index ba8b3b8c7d3e4..ce4b1e467739e 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 132a07af6b67b..d23bff3016f05 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -1829,7 +1829,7 @@ mod tests { assert_eq!(format!("{}", x), x_str); assert_eq!(format!("{}", x.as_slice()), x_str); }) - ) + ); let empty: Vec = vec![]; test_show_vec!(empty, "[]".to_string()); test_show_vec!(vec![1i], "[1]".to_string()); diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index aaa7da312f29a..0e24931cd7b81 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -407,14 +407,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 e6698542df238..12b0e240fd266 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 diff --git a/src/libcollections/tree/map.rs b/src/libcollections/tree/map.rs index 119268c27eeac..88007d3a56e9f 100644 --- a/src/libcollections/tree/map.rs +++ b/src/libcollections/tree/map.rs @@ -892,7 +892,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() { @@ -960,10 +960,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`. @@ -975,10 +975,10 @@ macro_rules! define_iterator { fn size_hint(&self) -> (uint, Option) { (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) } @@ -987,7 +987,7 @@ macro_rules! define_iterator { fn size_hint(&self) -> (uint, Option) { self.iter.size_hint() } - }) + } } } } // end of define_iterator diff --git a/src/libcollections/trie/map.rs b/src/libcollections/trie/map.rs index 672ddab4d87e0..f9425fd91fa82 100644 --- a/src/libcollections/trie/map.rs +++ b/src/libcollections/trie/map.rs @@ -1136,7 +1136,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 @@ -1208,7 +1208,7 @@ macro_rules! iterator_impl { fn size_hint(&self) -> (uint, Option) { (self.remaining_min, Some(self.remaining_max)) } - }) + } } } } diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 7111a0776307a..4b9abff7393fc 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -1910,7 +1910,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 36e66ed27f3c9..af727521c0955 100644 --- a/src/libcollections/vec_map.rs +++ b/src/libcollections/vec_map.rs @@ -580,8 +580,8 @@ pub struct Entries<'a, T:'a> { iter: slice::Items<'a, Option> } -iterator!(impl Entries -> (uint, &'a T), as_ref, unwrap) -double_ended_iterator!(impl Entries -> (uint, &'a T), as_ref, unwrap) +iterator! { impl Entries -> (uint, &'a T), as_ref, unwrap } +double_ended_iterator! { impl Entries -> (uint, &'a T), as_ref, unwrap } /// Forward iterator over the key-value pairs of a map, with the /// values being mutable. @@ -591,8 +591,10 @@ pub struct MutEntries<'a, T:'a> { iter: slice::MutItems<'a, Option> } -iterator!(impl MutEntries -> (uint, &'a mut T), as_mut, unwrap) -double_ended_iterator!(impl MutEntries -> (uint, &'a mut T), as_mut, unwrap) +iterator! { impl MutEntries -> (uint, &'a mut T), as_mut, unwrap } +double_ended_iterator! { + impl MutEntries -> (uint, &'a mut T), as_mut, unwrap +} /// Forward iterator over the keys of a map pub type Keys<'a, T> = diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs index d13daf0964a1a..4e5c559b8ca58 100644 --- a/src/libcore/clone.rs +++ b/src/libcore/clone.rs @@ -48,7 +48,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. @@ -56,28 +56,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 { @@ -86,15 +86,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 59d31a0749f11..2fdcb52d18b81 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -293,7 +293,7 @@ mod impls { use kinds::Sized; 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 { @@ -303,7 +303,7 @@ mod impls { fn ne(&self, other: &$t) -> bool { (*self) != (*other) } } )*) - ) + } #[unstable = "Trait is unstable."] impl PartialEq for () { @@ -313,18 +313,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 { @@ -347,7 +349,7 @@ mod impls { fn gt(&self, other: &$t) -> bool { (*self) > (*other) } } )*) - ) + } #[unstable = "Trait is unstable."] impl PartialOrd for () { @@ -365,9 +367,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 { @@ -379,7 +381,7 @@ mod impls { } } )*) - ) + } #[unstable = "Trait is unstable."] impl Ord for () { @@ -395,7 +397,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 269a456542cb0..37456a6717be7 100644 --- a/src/libcore/default.rs +++ b/src/libcore/default.rs @@ -133,30 +133,31 @@ pub trait Default { fn default() -> Self; } -macro_rules! default_impl( +macro_rules! default_impl { ($t:ty, $v:expr) => { impl Default for $t { #[inline] 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 1efb595610155..ff49a62b2f53f 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -619,7 +619,7 @@ impl<'a, T> Pointer for &'a mut T { } } -macro_rules! floating(($ty:ident) => { +macro_rules! floating { ($ty:ident) => { impl Float for $ty { fn fmt(&self, fmt: &mut Formatter) -> Result { use num::Float; @@ -682,24 +682,24 @@ macro_rules! floating(($ty:ident) => { }) } } -}) -floating!(f32) -floating!(f64) +} } +floating! { f32 } +floating! { f64 } // Implementation of Show for various core types -macro_rules! delegate(($ty:ty to $other:ident) => { +macro_rules! delegate { ($ty:ty to $other:ident) => { impl Show for $ty { fn fmt(&self, f: &mut Formatter) -> Result { $other::fmt(self, f) } } -}) -delegate!(str to String) -delegate!(bool to Bool) -delegate!(char to Char) -delegate!(f32 to Float) -delegate!(f64 to Float) +} } +delegate! { str to String } +delegate! { bool to Bool } +delegate! { char to Char } +delegate! { f32 to Float } +delegate! { f64 to Float } impl Show for *const T { fn fmt(&self, f: &mut Formatter) -> Result { Pointer::fmt(self, f) } @@ -709,9 +709,11 @@ impl 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,)*) { @@ -733,9 +735,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 0a5af56217c8d..3fa63e0b5f614 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -99,13 +99,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)] @@ -166,25 +166,25 @@ macro_rules! int_base { } macro_rules! integer { ($Int:ident, $Uint:ident) => { - int_base!(Show for $Int as $Int -> Decimal) - int_base!(Signed 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!(Unsigned 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! { Signed 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! { Unsigned 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/iter.rs b/src/libcore/iter.rs index 3b62c8da1ebe1..ad4c0941c5f4a 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -802,18 +802,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. pub trait MultiplicativeIterator { @@ -844,18 +844,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. pub trait OrdIterator { @@ -1005,7 +1005,7 @@ impl MinMaxResult { /// use std::iter::{NoElements, OneElement, MinMax, MinMaxResult}; /// /// let r: MinMaxResult = 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 9ba67bb2e47dc..0823bc3c22c82 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,53 +81,54 @@ 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)*) => (format_args_method!($dst, write_fmt, $($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)*) ) -) +} /// Write some formatted data into a stream. /// /// Identical to the macro in `std::macros` #[macro_export] -macro_rules! write( +macro_rules! write { ($dst:expr, $($arg:tt)*) => ({ format_args_method!($dst, write_fmt, $($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 d15cff3a8a9e3..97de61d7e272e 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 39e5c99b97bec..557fa29c314da 100644 --- a/src/libcore/num/i16.rs +++ b/src/libcore/num/i16.rs @@ -13,5 +13,5 @@ #![unstable] #![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 1ad9b51b6acf7..7cf48bbfa1bb3 100644 --- a/src/libcore/num/i32.rs +++ b/src/libcore/num/i32.rs @@ -13,5 +13,5 @@ #![unstable] #![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 7c3b05df7e84f..4d783414f1191 100644 --- a/src/libcore/num/i64.rs +++ b/src/libcore/num/i64.rs @@ -13,5 +13,5 @@ #![unstable] #![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 b88e78d66bf34..6ab0708ecade0 100644 --- a/src/libcore/num/i8.rs +++ b/src/libcore/num/i8.rs @@ -13,5 +13,5 @@ #![unstable] #![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 835246684dff1..a0659d3830764 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 0f8950344c8a0..00b9d88abe194 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 04ca2c6001b2f..526e279f42033 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -453,61 +453,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, @@ -573,37 +573,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. pub trait SignedInt @@ -656,11 +656,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. pub trait UnsignedInt: Int { @@ -773,7 +773,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>() { @@ -790,9 +790,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(); @@ -804,9 +804,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] @@ -837,15 +837,15 @@ macro_rules! impl_to_primitive_int( fn to_f64(&self) -> Option { 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(); @@ -856,9 +856,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>() { @@ -874,9 +874,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] @@ -907,15 +907,15 @@ macro_rules! impl_to_primitive_uint( fn to_f64(&self) -> Option { 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) @@ -929,9 +929,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] @@ -962,10 +962,10 @@ macro_rules! impl_to_primitive_float( fn to_f64(&self) -> Option { 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. pub trait FromPrimitive { @@ -1108,7 +1108,7 @@ pub fn from_f64(n: f64) -> Option { 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() } @@ -1127,20 +1127,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. /// @@ -1165,7 +1165,7 @@ pub trait NumCast: ToPrimitive { fn from(n: T) -> Option; } -macro_rules! impl_num_cast( +macro_rules! impl_num_cast { ($T:ty, $conv:ident) => ( impl NumCast for $T { #[inline] @@ -1176,20 +1176,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)] @@ -1588,8 +1588,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) => { @@ -1655,16 +1655,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 @@ -1683,17 +1683,17 @@ pub trait Num: PartialEq + Zero + One + Mul + Div + Rem {} -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 { @@ -1713,18 +1713,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 { @@ -1741,18 +1741,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(n: T) -> T { @@ -1785,15 +1785,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 28dc9dacbe6a5..e7a7357fd5790 100644 --- a/src/libcore/num/u16.rs +++ b/src/libcore/num/u16.rs @@ -13,4 +13,4 @@ #![unstable] #![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 5763ebc4e4674..1f8e4a7d39620 100644 --- a/src/libcore/num/u32.rs +++ b/src/libcore/num/u32.rs @@ -13,5 +13,5 @@ #![unstable] #![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 f48807f8851c3..24382c53a69de 100644 --- a/src/libcore/num/u64.rs +++ b/src/libcore/num/u64.rs @@ -13,5 +13,5 @@ #![unstable] #![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 f4e9994892335..2d016fdf0f14b 100644 --- a/src/libcore/num/u8.rs +++ b/src/libcore/num/u8.rs @@ -13,5 +13,5 @@ #![unstable] #![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 62d2f11e54199..80d7b0b4ef374 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 2a94f851646c4..d79cf20fdfa6f 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 b4bf5351e597b..20cba2110f334 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -117,16 +117,16 @@ pub trait Add { fn add(&self, rhs: &RHS) -> Result; } -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 } /** * @@ -158,16 +158,16 @@ pub trait Sub { fn sub(&self, rhs: &RHS) -> Result; } -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 } /** * @@ -199,16 +199,16 @@ pub trait Mul { fn mul(&self, rhs: &RHS) -> Result; } -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 } /** * @@ -240,16 +240,16 @@ pub trait Div { fn div(&self, rhs: &RHS) -> Result; } -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 } /** * @@ -281,16 +281,16 @@ pub trait Rem { fn rem(&self, rhs: &RHS) -> Result; } -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) } } )*) -) +} -macro_rules! rem_float_impl( +macro_rules! rem_float_impl { ($t:ty, $fmod:ident) => { impl Rem<$t, $t> for $t { #[inline] @@ -300,11 +300,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 } /** * @@ -336,31 +336,31 @@ pub trait Neg { 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 } /** @@ -394,16 +394,16 @@ pub trait Not { } -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 } /** * @@ -435,16 +435,16 @@ pub trait BitAnd { fn bitand(&self, rhs: &RHS) -> Result; } -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 } /** * @@ -476,16 +476,16 @@ pub trait BitOr { fn bitor(&self, rhs: &RHS) -> Result; } -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 } /** * @@ -517,16 +517,16 @@ pub trait BitXor { fn bitxor(&self, rhs: &RHS) -> Result; } -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 } /** * @@ -558,7 +558,7 @@ pub trait Shl { fn shl(&self, rhs: &RHS) -> Result; } -macro_rules! shl_impl( +macro_rules! shl_impl { ($($t:ty)*) => ($( impl Shl for $t { #[inline] @@ -567,9 +567,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 } /** * @@ -601,16 +601,16 @@ pub trait Shr { fn shr(&self, rhs: &RHS) -> Result; } -macro_rules! shr_impl( +macro_rules! shr_impl { ($($t:ty)*) => ($( impl Shr 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 } /** * @@ -910,7 +910,7 @@ impl Fn<(A0,),Result> for extern "Rust" fn(A0) -> Result { } } -macro_rules! def_fn( +macro_rules! def_fn { ($($args:ident)*) => ( impl Fn<($($args,)*),Result> @@ -922,20 +922,20 @@ macro_rules! def_fn( } } ) -) - -def_fn!(A0 A1) -def_fn!(A0 A1 A2) -def_fn!(A0 A1 A2 A3) -def_fn!(A0 A1 A2 A3 A4) -def_fn!(A0 A1 A2 A3 A4 A5) -def_fn!(A0 A1 A2 A3 A4 A5 A6) -def_fn!(A0 A1 A2 A3 A4 A5 A6 A7) -def_fn!(A0 A1 A2 A3 A4 A5 A6 A7 A8) -def_fn!(A0 A1 A2 A3 A4 A5 A6 A7 A8 A9) -def_fn!(A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10) -def_fn!(A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11) -def_fn!(A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12) -def_fn!(A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13) -def_fn!(A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14) -def_fn!(A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15) +} + +def_fn! { A0 A1 } +def_fn! { A0 A1 A2 } +def_fn! { A0 A1 A2 A3 } +def_fn! { A0 A1 A2 A3 A4 } +def_fn! { A0 A1 A2 A3 A4 A5 } +def_fn! { A0 A1 A2 A3 A4 A5 A6 } +def_fn! { A0 A1 A2 A3 A4 A5 A6 A7 } +def_fn! { A0 A1 A2 A3 A4 A5 A6 A7 A8 } +def_fn! { A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 } +def_fn! { A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 } +def_fn! { A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 } +def_fn! { A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 } +def_fn! { A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 } +def_fn! { A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 } +def_fn! { A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15 } diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 5e2f5529e8d49..8ccc4eebb5ac8 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -360,7 +360,7 @@ mod externfnpointers { self_ == other_ } } - macro_rules! fnptreq( + macro_rules! fnptreq { ($($p:ident),*) => { impl<_R,$($p),*> PartialEq for extern "C" fn($($p),*) -> _R { #[inline] @@ -372,12 +372,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 0dc4fb839659d..53a1a4e946929 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 7923c46717e66..6f446e3a4544d 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -1764,15 +1764,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 24f26b15f27ac..3858db6f36f43 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -146,18 +146,18 @@ pub struct 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 { @@ -911,7 +911,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); @@ -1571,10 +1571,10 @@ pub trait StrPrelude for Sized? { /// # Example /// /// ```rust - /// 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_digit()), "foo1bar") + /// assert_eq!("12foo1bar12".trim_chars(x), "foo1bar"); + /// assert_eq!("123foo1bar123".trim_chars(|c: char| c.is_digit()), "foo1bar"); /// ``` fn trim_chars<'a, C: CharEq>(&'a self, to_trim: C) -> &'a str; @@ -1587,10 +1587,10 @@ pub trait StrPrelude for Sized? { /// # Example /// /// ```rust - /// 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_digit()), "foo1bar123") + /// assert_eq!("12foo1bar12".trim_left_chars(x), "foo1bar12"); + /// assert_eq!("123foo1bar123".trim_left_chars(|c: char| c.is_digit()), "foo1bar123"); /// ``` fn trim_left_chars<'a, C: CharEq>(&'a self, to_trim: C) -> &'a str; @@ -1603,10 +1603,10 @@ pub trait StrPrelude for Sized? { /// # Example /// /// ```rust - /// 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_digit()), "123foo1bar") + /// assert_eq!("12foo1bar12".trim_right_chars(x), "12foo1bar"); + /// assert_eq!("123foo1bar123".trim_right_chars(|c: char| c.is_digit()), "123foo1bar"); /// ``` fn trim_right_chars<'a, C: CharEq>(&'a self, to_trim: C) -> &'a str; @@ -1952,7 +1952,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 d046faa82d405..7302e892fab89 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 = 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 f3c2d67cdeb1b..7435831ac6dba 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 7232fc7505df9..3b3407e1ada52 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 075b8448f3529..9e1aec256eed0 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 9e0439f281889..f72244239b260 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 f01ec3f0310a3..be8dfd02ee196 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 e25f10bd0dad5..11fc92b79b681 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 0cd1ded21d6c6..ff35ee77af119 100644 --- a/src/libcoretest/num/mod.rs +++ b/src/libcoretest/num/mod.rs @@ -59,9 +59,9 @@ mod test { let s : Option = from_str_radix("80000", 10); assert_eq!(s, None); let f : Option = from_str_radix("10000000000000000000000000000000000000000", 10); - assert_eq!(f, Some(Float::infinity())) + assert_eq!(f, Some(Float::infinity())); let fe : Option = 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 d6aa647667804..8455207583cc1 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 218e79df5aece..b44e60f652979 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 f78d4813503e7..ffcd1015d58d6 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 bb08072320b70..4ee14e22f2d57 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 0db865f4cde7a..395e55cf255d2 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 01a88119b6470..128e3621f85ea 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/libcoretest/tuple.rs b/src/libcoretest/tuple.rs index be71e42ae9ad6..2cf809da71ab5 100644 --- a/src/libcoretest/tuple.rs +++ b/src/libcoretest/tuple.rs @@ -25,7 +25,7 @@ fn test_getters() { *$x.$mutN() += $incr; assert_eq!(*$x.$refN(), $result); }) - ) + ); let mut x = (0u8, 1u16, 2u32, 3u64, 4u, 5i8, 6i16, 7i32, 8i64, 9i, 10f32, 11f64); test_getter!(x, val0, ref0, mut0, 0, 1, 1); test_getter!(x, val1, ref1, mut1, 1, 1, 2); diff --git a/src/libgreen/macros.rs b/src/libgreen/macros.rs index 4cce430d88a8d..93c36839e72d8 100644 --- a/src/libgreen/macros.rs +++ b/src/libgreen/macros.rs @@ -23,7 +23,7 @@ macro_rules! rterrln ( ($($arg:tt)*) => ( { format_args!(::macros::dumb_println, $($arg)*) } ) -) +); // Some basic logging. Enabled by passing `--cfg rtdebug` to the libstd build. macro_rules! rtdebug ( @@ -32,7 +32,7 @@ macro_rules! rtdebug ( rterrln!($($arg)*) } }) -) +); macro_rules! rtassert ( ( $arg:expr ) => ( { @@ -42,14 +42,14 @@ macro_rules! rtassert ( } } } ) -) +); macro_rules! rtabort ( ($($arg:tt)*) => ( { ::macros::abort(format!($($arg)*).as_slice()); } ) -) +); pub fn dumb_println(args: &fmt::Arguments) { use std::rt; diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index 2e60ce31d5e5e..9640bafdfc393 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -213,7 +213,7 @@ pub const WARN: u32 = 2; /// Error log level pub const ERROR: u32 = 1; -local_data_key!(local_logger: Box) +local_data_key! { local_logger: Box } /// 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 4f8837083ae57..8b2cfcd420ac1 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 49d60a98b6496..fc97b569c1d1a 100644 --- a/src/librand/isaac.rs +++ b/src/librand/isaac.rs @@ -431,7 +431,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 96f40bcc1565e..3b38fde3884f1 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::() != 1.0) - assert!(ConstantRng(0xffff_ffff_ffff_ffff).gen::() != 1.0) + assert!(ConstantRng(0xffff_ffff).gen::() != 1.0); + assert!(ConstantRng(0xffff_ffff_ffff_ffff).gen::() != 1.0); } #[test] diff --git a/src/librbml/lib.rs b/src/librbml/lib.rs index ccc7b96b26b82..aa6d87a3b34c3 100644 --- a/src/librbml/lib.rs +++ b/src/librbml/lib.rs @@ -134,7 +134,7 @@ pub mod reader { pub type DecodeResult = Result; // rbml reading - macro_rules! try_or( + macro_rules! try_or { ($e:expr, $r:expr) => ( match $e { Ok(e) => e, @@ -144,7 +144,7 @@ pub mod reader { } } ) - ) + } pub struct Res { pub val: uint, diff --git a/src/libregex/parse.rs b/src/libregex/parse.rs index c6f09e4697182..21b916495b5bd 100644 --- a/src/libregex/parse.rs +++ b/src/libregex/parse.rs @@ -222,7 +222,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; @@ -371,7 +371,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 @@ -595,7 +595,7 @@ impl<'a> Parser<'a> { // Parses all escape sequences. // Assumes that '\' is the current character. fn parse_escape(&mut self) -> Result { - try!(self.noteof("an escape sequence following a '\\'")) + try!(self.noteof("an escape sequence following a '\\'")); let c = self.cur(); if is_punct(c) { @@ -637,7 +637,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, @@ -675,10 +675,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; } } @@ -696,7 +696,7 @@ impl<'a> Parser<'a> { // Assumes that \x has been read. fn parse_hex(&mut self) -> Result { if !self.peek_is(1, '{') { - try!(self.expect('{')) + try!(self.expect('{')); return self.parse_hex_two() } let start = self.chari + 2; @@ -721,7 +721,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()) } @@ -741,7 +741,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, @@ -771,7 +771,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; @@ -779,7 +780,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}, @@ -821,7 +823,7 @@ impl<'a> Parser<'a> { // If it is, then the next character is consumed. fn get_next_greedy(&mut self) -> Result { 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 e1c24a902fa10..0c204f759e6ad 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 fb938513cb10b..7508f4c50a2c3 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 7f014b4eb68a6..1415664719124 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 2c59950abc3a3..87b6d58d11b89 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\S+)\s+(?P\S+)(?P\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)") -noparse!(fail_bad_capture_name, "(?P)") -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.)(?P.)") -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)"} +noparse!{fail_bad_capture_name, "(?P)"} +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.)(?P.)"} +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 afbb18faa0b9f..8f46efdcd7698 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, @@ -146,4 +146,5 @@ register_diagnostics!( E0167, E0168, E0169 -) +} + diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 0da9b05d4f862..d83641f5463a7 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -125,7 +125,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 df014eb1206aa..2ba113d696c41 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -53,8 +53,11 @@ use syntax::ast::{TyI, TyU, TyI8, TyU8, TyI16, TyU16, TyI32, TyU32, TyI64, TyU64 use syntax::ptr::P; use syntax::visit::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; @@ -85,8 +88,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; @@ -108,17 +114,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 @@ -383,8 +401,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> @@ -467,8 +488,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; @@ -532,8 +556,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> @@ -600,8 +627,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; @@ -688,8 +718,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; @@ -712,11 +745,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; @@ -783,8 +822,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; @@ -902,8 +944,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; @@ -1023,8 +1068,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; @@ -1072,8 +1120,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; @@ -1165,8 +1216,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; @@ -1200,8 +1254,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; @@ -1234,8 +1291,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; @@ -1258,8 +1318,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; @@ -1279,8 +1342,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; @@ -1357,8 +1423,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; @@ -1397,8 +1466,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. @@ -1555,15 +1627,24 @@ impl LintPass for MissingDoc { } } -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. @@ -1722,44 +1803,83 @@ 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" +} /// 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 e9b235a2fe34b..52fb4d2c42f46 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -176,17 +176,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, @@ -208,21 +208,21 @@ impl LintStore { UnusedMut, UnusedAllocation, Stability, - ) + ); 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); @@ -322,7 +322,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(); @@ -330,7 +330,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 315462235bebd..accf98e507314 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc/lint/mod.rs @@ -73,7 +73,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), @@ -81,11 +81,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 @@ -95,17 +95,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 a53f5fa187df2..318780a1d7fb8 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/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index d7925177c29db..99b4853896d8a 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/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/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index a892744262bbe..09a450099cf07 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -538,7 +538,7 @@ pub fn eval_const_expr_partial(tcx: &ty::ctxt, e: &Expr) -> Result 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 a8ab4425f1dba..39e024708dc37 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -214,14 +214,14 @@ pub struct ExprUseVisitor<'d,'t,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 } ) -) +} impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,TYPER> { pub fn new(delegate: &'d mut Delegate, diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index c9e5bbbc54e1d..c03deb1247303 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -375,14 +375,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 9f90afa37490c..a45f47bbc5cce 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -1024,7 +1024,7 @@ mod primitives { use syntax::ast; - macro_rules! def_prim_ty( + macro_rules! def_prim_ty { ($name:ident, $sty:expr) => ( pub static $name: t_box_ = t_box_ { sty: $sty, @@ -1032,22 +1032,22 @@ mod primitives { region_depth: 0, }; ) - ) - - def_prim_ty!(TY_BOOL, super::ty_bool) - def_prim_ty!(TY_CHAR, super::ty_char) - def_prim_ty!(TY_INT, super::ty_int(ast::TyI)) - def_prim_ty!(TY_I8, super::ty_int(ast::TyI8)) - def_prim_ty!(TY_I16, super::ty_int(ast::TyI16)) - def_prim_ty!(TY_I32, super::ty_int(ast::TyI32)) - def_prim_ty!(TY_I64, super::ty_int(ast::TyI64)) - def_prim_ty!(TY_UINT, super::ty_uint(ast::TyU)) - def_prim_ty!(TY_U8, super::ty_uint(ast::TyU8)) - def_prim_ty!(TY_U16, super::ty_uint(ast::TyU16)) - def_prim_ty!(TY_U32, super::ty_uint(ast::TyU32)) - def_prim_ty!(TY_U64, super::ty_uint(ast::TyU64)) - def_prim_ty!(TY_F32, super::ty_float(ast::TyF32)) - def_prim_ty!(TY_F64, super::ty_float(ast::TyF64)) + } + + def_prim_ty! { TY_BOOL, super::ty_bool } + def_prim_ty! { TY_CHAR, super::ty_char } + def_prim_ty! { TY_INT, super::ty_int(ast::TyI) } + def_prim_ty! { TY_I8, super::ty_int(ast::TyI8) } + def_prim_ty! { TY_I16, super::ty_int(ast::TyI16) } + def_prim_ty! { TY_I32, super::ty_int(ast::TyI32) } + def_prim_ty! { TY_I64, super::ty_int(ast::TyI64) } + def_prim_ty! { TY_UINT, super::ty_uint(ast::TyU) } + def_prim_ty! { TY_U8, super::ty_uint(ast::TyU8) } + def_prim_ty! { TY_U16, super::ty_uint(ast::TyU16) } + def_prim_ty! { TY_U32, super::ty_uint(ast::TyU32) } + def_prim_ty! { TY_U64, super::ty_uint(ast::TyU64) } + def_prim_ty! { TY_F32, super::ty_float(ast::TyF32) } + def_prim_ty! { TY_F64, super::ty_float(ast::TyF64) } pub static TY_ERR: t_box_ = t_box_ { sty: super::ty_err, @@ -2512,7 +2512,7 @@ pub struct TypeContents { pub bits: u64 } -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 { @@ -2523,9 +2523,9 @@ macro_rules! def_type_content_sets( )+ } } -) +} -def_type_content_sets!( +def_type_content_sets! { mod TC { None = 0b0000_0000__0000_0000__0000, @@ -2576,7 +2576,7 @@ def_type_content_sets!( // All bits All = 0b1111_1111__1111_1111__1111 } -) +} impl TypeContents { pub fn when(&self, cond: bool) -> TypeContents { @@ -2886,7 +2886,7 @@ pub fn type_contents(cx: &ctxt, ty: t) -> TypeContents { ty_open(t) => { let result = tc_ty(cx, t, cache); - assert!(!result.is_sized(cx)) + assert!(!result.is_sized(cx)); result.unsafe_pointer() | TC::Nonsized } @@ -3391,7 +3391,7 @@ pub fn unsized_part_of_type(cx: &ctxt, ty: t) -> t { 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]) } @@ -5579,7 +5579,7 @@ pub fn hash_crate_independent(tcx: &ctxt, t: t, svh: &Svh) -> u64 { match c.store { UniqTraitStore => byte!(0), RegionTraitStore(r, m) => { - byte!(1) + byte!(1); region(&mut state, r); assert_eq!(m, ast::MutMutable); } diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index c63e8944dbdca..a2fdb2fcfbb78 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -203,14 +203,14 @@ pub fn regionck_ensure_component_tys_wf(fcx: &FnCtxt, // 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/middle/typeck/infer/error_reporting.rs b/src/librustc/middle/typeck/infer/error_reporting.rs index 65bd21b14e025..3b61a51e4636e 100644 --- a/src/librustc/middle/typeck/infer/error_reporting.rs +++ b/src/librustc/middle/typeck/infer/error_reporting.rs @@ -226,7 +226,7 @@ impl<'a, 'tcx> ErrorReporting 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, @@ -243,7 +243,7 @@ impl<'a, 'tcx> ErrorReporting 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); @@ -326,7 +326,7 @@ impl<'a, 'tcx> ErrorReporting 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/weak_lang_items.rs b/src/librustc/middle/weak_lang_items.rs index e0fe87d6d065a..892a8004fec1c 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 e10a1a4342c45..728b7a9fade49 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -176,17 +176,17 @@ pub enum CrateType { CrateTypeStaticlib, } -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, @@ -214,7 +214,7 @@ debugging_opts!( FLOWGRAPH_PRINT_ALL ] 0 -) +} pub fn debugging_opts_map() -> Vec<(&'static str, &'static str, u64)> { vec!(("verbose", "in general, enable more debug printouts", VERBOSE), @@ -281,7 +281,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)] @@ -396,9 +396,9 @@ macro_rules! cgoptions( } } } -) ) +) } -cgoptions!( +cgoptions! { ar: Option = (None, parse_opt_string, "tool to assemble archives with"), linker: Option = (None, parse_opt_string, @@ -447,7 +447,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 4c08c82ecac5a..6701c989f1a0d 100644 --- a/src/librustc_back/sha2.rs +++ b/src/librustc_back/sha2.rs @@ -346,7 +346,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, @@ -357,7 +357,7 @@ impl Engine256State { $H += sum0($A) + maj($A, $B, $C); } ) - ) + ); read_u32v_be(w[mut 0..16], data); @@ -451,7 +451,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 c7a7888c1cd60..6700253ac854e 100644 --- a/src/librustc_back/svh.rs +++ b/src/librustc_back/svh.rs @@ -344,14 +344,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 d7b4285cdb0ab..17e197df99ede 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); @@ -326,7 +326,7 @@ impl Target { } } ) - ) + ); load_specific!( x86_64_unknown_linux_gnu, @@ -349,7 +349,7 @@ impl Target { x86_64_pc_windows_gnu, i686_pc_windows_gnu - ) + ); let path = Path::new(target); diff --git a/src/librustc_trans/trans/_match.rs b/src/librustc_trans/trans/_match.rs index 001a3a4dca0e9..e4b65c235a579 100644 --- a/src/librustc_trans/trans/_match.rs +++ b/src/librustc_trans/trans/_match.rs @@ -677,7 +677,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 { @@ -686,7 +686,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 806c4a68ba281..2c9efd7e9afec 100644 --- a/src/librustc_trans/trans/adt.rs +++ b/src/librustc_trans/trans/adt.rs @@ -157,7 +157,7 @@ pub fn represent_type(cx: &CrateContext, t: ty::t) -> Rc { } 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 9c4a532790dde..d9083113905d9 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -100,7 +100,7 @@ use syntax::visit::Visitor; use syntax::visit; use syntax::{ast, ast_util, ast_map}; -local_data_key!(task_local_insn_key: RefCell>) +local_data_key! { task_local_insn_key: RefCell> } pub fn with_insn_ctxt(blk: |&[&'static str]|) { match task_local_insn_key.get() { diff --git a/src/librustc_trans/trans/context.rs b/src/librustc_trans/trans/context.rs index c2c1f8bb5f5ac..1809fa3aa67b4 100644 --- a/src/librustc_trans/trans/context.rs +++ b/src/librustc_trans/trans/context.rs @@ -733,10 +733,10 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option (Type::struct_(ccx, &[$($field_ty),*], false)) - ) + ); let i8p = Type::i8p(ccx); let void = Type::void(ccx); @@ -870,7 +870,7 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option 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 c4be6bf27b800..8510188aa91e2 100644 --- a/src/librustc_trans/trans/datum.rs +++ b/src/librustc_trans/trans/datum.rs @@ -653,7 +653,7 @@ impl Datum { } pub fn to_llbool(self, bcx: Block) -> 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 65fd95667608a..5b9b9234638f8 100644 --- a/src/librustc_trans/trans/debuginfo.rs +++ b/src/librustc_trans/trans/debuginfo.rs @@ -636,7 +636,7 @@ impl TypeMap { // 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() @@ -645,7 +645,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 313280cb7a8cc..ab202975bfc15 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 0662909e40f5a..c65cd621b91f6 100644 --- a/src/librustc_trans/trans/type_.rs +++ b/src/librustc_trans/trans/type_.rs @@ -31,9 +31,9 @@ pub struct Type { rf: TypeRef } -macro_rules! ty ( +macro_rules! ty { ($e:expr) => ( Type::from_ref(unsafe { $e })) -) +} /** * Wrapper for LLVM TypeRef diff --git a/src/librustc_trans/trans/value.rs b/src/librustc_trans/trans/value.rs index 8d74275c92ac7..c937316d53110 100644 --- a/src/librustc_trans/trans/value.rs +++ b/src/librustc_trans/trans/value.rs @@ -16,14 +16,14 @@ use libc::c_uint; pub struct Value(pub ValueRef); -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 diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index a7f3315154756..71ca71f10ecd0 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -758,7 +758,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, "")) + try!(write!(f, "
")); try!(fmt_inner(f, &mut context, self)); write!(f, "
") } diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 9dacee1652a4a..726db8407535d 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -147,10 +147,10 @@ fn stripped_filtered_line<'a>(s: &'a str) -> Option<&'a str> { } } -local_data_key!(used_header_map: RefCell>) -local_data_key!(test_idx: Cell) +local_data_key!(used_header_map: RefCell>); +local_data_key!(test_idx: Cell); // None == render an example, but there's no crate name -local_data_key!(pub playground_krate: Option) +local_data_key!(pub playground_krate: Option); 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 0ecb86d8bdd61..c62dc940acefc 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -232,8 +232,8 @@ struct IndexItem { // TLS keys used to carry information around during rendering. -local_data_key!(pub cache_key: Arc) -local_data_key!(pub current_location_key: Vec ) +local_data_key!(pub cache_key: Arc); +local_data_key!(pub current_location_key: Vec); /// Generates the documentation for `crate` into the directory `dst` pub fn run(mut krate: clean::Crate, external_html: &ExternalHtml, dst: Path) -> io::IoResult<()> { diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 0350fe72e110d..37c254666ed3e 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -84,7 +84,7 @@ static DEFAULT_PASSES: &'static [&'static str] = &[ "unindent-comments", ]; -local_data_key!(pub analysiskey: core::CrateAnalysis) +local_data_key!(pub analysiskey: core::CrateAnalysis); type Output = (clean::Crate, Vec ); diff --git a/src/librustrt/local_data.rs b/src/librustrt/local_data.rs index ca0f694676f29..f868b92ff6e19 100644 --- a/src/librustrt/local_data.rs +++ b/src/librustrt/local_data.rs @@ -23,8 +23,8 @@ named and annotated. This name is then passed to the functions in this module to modify/read the slot specified by the key. ```rust -local_data_key!(key_int: int) -local_data_key!(key_vector: Vec) +local_data_key!(key_int: int); +local_data_key!(key_vector: Vec); key_int.replace(Some(3)); assert_eq!(*key_int.get().unwrap(), 3); @@ -173,7 +173,7 @@ impl KeyValue { /// # Example /// /// ``` - /// local_data_key!(foo: int) + /// local_data_key!(foo: int); /// /// assert_eq!(foo.replace(Some(10)), None); /// assert_eq!(foo.replace(Some(4)), Some(10)); @@ -254,7 +254,7 @@ impl KeyValue { /// # Example /// /// ``` - /// local_data_key!(key: int) + /// local_data_key!(key: int); /// /// assert!(key.get().is_none()); /// diff --git a/src/librustrt/macros.rs b/src/librustrt/macros.rs index d4e92736a9d4d..4514430853572 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/librustrt/task.rs b/src/librustrt/task.rs index 2c8fca2d5e6d9..bf3d9a6c3dd3f 100644 --- a/src/librustrt/task.rs +++ b/src/librustrt/task.rs @@ -297,7 +297,7 @@ impl Task { // was recursively run via the `run` method invoking this method. In // this case, we just make sure the world is as we thought, and return. if task.is_destroyed() { - rtassert!(result.is_ok()) + rtassert!(result.is_ok()); return task } @@ -552,10 +552,10 @@ mod test { #[test] fn tls() { - local_data_key!(key: String) + local_data_key!(key: String); key.replace(Some("data".to_string())); assert_eq!(key.get().unwrap().as_slice(), "data"); - local_data_key!(key2: String) + local_data_key!(key2: String); key2.replace(Some("data".to_string())); assert_eq!(key2.get().unwrap().as_slice(), "data"); } diff --git a/src/libserialize/base64.rs b/src/libserialize/base64.rs index 9b1e285431f6a..04c140b619d97 100644 --- a/src/libserialize/base64.rs +++ b/src/libserialize/base64.rs @@ -355,7 +355,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 2968c53de9aba..8fef270df29a9 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -1952,7 +1952,7 @@ impl Decoder { } } -macro_rules! expect( +macro_rules! expect { ($e:expr, Null) => ({ match $e { Null => Ok(()), @@ -1969,7 +1969,7 @@ macro_rules! expect( } } }) -) +} macro_rules! read_primitive { ($name:ident, $ty:ty) => { @@ -2013,16 +2013,16 @@ impl ::Decoder 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 { self.read_f64().map(|x| x as f32) } @@ -2278,25 +2278,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 { 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 { 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() } @@ -2919,7 +2919,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".to_string())); diff --git a/src/libserialize/serialize.rs b/src/libserialize/serialize.rs index 7539a6dc3486b..6cecda3b4ae11 100644 --- a/src/libserialize/serialize.rs +++ b/src/libserialize/serialize.rs @@ -471,7 +471,9 @@ impl,T:Decodable> Decodable for Option { } } -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 { @@ -479,7 +481,7 @@ macro_rules! count_idents { ($_i:ident $(, $rest:ident)*) => { 1 + count_idents!($($rest),*) } } -macro_rules! tuple ( +macro_rules! tuple { () => (); ( $($name:ident,)+ ) => ( impl,$($name:Decodable),*> Decodable for ($($name,)*) { @@ -508,9 +510,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 923349b1bf740..a9895c9727576 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -579,14 +579,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() { @@ -729,7 +729,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().as_slice().to_ascii_upper(), - (from_u32(upper).unwrap()).to_string()) + (from_u32(upper).unwrap()).to_string()); i += 1; } } @@ -745,7 +745,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().as_slice().to_ascii_lower(), - (from_u32(lower).unwrap()).to_string()) + (from_u32(lower).unwrap()).to_string()); i += 1; } } @@ -761,7 +761,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; } } @@ -778,7 +778,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 69375e8d4f84e..b77b21d9517e2 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); } - local_data_key!(drop_vector: RefCell>) + local_data_key! { drop_vector: RefCell> } #[deriving(Hash, PartialEq, Eq)] struct Dropable { diff --git a/src/libstd/failure.rs b/src/libstd/failure.rs index 0775997435641..d60a0317dd6b6 100644 --- a/src/libstd/failure.rs +++ b/src/libstd/failure.rs @@ -25,7 +25,7 @@ use str::Str; use string::String; // Defined in this module instead of io::stdio so that the unwinding -local_data_key!(pub local_stderr: Box) +local_data_key! { pub local_stderr: Box } 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 4b2ffb4d559c4..8fb060870caf7 100644 --- a/src/libstd/io/extensions.rs +++ b/src/libstd/io/extensions.rs @@ -505,7 +505,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; @@ -520,7 +520,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 cd4141e045cb5..44b5bd0b6b79c 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -815,20 +815,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().as_slice().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 d87768a086098..0c69429e694b0 100644 --- a/src/libstd/io/net/ip.rs +++ b/src/libstd/io/net/ip.rs @@ -468,7 +468,7 @@ fn resolve_socket_addr(s: &str, p: u16) -> IoResult> { } fn parse_and_resolve_socket_addr(s: &str) -> IoResult> { - macro_rules! try_opt( + macro_rules! try_opt { ($e:expr, $msg:expr) => ( match $e { Some(r) => r, @@ -479,7 +479,7 @@ fn parse_and_resolve_socket_addr(s: &str) -> IoResult> { }) } ) - ) + } // 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 362e80f9f12c3..239a901f12e5f 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -87,7 +87,7 @@ fn src(fd: libc::c_int, _readable: bool, f: |StdSource| -> T) -> T { } } -local_data_key!(local_stdout: Box) +local_data_key! { local_stdout: Box } /// Creates a new non-blocking handle to the stdin of the current process. /// diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 26e9e70dff3e8..86499a70f22d5 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 { ($given:expr , $expected:expr) => ({ match (&($given), &($expected)) { (given_val, expected_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. It will panic if /// executed. This is occasionally useful to put after loops that never @@ -210,7 +210,7 @@ macro_rules! debug_assert_eq( /// } /// ``` #[macro_export] -macro_rules! unreachable( +macro_rules! unreachable { () => ({ panic!("internal error: entered unreachable code") }); @@ -220,14 +220,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. @@ -240,11 +240,11 @@ macro_rules! unimplemented( /// format!("x = {}, y = {y}", 10i, y = 30i); /// ``` #[macro_export] -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. @@ -259,27 +259,27 @@ macro_rules! format( /// write!(&mut w, "formatted {}", "arguments"); /// ``` #[macro_export] -macro_rules! write( +macro_rules! write { ($dst:expr, $($arg:tt)*) => ({ format_args_method!($dst, write_fmt, $($arg)*) }) -) +} /// Equivalent to the `write!` macro, except that a newline is appended after /// the message is written. #[macro_export] -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] -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. /// @@ -294,22 +294,22 @@ macro_rules! print( /// println!("format {} arguments", "some"); /// ``` #[macro_export] -macro_rules! println( +macro_rules! println { ($($arg:tt)*) => (format_args!(::std::io::stdio::println_args, $($arg)*)) -) +} /// Declare a task-local key with a specific type. /// /// # Example /// /// ``` -/// local_data_key!(my_integer: int) +/// local_data_key!(my_integer: int); /// /// my_integer.replace(Some(2)); /// println!("{}", my_integer.get().map(|a| *a)); /// ``` #[macro_export] -macro_rules! local_data_key( +macro_rules! local_data_key { ($name:ident: $ty:ty) => ( #[allow(non_upper_case_globals)] static $name: ::std::local_data::Key<$ty> = &::std::local_data::KeyValueKey; @@ -318,31 +318,31 @@ macro_rules! local_data_key( #[allow(non_upper_case_globals)] pub static $name: ::std::local_data::Key<$ty> = &::std::local_data::KeyValueKey; ); -) +} /// 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::BoxedSlicePrelude; 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! col( () => ({ /* compiler built-in */ }) ) + macro_rules! col { () => ({ /* 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 207fa6499309c..1fb3b9c461f85 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -663,8 +663,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 543d50596e8ce..caa5235622b2d 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -665,8 +665,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 4b3727ead6148..fd00f15662a72 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 6455c10736a3f..ac86819714c73 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 39b179c8274eb..312820cc36c17 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 a0c474c479ae4..f54b28eb4c0b7 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 e911ed1de9ac4..ee1fb13065b42 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 36c021efe0a39..f59dab4b20bde 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 2f1162d28e558..fce150c4ad1e3 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 f49b2b0deed32..1609f7af20074 100644 --- a/src/libstd/num/mod.rs +++ b/src/libstd/num/mod.rs @@ -157,7 +157,7 @@ mod tests { use u64; use uint; - macro_rules! test_cast_20( + macro_rules! test_cast_20 { ($_20:expr) => ({ let _20 = $_20; @@ -200,7 +200,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) } @@ -660,7 +660,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] @@ -672,15 +672,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] @@ -695,13 +695,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 } @@ -755,13 +755,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 246224ddb2b4e..e3ce32078ce46 100644 --- a/src/libstd/num/u16.rs +++ b/src/libstd/num/u16.rs @@ -15,4 +15,4 @@ pub use core::u16::{BITS, BYTES, MIN, MAX}; -uint_module!(u16) +uint_module! { u16 } diff --git a/src/libstd/num/u32.rs b/src/libstd/num/u32.rs index 143b45010c254..6946fbd6fec0b 100644 --- a/src/libstd/num/u32.rs +++ b/src/libstd/num/u32.rs @@ -15,4 +15,4 @@ pub use core::u32::{BITS, BYTES, MIN, MAX}; -uint_module!(u32) +uint_module! { u32 } diff --git a/src/libstd/num/u64.rs b/src/libstd/num/u64.rs index 92c5380f980ea..6a08fddc40593 100644 --- a/src/libstd/num/u64.rs +++ b/src/libstd/num/u64.rs @@ -15,4 +15,4 @@ pub use core::u64::{BITS, BYTES, MIN, MAX}; -uint_module!(u64) +uint_module! { u64 } diff --git a/src/libstd/num/u8.rs b/src/libstd/num/u8.rs index faa6d167065ce..2ab9b618d617b 100644 --- a/src/libstd/num/u8.rs +++ b/src/libstd/num/u8.rs @@ -15,4 +15,4 @@ pub use core::u8::{BITS, BYTES, MIN, MAX}; -uint_module!(u8) +uint_module! { u8 } diff --git a/src/libstd/num/uint.rs b/src/libstd/num/uint.rs index a425aab3aa10c..98569b59dae74 100644 --- a/src/libstd/num/uint.rs +++ b/src/libstd/num/uint.rs @@ -15,4 +15,4 @@ pub use core::uint::{BITS, BYTES, MIN, MAX}; -uint_module!(uint) +uint_module! { uint } diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs index 7b79e53520140..aa91daf4e63e8 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 @@ -139,4 +139,4 @@ mod tests { } } -)) +) } diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index 3e013ba20c462..0150cb1f217f1 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -445,7 +445,7 @@ mod tests { use str; use str::StrPrelude; - macro_rules! t( + macro_rules! t { (s: $path:expr, $exp:expr) => ( { let path = $path; @@ -458,7 +458,7 @@ mod tests { assert!(path.as_vec() == $exp); } ) - ) + } #[test] fn test_paths() { @@ -531,14 +531,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().as_slice() == $exp); } ) - ) + } t!("foo", display, "foo"); t!(b"foo\x80", display, "foo\uFFFD"); t!(b"foo\xFFbar", display, "foo\uFFFDbar"); @@ -561,7 +561,7 @@ mod tests { assert!(mo.as_slice() == $exp); } ) - ) + ); t!("foo", "foo"); t!(b"foo\x80", "foo\uFFFD"); @@ -583,7 +583,7 @@ mod tests { assert!(f.as_slice() == $expf); } ) - ) + ); t!(b"foo", "foo", "foo"); t!(b"foo/bar", "foo/bar", "bar"); @@ -621,7 +621,7 @@ mod tests { } } ); - ) + ); t!(v: b"a/b/c", filename, Some(b"c")); t!(v: b"a/b/c\xFF", filename, Some(b"c\xFF")); @@ -696,7 +696,7 @@ mod tests { assert!(p1 == p2.join(join)); } ) - ) + ); t!(s: "a/b/c", ".."); t!(s: "/a/b/c", "d"); @@ -715,7 +715,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"); @@ -742,7 +742,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"); @@ -772,7 +772,7 @@ mod tests { assert!(result == $right); } ) - ) + ); t!(b: b"a/b/c", b"a/b", true); t!(b: b"a", b".", true); @@ -820,7 +820,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"); @@ -847,7 +847,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"); @@ -931,7 +931,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"); @@ -989,7 +989,7 @@ mod tests { } } ) - ) + ); let no: Option<&'static str> = None; t!(v: Path::new(b"a/b/c"), Some(b"c"), b"a/b", Some(b"c"), no); @@ -1037,7 +1037,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); @@ -1058,7 +1058,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); @@ -1099,7 +1099,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); @@ -1132,7 +1132,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")); @@ -1194,7 +1194,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"]); @@ -1226,7 +1226,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 f31ffdab17b61..04633e9d7061c 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -1119,7 +1119,7 @@ mod tests { use super::*; use super::parse_prefix; - macro_rules! t( + macro_rules! t { (s: $path:expr, $exp:expr) => ( { let path = $path; @@ -1132,7 +1132,7 @@ mod tests { assert!(path.as_vec() == $exp); } ) - ) + } #[test] fn test_parse_prefix() { @@ -1146,7 +1146,7 @@ mod tests { "parse_prefix(\"{}\"): expected {}, found {}", path, exp, res); } ) - ) + ); t!("\\\\SERVER\\share\\foo", Some(UNCPrefix(6,5))); t!("\\\\", None); @@ -1345,7 +1345,7 @@ mod tests { assert_eq!(f.as_slice(), $expf); } ) - ) + ); t!("foo", "foo", "foo"); t!("foo\\bar", "foo\\bar", "bar"); @@ -1381,7 +1381,7 @@ mod tests { } } ) - ) + ); t!(v: b"a\\b\\c", filename, Some(b"c")); t!(s: "a\\b\\c", filename_str, "c"); @@ -1493,7 +1493,7 @@ mod tests { assert!(p1 == p2.join(join)); } ) - ) + ); t!(s: "a\\b\\c", ".."); t!(s: "\\a\\b\\c", "d"); @@ -1526,7 +1526,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"); @@ -1584,7 +1584,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"); @@ -1619,7 +1619,7 @@ mod tests { assert!(result == $right); } ) - ) + ); t!(s: "a\\b\\c", "a\\b", true); t!(s: "a", ".", true); @@ -1696,7 +1696,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"); @@ -1725,7 +1725,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"); @@ -1751,7 +1751,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"); @@ -1844,7 +1844,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"); @@ -1903,7 +1903,7 @@ mod tests { } } ) - ) + ); let no: Option<&'static str> = None; t!(v: Path::new(b"a\\b\\c"), Some(b"c"), b"a\\b", Some(b"c"), no); @@ -1958,7 +1958,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); @@ -1991,7 +1991,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); @@ -2090,7 +2090,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); @@ -2127,7 +2127,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")); @@ -2262,7 +2262,7 @@ mod tests { assert_eq!(comps, exp); } ); - ) + ); t!(s: b"a\\b\\c", ["a", "b", "c"]); t!(s: "a\\b\\c", ["a", "b", "c"]); @@ -2318,7 +2318,7 @@ mod tests { assert_eq!(comps, exp); } ) - ) + ); t!(s: "a\\b\\c", [b"a", b"b", b"c"]); t!(s: ".", [b"."]); @@ -2336,7 +2336,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 08eb7350bcf38..de01724fbd4f2 100644 --- a/src/libstd/rand/mod.rs +++ b/src/libstd/rand/mod.rs @@ -337,7 +337,7 @@ pub struct TaskRng { /// explicitly select an RNG, e.g. `IsaacRng` or `Isaac64Rng`. pub fn task_rng() -> TaskRng { // used to make space in TLS for a random number generator - local_data_key!(TASK_RNG_KEY: Rc>) + local_data_key!(TASK_RNG_KEY: Rc>); match TASK_RNG_KEY.get() { None => { diff --git a/src/libstd/rt/backtrace.rs b/src/libstd/rt/backtrace.rs index 11257d506b0e0..0f668c816a0a3 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$" => "@", @@ -939,12 +940,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); @@ -1009,11 +1010,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.to_string()); - }) ) + }) } #[test] fn demangle() { diff --git a/src/libstd/sync/future.rs b/src/libstd/sync/future.rs index e37d1f8387796..7ac4c53255239 100644 --- a/src/libstd/sync/future.rs +++ b/src/libstd/sync/future.rs @@ -215,7 +215,7 @@ mod test { fn test_dropped_future_doesnt_panic() { struct Bomb(Sender); - local_data_key!(LOCAL: Bomb) + local_data_key!(LOCAL: Bomb); impl Drop for Bomb { fn drop(&mut self) { diff --git a/src/libstd/sys/unix/mod.rs b/src/libstd/sys/unix/mod.rs index 4db9e8a9df8b5..272de837b4b46 100644 --- a/src/libstd/sys/unix/mod.rs +++ b/src/libstd/sys/unix/mod.rs @@ -23,14 +23,14 @@ 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: ::rt::mutex::NATIVE_MUTEX_INIT, chan: ::cell::UnsafeCell { value: 0 as *mut Sender<$m> }, signal: ::cell::UnsafeCell { value: 0 }, initialized: ::cell::UnsafeCell { value: false }, }; -) ) +) } pub mod c; pub mod fs; diff --git a/src/libstd/sys/unix/process.rs b/src/libstd/sys/unix/process.rs index 81bc138ca9195..af96ed970b237 100644 --- a/src/libstd/sys/unix/process.rs +++ b/src/libstd/sys/unix/process.rs @@ -28,7 +28,7 @@ use sys_common::{AsFileDesc, mkerr_libc, timeout}; pub use sys_common::ProcessConfig; -helper_init!(static HELPER: Helper) +helper_init! { static HELPER: Helper } /// 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 6ebbedb8e9036..79a6a871f8dd4 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) +helper_init! { static HELPER: Helper } pub trait Callback { fn call(&mut self); diff --git a/src/libstd/sys/windows/c.rs b/src/libstd/sys/windows/c.rs index b8e9b1dca3abc..1b28cbd4058b3 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 f316b2d8493f4..2b92a7b9e7ed4 100644 --- a/src/libstd/sys/windows/mod.rs +++ b/src/libstd/sys/windows/mod.rs @@ -24,14 +24,14 @@ 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: ::rt::mutex::NATIVE_MUTEX_INIT, chan: ::cell::UnsafeCell { value: 0 as *mut Sender<$m> }, signal: ::cell::UnsafeCell { value: 0 }, initialized: ::cell::UnsafeCell { value: false }, }; -) ) +) } pub mod c; pub mod fs; diff --git a/src/libstd/sys/windows/timer.rs b/src/libstd/sys/windows/timer.rs index 9af3a7c8b6e01..e2f9e2a9201c3 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) +helper_init! { static HELPER: Helper } pub trait Callback { fn call(&mut self); diff --git a/src/libstd/time/duration.rs b/src/libstd/time/duration.rs index 39ca3128ccb2b..a9f3fc0202620 100644 --- a/src/libstd/time/duration.rs +++ b/src/libstd/time/duration.rs @@ -37,9 +37,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/libsync/comm/mod.rs b/src/libsync/comm/mod.rs index 2a9a19a7fa68a..3ab83efa23272 100644 --- a/src/libsync/comm/mod.rs +++ b/src/libsync/comm/mod.rs @@ -140,7 +140,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; //! } //! } @@ -164,7 +164,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; //! } //! } @@ -338,7 +338,7 @@ use rustrt::task::{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)] @@ -362,7 +362,7 @@ macro_rules! test ( } } ) -) +} mod oneshot; mod select; @@ -1078,70 +1078,70 @@ mod test { } } - test!(fn smoke() { + test! { fn smoke() { let (tx, rx) = channel::(); 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::(); 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::(); spawn(proc() { tx.send(1); }); assert_eq!(rx.recv(), 1); - }) + } } - test!(fn smoke_port_gone() { + test! { fn smoke_port_gone() { let (tx, rx) = channel::(); 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::(); 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::(); 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::(); spawn(proc() { 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::(); let tx2 = tx.clone(); spawn(proc() { @@ -1151,32 +1151,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::(); 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::(); spawn(proc() { tx.send(1); tx.send(1); }); loop { rx.recv(); } - } #[should_fail]) + } #[should_fail] } - test!(fn stress() { + test! { fn stress() { let (tx, rx) = channel::(); spawn(proc() { for _ in range(0u, 10000) { tx.send(1i); } @@ -1184,9 +1184,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::(); @@ -1211,7 +1211,7 @@ mod test { } drop(tx); drx.recv(); - }) + } } #[test] fn send_from_outside_runtime() { @@ -1273,26 +1273,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::(); 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::(); 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::>(); 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(proc() { let (tx, rx) = channel::(); @@ -1301,67 +1301,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::>(); 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::(); 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::(); 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::(); 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::(); 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::(); - 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::(); 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::(); 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::>(); spawn(proc() { 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::>(); spawn(proc() { drop(tx); @@ -1370,9 +1370,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::(); spawn(proc() { @@ -1380,9 +1380,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::(); spawn(proc() { @@ -1392,9 +1392,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::(); spawn(proc() { @@ -1409,9 +1409,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(proc() { @@ -1421,9 +1421,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(); @@ -1448,16 +1448,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) { @@ -1470,9 +1470,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::(); let (total_tx, total_rx) = channel::(); @@ -1489,9 +1489,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::(); let (count_tx, count_rx) = channel(); @@ -1513,9 +1513,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::(); let (tx2, rx2) = channel::<()>(); let (tx3, rx3) = channel::<()>(); @@ -1536,11 +1536,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(proc() { @@ -1558,9 +1558,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 std::rt::thread::Thread; let (tx, rx) = channel(); @@ -1573,9 +1573,9 @@ mod test { rx.recv(); } t.join(); - }) + } } - test!(fn try_recvs_off_the_runtime() { + test! { fn try_recvs_off_the_runtime() { use std::rt::thread::Thread; let (tx, rx) = channel(); @@ -1596,7 +1596,7 @@ mod test { } t.join(); pdone.recv(); - }) + } } } #[cfg(test)] @@ -1611,57 +1611,57 @@ mod sync_tests { } } - test!(fn smoke() { + test! { fn smoke() { let (tx, rx) = sync_channel::(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::(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::(0); spawn(proc() { tx.send(1); }); assert_eq!(rx.recv(), 1); - }) + } } - test!(fn smoke_port_gone() { + test! { fn smoke_port_gone() { let (tx, rx) = sync_channel::(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::(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::(0); spawn(proc() { 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::(0); let tx2 = tx.clone(); spawn(proc() { @@ -1671,32 +1671,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::(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::(0); spawn(proc() { tx.send(1); tx.send(1); }); loop { rx.recv(); } - } #[should_fail]) + } #[should_fail] } - test!(fn stress() { + test! { fn stress() { let (tx, rx) = sync_channel::(0); spawn(proc() { for _ in range(0u, 10000) { tx.send(1); } @@ -1704,9 +1704,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::(0); @@ -1731,28 +1731,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::(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::(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::>(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(proc() { let (tx, rx) = sync_channel::(0); @@ -1761,72 +1761,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::>(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::(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::(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::(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::(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::(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::(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::(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::(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::>(0); spawn(proc() { 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::>(0); spawn(proc() { drop(tx); @@ -1835,9 +1835,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::(0); spawn(proc() { @@ -1845,9 +1845,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::(0); spawn(proc() { @@ -1857,9 +1857,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::(0); spawn(proc() { @@ -1874,9 +1874,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::>(0); spawn(proc() { @@ -1886,9 +1886,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::>(0); @@ -1913,16 +1913,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) { @@ -1935,9 +1935,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::(0); let (total_tx, total_rx) = sync_channel::(0); @@ -1954,9 +1954,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::(0); let (count_tx, count_rx) = sync_channel(0); @@ -1978,9 +1978,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::(1); let (tx2, rx2) = sync_channel::<()>(1); let (tx3, rx3) = sync_channel::<()>(1); @@ -2001,11 +2001,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(proc() { @@ -2023,9 +2023,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 std::rt::thread::Thread; let (tx, rx) = sync_channel::<()>(0); @@ -2046,28 +2046,28 @@ mod sync_tests { } t.join(); pdone.recv(); - }) + } } - test!(fn send_opt1() { + test! { fn send_opt1() { let (tx, rx) = sync_channel::(0); spawn(proc() { rx.recv(); }); assert_eq!(tx.send_opt(1), Ok(())); - }) + } } - test!(fn send_opt2() { + test! { fn send_opt2() { let (tx, rx) = sync_channel::(0); spawn(proc() { drop(rx); }); assert_eq!(tx.send_opt(1), Err(1)); - }) + } } - test!(fn send_opt3() { + test! { fn send_opt3() { let (tx, rx) = sync_channel::(1); assert_eq!(tx.send_opt(1), Ok(())); spawn(proc() { drop(rx); }); assert_eq!(tx.send_opt(1), Err(1)); - }) + } } - test!(fn send_opt4() { + test! { fn send_opt4() { let (tx, rx) = sync_channel::(0); let tx2 = tx.clone(); let (done, donerx) = channel(); @@ -2083,36 +2083,36 @@ mod sync_tests { drop(rx); donerx.recv(); donerx.recv(); - }) + } } - test!(fn try_send1() { + test! { fn try_send1() { let (tx, _rx) = sync_channel::(0); assert_eq!(tx.try_send(1), Err(Full(1))); - }) + } } - test!(fn try_send2() { + test! { fn try_send2() { let (tx, _rx) = sync_channel::(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::(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::(0); spawn(proc() { 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); @@ -2129,5 +2129,5 @@ mod sync_tests { for _ in range(0u, 100) { repro() } - }) + } } } diff --git a/src/libsync/comm/select.rs b/src/libsync/comm/select.rs index f826664308429..40c7c2fc5d387 100644 --- a/src/libsync/comm/select.rs +++ b/src/libsync/comm/select.rs @@ -347,58 +347,58 @@ mod test { }) } - test!(fn smoke() { + test! { fn smoke() { let (tx1, rx1) = channel::(); let (tx2, rx2) = channel::(); 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::(); let (_tx2, rx2) = channel::(); let (_tx3, rx3) = channel::(); let (_tx4, rx4) = channel::(); let (tx5, rx5) = channel::(); 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::(); let (tx2, rx2) = channel::(); 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::(); let (_tx2, rx2) = channel::(); let (tx3, rx3) = channel::(); @@ -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::(); let (tx2, rx2) = channel::(); 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::(); let (tx2, rx2) = channel::(); @@ -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::(); let (_tx2, rx2) = channel::(); 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::(); let (_tx2, rx2) = channel::(); 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(proc() { @@ -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::(1); tx.send(1); select! { n = rx.recv() => { assert_eq!(n, 1); } } - }) + } } - test!(fn sync2() { + test! { fn sync2() { let (tx, rx) = sync_channel::(0); spawn(proc() { 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::(0); let (tx2, rx2): (Sender, Receiver) = channel(); spawn(proc() { tx1.send(1); }); @@ -707,5 +707,5 @@ mod test { assert_eq!(rx1.recv(), 1); } } - }) + } } } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 15e14902727f5..3f2901135a57e 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -32,6 +32,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_::*; @@ -571,8 +572,20 @@ pub enum Stmt_ { /// Expr with trailing semi-colon (may have any type): StmtSemi(P, NodeId), - /// bool: is there a trailing semi-colon? - StmtMac(Mac, bool), + StmtMac(Mac, MacStmtStyle), +} + +#[deriving(Clone, 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 30cdecbc85199..681ee50448a16 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -733,16 +733,16 @@ 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_fn_style,ast::FnStyle,MethDecl(_,_,_,_,fn_style,_,_,_),fn_style) - 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_fn_style,ast::FnStyle,MethDecl(_,_,_,_,fn_style,_,_,_),fn_style } + 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 12a3bd8990194..6bd05bd3bcfd1 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -28,7 +28,7 @@ use ptr::P; use std::collections::HashSet; use std::collections::BitvSet; -local_data_key!(used_attrs: BitvSet) +local_data_key! { used_attrs: BitvSet } pub fn mark_used(attr: &Attribute) { let mut used = used_attrs.replace(None).unwrap_or_else(|| BitvSet::new()); @@ -167,7 +167,7 @@ pub fn mk_word_item(name: InternedString) -> P { P(dummy_spanned(MetaWord(name))) } -local_data_key!(next_attr_id: uint) +local_data_key! { next_attr_id: uint } pub fn mk_attr_id() -> AttrId { let id = next_attr_id.replace(None).unwrap_or(0); diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 7d849ddf1c1ad..21882d1c5e538 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -287,7 +287,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 b4bf793d4e197..3107508a96a5c 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 d077fbd7bf00f..f4a166ca53c9c 100644 --- a/src/libsyntax/diagnostics/plugin.rs +++ b/src/libsyntax/diagnostics/plugin.rs @@ -18,8 +18,12 @@ use ext::build::AstBuilder; use parse::token; use ptr::P; -local_data_key!(registered_diagnostics: RefCell>>) -local_data_key!(used_diagnostics: RefCell>) +local_data_key! { + registered_diagnostics: RefCell>> +} +local_data_key! { + used_diagnostics: RefCell> +} fn with_registered_diagnostics(f: |&mut HashMap>| -> T) -> T { match registered_diagnostics.get() { diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 081456bebe19c..b9f0289c85972 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; @@ -358,7 +359,7 @@ fn expand_loop_block(loop_block: P, // 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; @@ -366,7 +367,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, fld: &mut MacroExpander) @@ -633,8 +634,8 @@ pub fn expand_item_mac(it: P, 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> { - 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, @@ -650,7 +651,7 @@ fn expand_stmt(s: Stmt, fld: &mut MacroExpander) -> SmallVector> { 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 { @@ -1320,7 +1321,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( @@ -1334,7 +1335,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( @@ -1346,7 +1347,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( @@ -1398,13 +1399,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() ); } @@ -1447,16 +1448,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) ); @@ -1484,7 +1485,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) @@ -1494,7 +1495,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)), @@ -1507,8 +1508,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), @@ -1523,8 +1524,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)), @@ -1538,8 +1539,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) @@ -1549,7 +1550,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) @@ -1559,7 +1560,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), @@ -1570,7 +1571,7 @@ mod test { // expands to fn f(){(proc(x_1 : int) {(x_2 + x_1)})(3);} #[test] fn closure_arg_hygiene_2(){ run_renaming_test( - &("macro_rules! inject_x (()=>(x)) + &("macro_rules! inject_x (()=>(x)); fn f(){ (proc(x : int){(inject_x!() + x)})(3); }", vec!(vec!(1)), true), @@ -1580,9 +1581,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()); } @@ -1593,7 +1594,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) @@ -1673,9 +1674,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 b50a4690e420b..38a201151fdee 100644 --- a/src/libsyntax/ext/mtwt.rs +++ b/src/libsyntax/ext/mtwt.rs @@ -105,7 +105,7 @@ pub fn apply_renames(renames: &RenameList, ctxt: SyntaxContext) -> SyntaxContext /// Fetch the SCTable from TLS, create one if it doesn't yet exist. pub fn with_sctable(op: |&SCTable| -> T) -> T { - local_data_key!(sctable_key: Rc) + local_data_key!(sctable_key: Rc); match sctable_key.get() { Some(ts) => op(&**ts), @@ -165,7 +165,7 @@ type ResolveTable = HashMap<(Name,SyntaxContext),Name>; // okay, I admit, putting this in TLS is not so nice: // fetch the SCTable from TLS, create one if it doesn't yet exist. fn with_resolve_table_mut(op: |&mut ResolveTable| -> T) -> T { - local_data_key!(resolve_table_key: Rc>) + local_data_key!(resolve_table_key: Rc>); match resolve_table_key.get() { Some(ts) => op(&mut *ts.borrow_mut()), diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index ec69175707746..8ca82b0f55d14 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -104,7 +104,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 { @@ -129,7 +129,7 @@ pub mod rt { } } ); - ) + } fn slice_to_source<'a, T: ToSource>(sep: &'static str, xs: &'a [T]) -> String { xs.iter() @@ -148,7 +148,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 { @@ -162,7 +162,7 @@ pub mod rt { } } ) - ) + } impl ToSource for ast::Ident { fn to_source(&self) -> String { @@ -176,18 +176,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, item_to_string) - impl_to_source!(P, method_to_string) - impl_to_source!(P, stmt_to_string) - impl_to_source!(P, expr_to_string) - impl_to_source!(P, pat_to_string) - impl_to_source!(ast::Arm, arm_to_string) - impl_to_source_slice!(ast::Ty, ", ") - impl_to_source_slice!(P, "\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, item_to_string } + impl_to_source! { P, method_to_string } + impl_to_source! { P, stmt_to_string } + impl_to_source! { P, expr_to_string } + impl_to_source! { P, pat_to_string } + impl_to_source! { ast::Arm, arm_to_string } + impl_to_source_slice! { ast::Ty, ", " } + impl_to_source_slice! { P, "\n\n" } impl ToSource for ast::Attribute_ { fn to_source(&self) -> String { @@ -248,7 +248,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 { @@ -276,23 +276,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 { @@ -300,9 +300,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 { @@ -310,36 +310,36 @@ pub mod rt { } } ) - ) - - impl_to_tokens!(ast::Ident) - impl_to_tokens!(P) - impl_to_tokens!(P) - impl_to_tokens!(ast::Arm) - impl_to_tokens!(P) - impl_to_tokens_lifetime!(&'a [P]) - impl_to_tokens!(ast::Ty) - impl_to_tokens_lifetime!(&'a [ast::Ty]) - impl_to_tokens!(Generics) - impl_to_tokens!(P) - impl_to_tokens!(P) - 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 } + impl_to_tokens! { P } + impl_to_tokens! { ast::Arm } + impl_to_tokens! { P } + impl_to_tokens_lifetime! { &'a [P] } + impl_to_tokens! { ast::Ty } + impl_to_tokens_lifetime! { &'a [ast::Ty] } + impl_to_tokens! { Generics } + impl_to_tokens! { P } + impl_to_tokens! { P } + 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; diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index b3137ff5f7e52..4615f51c6b577 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -1461,7 +1461,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; @@ -1473,7 +1473,7 @@ mod test { } } ) - ) + } // make sure idents get transformed everywhere #[test] fn ident_transformation () { @@ -1499,6 +1499,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 50b1a2204b041..5af34d771c7a9 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}; @@ -145,7 +146,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 { @@ -183,10 +184,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 { @@ -283,7 +284,7 @@ macro_rules! maybe_whole ( } } ) -) +} fn maybe_append(mut lhs: Vec, rhs: Option>) @@ -3635,21 +3636,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.token == 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( @@ -3658,7 +3670,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()); @@ -3778,43 +3789,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(); @@ -3829,7 +3843,7 @@ impl<'a> Parser<'a> { } _ => { stmts.push(P(Spanned { - node: StmtMac(m, semi), + node: StmtMac(m, style), span: span })); } @@ -3868,6 +3882,43 @@ impl<'a> Parser<'a> { }) } + fn handle_expression_like_statement( + &mut self, + e: P, + stmt_id: NodeId, + span: Span, + stmts: &mut Vec>, + last_block_expr: &mut Option>) { + // 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) @@ -4453,6 +4504,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 abi = if self.eat_keyword(keywords::Extern) { @@ -5582,6 +5636,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 298328d73efb0..1d73e4fdb105a 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -555,7 +555,7 @@ pub type IdentInterner = StrInterner; // fresh one. // FIXME(eddyb) #8726 This should probably use a task-local reference. pub fn get_ident_interner() -> Rc { - local_data_key!(key: Rc<::parse::token::IdentInterner>) + local_data_key!(key: Rc<::parse::token::IdentInterner>); match key.get() { Some(interner) => interner.clone(), None => { diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index e6e0c33a42dbd..927d272d37423 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -395,12 +395,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 @@ -421,7 +421,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 { @@ -987,6 +987,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()); } } @@ -1247,6 +1248,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() } } @@ -1319,11 +1321,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, ";")), } } } @@ -1450,15 +1457,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), + } } } } @@ -1883,7 +1899,7 @@ impl<'a> State<'a> { try!(self.print_string(a.clobbers.get(), ast::CookedStr)); 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)); @@ -2168,7 +2184,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)) } @@ -2256,7 +2272,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 9eb7216fba0bf..aca5dc541def5 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 ab6756ffce3cf..31d057dab2951 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) { diff --git a/src/test/auxiliary/lint_group_plugin_test.rs b/src/test/auxiliary/lint_group_plugin_test.rs index 4790ae11b2107..add54ed01e00e 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 e18cef6d13624..6c78cdce28ac4 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 0be2f31e2827f..82af18b189b68 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 56053a0cd7520..ad3e72f5fa221 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 1c26ac26d7cf3..b82cfcbc8fcb2 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 1e8c15f6b44cb..9b4b1ceb5c1e7 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 24bd26b028813..b5b9dbd4d493f 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -30,7 +30,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 d8f771cfb5a73..0a004c101ee4f 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/core-tls-store-pointer.rs b/src/test/compile-fail/core-tls-store-pointer.rs index d77c552be034c..313c13b04c5b7 100644 --- a/src/test/compile-fail/core-tls-store-pointer.rs +++ b/src/test/compile-fail/core-tls-store-pointer.rs @@ -10,7 +10,7 @@ // Testing that we can't store a reference in task-local storage -local_data_key!(key: Box<&int>) +local_data_key!(key: Box<&int>); //~^ ERROR missing lifetime specifier fn main() {} diff --git a/src/test/compile-fail/gated-macro-rules.rs b/src/test/compile-fail/gated-macro-rules.rs index 7f771c7241681..ae2f03fd5f798 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 67a7cdf102481..22ac2eb1f7d5d 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-6596.rs b/src/test/compile-fail/issue-6596.rs index 267b30677a18f..3222b2cd53719 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 f2ea2ca96a59d..e92faa6bdaf6e 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 94386858d2949..71b656d0bbb57 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 3e731a2d2fed4..94ef7aed1553e 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 ec0e656cc2927..0a005a0f3c585 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 { - local_data_key!(baz: f64) + local_data_key!(baz: f64); } fn main() { diff --git a/src/test/compile-fail/macro-match-nonterminal.rs b/src/test/compile-fail/macro-match-nonterminal.rs index d6d32d94a2956..150187aa07d3c 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 e41f1bd369a88..6d59c203d14bd 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 similarity index 82% rename from src/test/compile-fail/macro-invocation-dot-help.rs rename to src/test/compile-fail/macros-no-semicolon-items.rs index bd45b76dd5afc..f1f31a99e970a 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 0000000000000..22c1aa97c66a2 --- /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 or the MIT license +// , 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 `;`, `}`, 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 dc41e2e02a846..747b4815ac2ae 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 similarity index 94% rename from src/test/compile-fail/pattern-macro-hygeine.rs rename to src/test/compile-fail/pattern-macro-hygiene.rs index 0b6a14c0fc931..3322fecf950c1 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/rustc-diagnostics-1.rs b/src/test/compile-fail/rustc-diagnostics-1.rs index 55d836092fa71..ce9d6828e9b9c 100644 --- a/src/test/compile-fail/rustc-diagnostics-1.rs +++ b/src/test/compile-fail/rustc-diagnostics-1.rs @@ -10,8 +10,8 @@ #![feature(rustc_diagnostic_macros)] -__register_diagnostic!(E0001) -__register_diagnostic!(E0003) +__register_diagnostic!(E0001); +__register_diagnostic!(E0003); fn main() { __diagnostic_used!(E0002); @@ -24,5 +24,5 @@ fn main() { //~^ WARNING diagnostic code E0001 already used } -__build_diagnostic_array!(DIAGNOSTICS) +__build_diagnostic_array!(DIAGNOSTICS); //~^ WARN diagnostic code E0003 never used diff --git a/src/test/compile-fail/rustc-diagnostics-2.rs b/src/test/compile-fail/rustc-diagnostics-2.rs index c4e011bcea042..65ddde1bb1503 100644 --- a/src/test/compile-fail/rustc-diagnostics-2.rs +++ b/src/test/compile-fail/rustc-diagnostics-2.rs @@ -10,11 +10,11 @@ #![feature(rustc_diagnostic_macros)] -__register_diagnostic!(E0001) -__register_diagnostic!(E0001) +__register_diagnostic!(E0001); +__register_diagnostic!(E0001); //~^ ERROR diagnostic code E0001 already registered fn main() { } -__build_diagnostic_array!(DIAGNOSTICS) +__build_diagnostic_array!(DIAGNOSTICS); diff --git a/src/test/compile-fail/rustc-diagnostics-3.rs b/src/test/compile-fail/rustc-diagnostics-3.rs index d160664a48c78..765851143e701 100644 --- a/src/test/compile-fail/rustc-diagnostics-3.rs +++ b/src/test/compile-fail/rustc-diagnostics-3.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -__register_diagnostic!(E0001) +__register_diagnostic!(E0001); //~^ ERROR macro undefined: '__register_diagnostic!' fn main() { @@ -16,5 +16,5 @@ fn main() { //~^ ERROR macro undefined: '__diagnostic_used!' } -__build_diagnostic_array!(DIAGNOSTICS) +__build_diagnostic_array!(DIAGNOSTICS); //~^ ERROR macro undefined: '__build_diagnostic_array!' 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 c5cfabd74e134..08c9f8b4aa7d5 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 35c6970592565..42f6914e081a3 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 f4dba3f6c7f5b..cac805189b82e 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 d8dfb433e6d49..e1580d4006c12 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 218216e3a34ea..52b5c040d86cd 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 318305b7ec38e..f63ab7fb7c9a5 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 18e35e72c02fc..0d56f28e8fae7 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 59f7eda41610c..a0cca8f256b3c 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 c3ba7ca12d02e..9f2fe155cdf95 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 16212b5f52995..01c96b7563a75 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 378fd4a222e38..a11b34e476275 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 adf1d1e614acd..0cd25bc2c719b 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 d8bb61477a0c8..c69b66f4dbd76 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 9f2aaa4d00577..d4ea05004a064 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 bf84721c98440..5826a5f9919f4 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 ff086355f9db4..60011281d425e 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 b61263d17542a..a6746f452065d 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 7b9fa3bcf7fc4..5eed791e0582d 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 afcd154f6478b..95a5f1003b6e3 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 0daa405fc6bb6..7b4d376993aa9 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-attributes.rs b/src/test/run-pass/macro-attributes.rs index e09ca68f6d198..4df3b94c1c9d1 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 0000000000000..fcf2dff66a5f7 --- /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 or the MIT license +// , 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 0e7e6e247f5ab..5c95f67257cd5 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 672efa68398ec..45712f5c62a6e 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, { 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 847024d42baca..4c124d85eee3a 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-local-data-key.rs b/src/test/run-pass/macro-local-data-key.rs index 730b0b08d451a..0c7c91a4602ce 100644 --- a/src/test/run-pass/macro-local-data-key.rs +++ b/src/test/run-pass/macro-local-data-key.rs @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -local_data_key!(foo: int) +local_data_key!(foo: int); mod bar { - local_data_key!(pub baz: f64) + local_data_key!(pub baz: f64); } pub fn main() { diff --git a/src/test/run-pass/macro-meta-items.rs b/src/test/run-pass/macro-meta-items.rs index 91f67abd8af4a..4b01fdf816216 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 b5400edb41fc4..aa6de9acf6b88 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 d56d211b606eb..4fb130f0e1314 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 2a00e5b861602..9367a231d4f65 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 561933d759927..c47b5e1108901 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 3e89466bc0f76..496cef9d644e2 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) -> uint { match c { diff --git a/src/test/run-pass/macro-stmt.rs b/src/test/run-pass/macro-stmt.rs index 49e146cb0cf88..7be49e1acd844 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 aaa2be66ff44e..631fc8666713d 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 4a191b2fa66ce..3ac0d47e61a63 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 f9b1b951cf03d..f69ac673ee393 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 b6834f8026d19..90639dd72d73b 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 c6dd373685794..9151564b3407b 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 7c6ad45a9efe1..c0359a3418698 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/running-with-no-runtime.rs b/src/test/run-pass/running-with-no-runtime.rs index 942542a6bcdbd..bcec8cc75045a 100644 --- a/src/test/run-pass/running-with-no-runtime.rs +++ b/src/test/run-pass/running-with-no-runtime.rs @@ -15,7 +15,7 @@ use std::os; use std::str; use std::rt::unwind::try; -local_data_key!(foo: int) +local_data_key!(foo: int); #[start] fn start(argc: int, argv: *const *const u8) -> int { diff --git a/src/test/run-pass/slice-2.rs b/src/test/run-pass/slice-2.rs index 768c28cb8ded7..f03b4609637a9 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 = 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 = 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 89add2af44072..e3e33e52639da 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 1b08955adfce8..4dec227d52020 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 d06e3dc0633fa..2c784dade5711 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];