librustc: Always parse `macro!()`/`macro![]` as expressions if not

followed by a semicolon.

This allows code like `vec![1i, 2, 3].len();` to work.

This breaks code that uses macros as statements without putting
semicolons after them, such as:

    fn main() {
        ...
        assert!(a == b)
        assert!(c == d)
        println(...);
    }

It also breaks code that uses macros as items without semicolons:

    local_data_key!(foo)

    fn main() {
        println("hello world")
    }

Add semicolons to fix this code. Those two examples can be fixed as
follows:

    fn main() {
        ...
        assert!(a == b);
        assert!(c == d);
        println(...);
    }

    local_data_key!(foo);

    fn main() {
        println("hello world")
    }

RFC #378.

Closes #18635.

[breaking-change]
This commit is contained in:
Patrick Walton 2014-11-14 09:18:10 -08:00 committed by Jorge Aparicio
parent c0b2885ee1
commit ddb2466f6a
222 changed files with 2330 additions and 2039 deletions

View File

@ -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
}

View File

@ -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))

View File

@ -2083,7 +2083,7 @@ mod tests {
let bools = vec![true, false, true, true];
let bitv: Bitv = bools.iter().map(|n| *n).collect();
assert_eq!(bitv.iter().collect::<Vec<bool>>(), bools)
assert_eq!(bitv.iter().collect::<Vec<bool>>(), bools);
let long = Vec::from_fn(10000, |i| i % 2 == 0);
let bitv: Bitv = long.iter().map(|n| *n).collect();
@ -2112,8 +2112,8 @@ mod tests {
for &b in bools.iter() {
for &l in lengths.iter() {
let bitset = BitvSet::from_bitv(Bitv::with_capacity(l, b));
assert_eq!(bitset.contains(&1u), b)
assert_eq!(bitset.contains(&(l-1u)), b)
assert_eq!(bitset.contains(&1u), b);
assert_eq!(bitset.contains(&(l-1u)), b);
assert!(!bitset.contains(&l))
}
}
@ -2321,12 +2321,12 @@ mod tests {
assert!(!a.is_disjoint(&d));
assert!(!d.is_disjoint(&a));
assert!(a.is_disjoint(&b))
assert!(a.is_disjoint(&c))
assert!(b.is_disjoint(&a))
assert!(b.is_disjoint(&c))
assert!(c.is_disjoint(&a))
assert!(c.is_disjoint(&b))
assert!(a.is_disjoint(&b));
assert!(a.is_disjoint(&c));
assert!(b.is_disjoint(&a));
assert!(b.is_disjoint(&c));
assert!(c.is_disjoint(&a));
assert!(c.is_disjoint(&b));
}
#[test]

View File

@ -411,7 +411,7 @@ mod test {
assert!(e1.is_subset(&e2));
assert!(e2.is_superset(&e1));
assert!(!e3.is_superset(&e2))
assert!(!e3.is_superset(&e2));
assert!(!e2.is_superset(&e3))
}
@ -438,23 +438,23 @@ mod test {
let mut e1: EnumSet<Foo> = EnumSet::new();
let elems: ::vec::Vec<Foo> = e1.iter().collect();
assert!(elems.is_empty())
assert!(elems.is_empty());
e1.insert(A);
let elems: ::vec::Vec<_> = e1.iter().collect();
assert_eq!(vec![A], elems)
assert_eq!(vec![A], elems);
e1.insert(C);
let elems: ::vec::Vec<_> = e1.iter().collect();
assert_eq!(vec![A,C], elems)
assert_eq!(vec![A,C], elems);
e1.insert(C);
let elems: ::vec::Vec<_> = e1.iter().collect();
assert_eq!(vec![A,C], elems)
assert_eq!(vec![A,C], elems);
e1.insert(B);
let elems: ::vec::Vec<_> = e1.iter().collect();
assert_eq!(vec![A,B,C], elems)
assert_eq!(vec![A,B,C], elems);
}
///////////////////////////////////////////////////////////////////////////
@ -472,35 +472,35 @@ mod test {
let e_union = e1 | e2;
let elems: ::vec::Vec<_> = e_union.iter().collect();
assert_eq!(vec![A,B,C], elems)
assert_eq!(vec![A,B,C], elems);
let e_intersection = e1 & e2;
let elems: ::vec::Vec<_> = e_intersection.iter().collect();
assert_eq!(vec![C], elems)
assert_eq!(vec![C], elems);
// Another way to express intersection
let e_intersection = e1 - (e1 - e2);
let elems: ::vec::Vec<_> = e_intersection.iter().collect();
assert_eq!(vec![C], elems)
assert_eq!(vec![C], elems);
let e_subtract = e1 - e2;
let elems: ::vec::Vec<_> = e_subtract.iter().collect();
assert_eq!(vec![A], elems)
assert_eq!(vec![A], elems);
// Bitwise XOR of two sets, aka symmetric difference
let e_symmetric_diff = e1 ^ e2;
let elems: ::vec::Vec<_> = e_symmetric_diff.iter().collect();
assert_eq!(vec![A,B], elems)
assert_eq!(vec![A,B], elems);
// Another way to express symmetric difference
let e_symmetric_diff = (e1 - e2) | (e2 - e1);
let elems: ::vec::Vec<_> = e_symmetric_diff.iter().collect();
assert_eq!(vec![A,B], elems)
assert_eq!(vec![A,B], elems);
// Yet another way to express symmetric difference
let e_symmetric_diff = (e1 | e2) - (e1 & e2);
let elems: ::vec::Vec<_> = e_symmetric_diff.iter().collect();
assert_eq!(vec![A,B], elems)
assert_eq!(vec![A,B], elems);
}
#[test]

View File

@ -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),+))
)
}

View File

@ -2515,7 +2515,7 @@ mod tests {
assert_eq!(format!("{}", x), x_str);
assert_eq!(format!("{}", x.as_slice()), x_str);
})
)
);
let empty: Vec<int> = vec![];
test_show_vec!(empty, "[]");
test_show_vec!(vec![1i], "[1]");

View File

@ -415,14 +415,14 @@ Section: Misc
// Return the initial codepoint accumulator for the first byte.
// The first byte is special, only want bottom 5 bits for width 2, 4 bits
// for width 3, and 3 bits for width 4
macro_rules! utf8_first_byte(
macro_rules! utf8_first_byte {
($byte:expr, $width:expr) => (($byte & (0x7F >> $width)) as u32)
)
}
// return the value of $ch updated with continuation byte $byte
macro_rules! utf8_acc_cont_byte(
macro_rules! utf8_acc_cont_byte {
($ch:expr, $byte:expr) => (($ch << 6) | ($byte & 63u8) as u32)
)
}
/*
Section: MaybeOwned

View File

@ -167,7 +167,7 @@ impl String {
subseqidx = i;
res.as_mut_vec().push_all(REPLACEMENT);
}
}))
}));
if byte < 128u8 {
// subseqidx handles this
@ -788,8 +788,8 @@ macro_rules! impl_eq {
}
}
impl_eq!(String, &'a str)
impl_eq!(CowString<'a>, String)
impl_eq! { String, &'a str }
impl_eq! { CowString<'a>, String }
impl<'a, 'b> PartialEq<&'b str> for CowString<'a> {
#[inline]

View File

@ -900,7 +900,7 @@ macro_rules! define_iterator {
) => {
// private methods on the forward iterator (item!() for the
// addr_mut in the next_ return value)
item!(impl<'a, K, V> $name<'a, K, V> {
item! { impl<'a, K, V> $name<'a, K, V> {
#[inline(always)]
fn next_(&mut self, forward: bool) -> Option<(&'a K, &'a $($addr_mut)* V)> {
while !self.stack.is_empty() || !self.node.is_null() {
@ -968,10 +968,10 @@ macro_rules! define_iterator {
self.node = ptr::RawPtr::null();
}
}
})
} }
// the forward Iterator impl.
item!(impl<'a, K, V> Iterator<(&'a K, &'a $($addr_mut)* V)> for $name<'a, K, V> {
item! { impl<'a, K, V> Iterator<(&'a K, &'a $($addr_mut)* V)> for $name<'a, K, V> {
/// Advances the iterator to the next node (in order) and return a
/// tuple with a reference to the key and value. If there are no
/// more nodes, return `None`.
@ -983,10 +983,10 @@ macro_rules! define_iterator {
fn size_hint(&self) -> (uint, Option<uint>) {
(self.remaining_min, Some(self.remaining_max))
}
})
} }
// the reverse Iterator impl.
item!(impl<'a, K, V> Iterator<(&'a K, &'a $($addr_mut)* V)> for $rev_name<'a, K, V> {
item! { impl<'a, K, V> Iterator<(&'a K, &'a $($addr_mut)* V)> for $rev_name<'a, K, V> {
fn next(&mut self) -> Option<(&'a K, &'a $($addr_mut)* V)> {
self.iter.next_(false)
}
@ -995,7 +995,7 @@ macro_rules! define_iterator {
fn size_hint(&self) -> (uint, Option<uint>) {
self.iter.size_hint()
}
})
} }
}
} // end of define_iterator

View File

@ -1141,7 +1141,7 @@ macro_rules! iterator_impl {
}
}
item!(impl<'a, T> Iterator<(uint, &'a $($mut_)* T)> for $name<'a, T> {
item! { impl<'a, T> Iterator<(uint, &'a $($mut_)* T)> for $name<'a, T> {
// you might wonder why we're not even trying to act within the
// rules, and are just manipulating raw pointers like there's no
// such thing as invalid pointers and memory unsafety. The
@ -1213,7 +1213,7 @@ macro_rules! iterator_impl {
fn size_hint(&self) -> (uint, Option<uint>) {
(self.remaining_min, Some(self.remaining_max))
}
})
} }
}
}

View File

@ -582,8 +582,8 @@ macro_rules! impl_eq {
}
}
impl_eq!(Vec<A>, &'b [B])
impl_eq!(Vec<A>, &'b mut [B])
impl_eq! { Vec<A>, &'b [B] }
impl_eq! { Vec<A>, &'b mut [B] }
impl<'a, A, B> PartialEq<Vec<B>> for CowVec<'a, A> where A: PartialEq<B> + Clone {
#[inline]
@ -617,8 +617,8 @@ macro_rules! impl_eq_for_cowvec {
}
}
impl_eq_for_cowvec!(&'b [B])
impl_eq_for_cowvec!(&'b mut [B])
impl_eq_for_cowvec! { &'b [B] }
impl_eq_for_cowvec! { &'b mut [B] }
#[unstable = "waiting on PartialOrd stability"]
impl<T: PartialOrd> PartialOrd for Vec<T> {
@ -2065,7 +2065,7 @@ mod tests {
#[test]
fn test_partitioned() {
assert_eq!(vec![].partitioned(|x: &int| *x < 3), (vec![], vec![]))
assert_eq!(vec![].partitioned(|x: &int| *x < 3), (vec![], vec![]));
assert_eq!(vec![1i, 2, 3].partitioned(|x: &int| *x < 4), (vec![1, 2, 3], vec![]));
assert_eq!(vec![1i, 2, 3].partitioned(|x: &int| *x < 2), (vec![1], vec![2, 3]));
assert_eq!(vec![1i, 2, 3].partitioned(|x: &int| *x < 0), (vec![], vec![1, 2, 3]));

View File

@ -612,8 +612,8 @@ pub struct Entries<'a, V:'a> {
iter: slice::Items<'a, Option<V>>
}
iterator!(impl Entries -> (uint, &'a V), as_ref)
double_ended_iterator!(impl Entries -> (uint, &'a V), as_ref)
iterator! { impl Entries -> (uint, &'a V), as_ref }
double_ended_iterator! { impl Entries -> (uint, &'a V), as_ref }
/// An iterator over the key-value pairs of a map, with the
/// values being mutable.
@ -623,8 +623,8 @@ pub struct MutEntries<'a, V:'a> {
iter: slice::MutItems<'a, Option<V>>
}
iterator!(impl MutEntries -> (uint, &'a mut V), as_mut)
double_ended_iterator!(impl MutEntries -> (uint, &'a mut V), as_mut)
iterator! { impl MutEntries -> (uint, &'a mut V), as_mut }
double_ended_iterator! { impl MutEntries -> (uint, &'a mut V), as_mut }
/// An iterator over the keys of a map.
pub struct Keys<'a, V: 'a> {

View File

@ -46,7 +46,7 @@ impl<'a, Sized? T> Clone for &'a T {
fn clone(&self) -> &'a T { *self }
}
macro_rules! clone_impl(
macro_rules! clone_impl {
($t:ty) => {
impl Clone for $t {
/// Return a deep copy of the value.
@ -54,28 +54,28 @@ macro_rules! clone_impl(
fn clone(&self) -> $t { *self }
}
}
)
}
clone_impl!(int)
clone_impl!(i8)
clone_impl!(i16)
clone_impl!(i32)
clone_impl!(i64)
clone_impl! { int }
clone_impl! { i8 }
clone_impl! { i16 }
clone_impl! { i32 }
clone_impl! { i64 }
clone_impl!(uint)
clone_impl!(u8)
clone_impl!(u16)
clone_impl!(u32)
clone_impl!(u64)
clone_impl! { uint }
clone_impl! { u8 }
clone_impl! { u16 }
clone_impl! { u32 }
clone_impl! { u64 }
clone_impl!(f32)
clone_impl!(f64)
clone_impl! { f32 }
clone_impl! { f64 }
clone_impl!(())
clone_impl!(bool)
clone_impl!(char)
clone_impl! { () }
clone_impl! { bool }
clone_impl! { char }
macro_rules! extern_fn_clone(
macro_rules! extern_fn_clone {
($($A:ident),*) => (
#[experimental = "this may not be sufficient for fns with region parameters"]
impl<$($A,)* ReturnType> Clone for extern "Rust" fn($($A),*) -> ReturnType {
@ -84,15 +84,15 @@ macro_rules! extern_fn_clone(
fn clone(&self) -> extern "Rust" fn($($A),*) -> ReturnType { *self }
}
)
)
}
extern_fn_clone!()
extern_fn_clone!(A)
extern_fn_clone!(A, B)
extern_fn_clone!(A, B, C)
extern_fn_clone!(A, B, C, D)
extern_fn_clone!(A, B, C, D, E)
extern_fn_clone!(A, B, C, D, E, F)
extern_fn_clone!(A, B, C, D, E, F, G)
extern_fn_clone!(A, B, C, D, E, F, G, H)
extern_fn_clone! {}
extern_fn_clone! { A }
extern_fn_clone! { A, B }
extern_fn_clone! { A, B, C }
extern_fn_clone! { A, B, C, D }
extern_fn_clone! { A, B, C, D, E }
extern_fn_clone! { A, B, C, D, E, F }
extern_fn_clone! { A, B, C, D, E, F, G }
extern_fn_clone! { A, B, C, D, E, F, G, H }

View File

@ -296,7 +296,7 @@ mod impls {
use option::Option;
use option::Option::{Some, None};
macro_rules! partial_eq_impl(
macro_rules! partial_eq_impl {
($($t:ty)*) => ($(
#[unstable = "Trait is unstable."]
impl PartialEq for $t {
@ -306,7 +306,7 @@ mod impls {
fn ne(&self, other: &$t) -> bool { (*self) != (*other) }
}
)*)
)
}
#[unstable = "Trait is unstable."]
impl PartialEq for () {
@ -316,18 +316,20 @@ mod impls {
fn ne(&self, _other: &()) -> bool { false }
}
partial_eq_impl!(bool char uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64)
partial_eq_impl! {
bool char uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64
}
macro_rules! eq_impl(
macro_rules! eq_impl {
($($t:ty)*) => ($(
#[unstable = "Trait is unstable."]
impl Eq for $t {}
)*)
)
}
eq_impl!(() bool char uint u8 u16 u32 u64 int i8 i16 i32 i64)
eq_impl! { () bool char uint u8 u16 u32 u64 int i8 i16 i32 i64 }
macro_rules! partial_ord_impl(
macro_rules! partial_ord_impl {
($($t:ty)*) => ($(
#[unstable = "Trait is unstable."]
impl PartialOrd for $t {
@ -350,7 +352,7 @@ mod impls {
fn gt(&self, other: &$t) -> bool { (*self) > (*other) }
}
)*)
)
}
#[unstable = "Trait is unstable."]
impl PartialOrd for () {
@ -368,9 +370,9 @@ mod impls {
}
}
partial_ord_impl!(char uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64)
partial_ord_impl! { char uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 }
macro_rules! ord_impl(
macro_rules! ord_impl {
($($t:ty)*) => ($(
#[unstable = "Trait is unstable."]
impl Ord for $t {
@ -382,7 +384,7 @@ mod impls {
}
}
)*)
)
}
#[unstable = "Trait is unstable."]
impl Ord for () {
@ -398,7 +400,7 @@ mod impls {
}
}
ord_impl!(char uint u8 u16 u32 u64 int i8 i16 i32 i64)
ord_impl! { char uint u8 u16 u32 u64 int i8 i16 i32 i64 }
// & pointers

View File

@ -135,7 +135,7 @@ pub trait Default {
fn default() -> Self;
}
macro_rules! default_impl(
macro_rules! default_impl {
($t:ty, $v:expr) => {
#[stable]
impl Default for $t {
@ -144,23 +144,24 @@ macro_rules! default_impl(
fn default() -> $t { $v }
}
}
)
}
default_impl!((), ())
default_impl!(bool, false)
default_impl!(char, '\x00')
default_impl! { (), () }
default_impl! { bool, false }
default_impl! { char, '\x00' }
default_impl!(uint, 0u)
default_impl!(u8, 0u8)
default_impl!(u16, 0u16)
default_impl!(u32, 0u32)
default_impl!(u64, 0u64)
default_impl! { uint, 0u }
default_impl! { u8, 0u8 }
default_impl! { u16, 0u16 }
default_impl! { u32, 0u32 }
default_impl! { u64, 0u64 }
default_impl!(int, 0i)
default_impl!(i8, 0i8)
default_impl!(i16, 0i16)
default_impl!(i32, 0i32)
default_impl!(i64, 0i64)
default_impl! { int, 0i }
default_impl! { i8, 0i8 }
default_impl! { i16, 0i16 }
default_impl! { i32, 0i32 }
default_impl! { i64, 0i64 }
default_impl! { f32, 0.0f32 }
default_impl! { f64, 0.0f64 }
default_impl!(f32, 0.0f32)
default_impl!(f64, 0.0f64)

View File

@ -639,7 +639,7 @@ impl<'a, T> Pointer for &'a mut T {
}
}
macro_rules! floating(($ty:ident) => {
macro_rules! floating { ($ty:ident) => {
impl Show for $ty {
fn fmt(&self, fmt: &mut Formatter) -> Result {
use num::Float;
@ -702,9 +702,9 @@ macro_rules! floating(($ty:ident) => {
})
}
}
})
floating!(f32)
floating!(f64)
} }
floating! { f32 }
floating! { f64 }
// Implementation of Show for various core types
@ -716,9 +716,11 @@ impl<T> Show for *mut T {
fn fmt(&self, f: &mut Formatter) -> Result { Pointer::fmt(self, f) }
}
macro_rules! peel(($name:ident, $($other:ident,)*) => (tuple!($($other,)*)))
macro_rules! peel {
($name:ident, $($other:ident,)*) => (tuple! { $($other,)* })
}
macro_rules! tuple (
macro_rules! tuple {
() => ();
( $($name:ident,)+ ) => (
impl<$($name:Show),*> Show for ($($name,)*) {
@ -740,9 +742,9 @@ macro_rules! tuple (
write!(f, ")")
}
}
peel!($($name,)*)
peel! { $($name,)* }
)
)
}
tuple! { T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, }

View File

@ -100,13 +100,13 @@ macro_rules! radix {
}
}
radix!(Binary, 2, "0b", x @ 0 ... 2 => b'0' + x)
radix!(Octal, 8, "0o", x @ 0 ... 7 => b'0' + x)
radix!(Decimal, 10, "", x @ 0 ... 9 => b'0' + x)
radix!(LowerHex, 16, "0x", x @ 0 ... 9 => b'0' + x,
x @ 10 ... 15 => b'a' + (x - 10))
radix!(UpperHex, 16, "0x", x @ 0 ... 9 => b'0' + x,
x @ 10 ... 15 => b'A' + (x - 10))
radix! { Binary, 2, "0b", x @ 0 ... 2 => b'0' + x }
radix! { Octal, 8, "0o", x @ 0 ... 7 => b'0' + x }
radix! { Decimal, 10, "", x @ 0 ... 9 => b'0' + x }
radix! { LowerHex, 16, "0x", x @ 0 ... 9 => b'0' + x,
x @ 10 ... 15 => b'a' + (x - 10) }
radix! { UpperHex, 16, "0x", x @ 0 ... 9 => b'0' + x,
x @ 10 ... 15 => b'A' + (x - 10) }
/// A radix with in the range of `2..36`.
#[deriving(Clone, PartialEq)]
@ -174,23 +174,23 @@ macro_rules! int_base {
}
macro_rules! integer {
($Int:ident, $Uint:ident) => {
int_base!(Show for $Int as $Int -> Decimal)
int_base!(Binary for $Int as $Uint -> Binary)
int_base!(Octal for $Int as $Uint -> Octal)
int_base!(LowerHex for $Int as $Uint -> LowerHex)
int_base!(UpperHex for $Int as $Uint -> UpperHex)
radix_fmt!($Int as $Int, fmt_int)
int_base! { Show for $Int as $Int -> Decimal }
int_base! { Binary for $Int as $Uint -> Binary }
int_base! { Octal for $Int as $Uint -> Octal }
int_base! { LowerHex for $Int as $Uint -> LowerHex }
int_base! { UpperHex for $Int as $Uint -> UpperHex }
radix_fmt! { $Int as $Int, fmt_int }
int_base!(Show for $Uint as $Uint -> Decimal)
int_base!(Binary for $Uint as $Uint -> Binary)
int_base!(Octal for $Uint as $Uint -> Octal)
int_base!(LowerHex for $Uint as $Uint -> LowerHex)
int_base!(UpperHex for $Uint as $Uint -> UpperHex)
radix_fmt!($Uint as $Uint, fmt_int)
int_base! { Show for $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 }

View File

@ -109,16 +109,16 @@ macro_rules! impl_hash {
}
}
impl_hash!(u8, u8)
impl_hash!(u16, u16)
impl_hash!(u32, u32)
impl_hash!(u64, u64)
impl_hash!(uint, uint)
impl_hash!(i8, u8)
impl_hash!(i16, u16)
impl_hash!(i32, u32)
impl_hash!(i64, u64)
impl_hash!(int, uint)
impl_hash! { u8, u8 }
impl_hash! { u16, u16 }
impl_hash! { u32, u32 }
impl_hash! { u64, u64 }
impl_hash! { uint, uint }
impl_hash! { i8, u8 }
impl_hash! { i16, u16 }
impl_hash! { i32, u32 }
impl_hash! { i64, u64 }
impl_hash! { int, uint }
impl<S: Writer> Hash<S> for bool {
#[inline]
@ -142,7 +142,7 @@ impl<S: Writer> Hash<S> for str {
}
}
macro_rules! impl_hash_tuple(
macro_rules! impl_hash_tuple {
() => (
impl<S: Writer> Hash<S> for () {
#[inline]
@ -167,21 +167,21 @@ macro_rules! impl_hash_tuple(
}
}
);
)
}
impl_hash_tuple!()
impl_hash_tuple!(A)
impl_hash_tuple!(A B)
impl_hash_tuple!(A B C)
impl_hash_tuple!(A B C D)
impl_hash_tuple!(A B C D E)
impl_hash_tuple!(A B C D E F)
impl_hash_tuple!(A B C D E F G)
impl_hash_tuple!(A B C D E F G H)
impl_hash_tuple!(A B C D E F G H I)
impl_hash_tuple!(A B C D E F G H I J)
impl_hash_tuple!(A B C D E F G H I J K)
impl_hash_tuple!(A B C D E F G H I J K L)
impl_hash_tuple! {}
impl_hash_tuple! { A }
impl_hash_tuple! { A B }
impl_hash_tuple! { A B C }
impl_hash_tuple! { A B C D }
impl_hash_tuple! { A B C D E }
impl_hash_tuple! { A B C D E F }
impl_hash_tuple! { A B C D E F G }
impl_hash_tuple! { A B C D E F G H }
impl_hash_tuple! { A B C D E F G H I }
impl_hash_tuple! { A B C D E F G H I J }
impl_hash_tuple! { A B C D E F G H I J K }
impl_hash_tuple! { A B C D E F G H I J K L }
impl<S: Writer, T: Hash<S>> Hash<S> for [T] {
#[inline]

View File

@ -48,7 +48,7 @@ impl Copy for SipState {}
// because they're needed in the following defs;
// this design could be improved.
macro_rules! u8to64_le (
macro_rules! u8to64_le {
($buf:expr, $i:expr) =>
($buf[0+$i] as u64 |
$buf[1+$i] as u64 << 8 |
@ -68,14 +68,14 @@ macro_rules! u8to64_le (
}
out
});
)
}
macro_rules! rotl (
macro_rules! rotl {
($x:expr, $b:expr) =>
(($x << $b) | ($x >> (64 - $b)))
)
}
macro_rules! compress (
macro_rules! compress {
($v0:expr, $v1:expr, $v2:expr, $v3:expr) =>
({
$v0 += $v1; $v1 = rotl!($v1, 13); $v1 ^= $v0;
@ -85,7 +85,7 @@ macro_rules! compress (
$v2 += $v1; $v1 = rotl!($v1, 17); $v1 ^= $v2;
$v2 = rotl!($v2, 32);
})
)
}
impl SipState {
/// Creates a `SipState` that is keyed off the provided keys.

View File

@ -875,18 +875,18 @@ macro_rules! impl_additive {
}
};
}
impl_additive!(i8, 0)
impl_additive!(i16, 0)
impl_additive!(i32, 0)
impl_additive!(i64, 0)
impl_additive!(int, 0)
impl_additive!(u8, 0)
impl_additive!(u16, 0)
impl_additive!(u32, 0)
impl_additive!(u64, 0)
impl_additive!(uint, 0)
impl_additive!(f32, 0.0)
impl_additive!(f64, 0.0)
impl_additive! { i8, 0 }
impl_additive! { i16, 0 }
impl_additive! { i32, 0 }
impl_additive! { i64, 0 }
impl_additive! { int, 0 }
impl_additive! { u8, 0 }
impl_additive! { u16, 0 }
impl_additive! { u32, 0 }
impl_additive! { u64, 0 }
impl_additive! { uint, 0 }
impl_additive! { f32, 0.0 }
impl_additive! { f64, 0.0 }
/// A trait for iterators over elements which can be multiplied together.
#[experimental = "needs to be re-evaluated as part of numerics reform"]
@ -919,18 +919,18 @@ macro_rules! impl_multiplicative {
}
};
}
impl_multiplicative!(i8, 1)
impl_multiplicative!(i16, 1)
impl_multiplicative!(i32, 1)
impl_multiplicative!(i64, 1)
impl_multiplicative!(int, 1)
impl_multiplicative!(u8, 1)
impl_multiplicative!(u16, 1)
impl_multiplicative!(u32, 1)
impl_multiplicative!(u64, 1)
impl_multiplicative!(uint, 1)
impl_multiplicative!(f32, 1.0)
impl_multiplicative!(f64, 1.0)
impl_multiplicative! { i8, 1 }
impl_multiplicative! { i16, 1 }
impl_multiplicative! { i32, 1 }
impl_multiplicative! { i64, 1 }
impl_multiplicative! { int, 1 }
impl_multiplicative! { u8, 1 }
impl_multiplicative! { u16, 1 }
impl_multiplicative! { u32, 1 }
impl_multiplicative! { u64, 1 }
impl_multiplicative! { uint, 1 }
impl_multiplicative! { f32, 1.0 }
impl_multiplicative! { f64, 1.0 }
/// A trait for iterators over elements which can be compared to one another.
#[unstable = "recently renamed for new extension trait conventions"]
@ -1084,7 +1084,7 @@ impl<T: Clone> MinMaxResult<T> {
/// use std::iter::{NoElements, OneElement, MinMax, MinMaxResult};
///
/// let r: MinMaxResult<int> = NoElements;
/// assert_eq!(r.into_option(), None)
/// assert_eq!(r.into_option(), None);
///
/// let r = OneElement(1i);
/// assert_eq!(r.into_option(), Some((1,1)));

View File

@ -12,7 +12,7 @@
/// Entry point of task panic, for details, see std::macros
#[macro_export]
macro_rules! panic(
macro_rules! panic {
() => (
panic!("{}", "explicit panic")
);
@ -44,11 +44,11 @@ macro_rules! panic(
}
format_args!(_run_fmt, $fmt, $($arg)*)
});
)
}
/// Runtime assertion, for details see std::macros
#[macro_export]
macro_rules! assert(
macro_rules! assert {
($cond:expr) => (
if !$cond {
panic!(concat!("assertion failed: ", stringify!($cond)))
@ -59,21 +59,21 @@ macro_rules! assert(
panic!($($arg)*)
}
);
)
}
/// Runtime assertion, only without `--cfg ndebug`
#[macro_export]
macro_rules! debug_assert(
macro_rules! debug_assert {
($(a:tt)*) => ({
if cfg!(not(ndebug)) {
assert!($($a)*);
}
})
)
}
/// Runtime assertion for equality, for details see std::macros
#[macro_export]
macro_rules! assert_eq(
macro_rules! assert_eq {
($cond1:expr, $cond2:expr) => ({
let c1 = $cond1;
let c2 = $cond2;
@ -81,46 +81,47 @@ macro_rules! assert_eq(
panic!("expressions not equal, left: {}, right: {}", c1, c2);
}
})
)
}
/// Runtime assertion for equality, only without `--cfg ndebug`
#[macro_export]
macro_rules! debug_assert_eq(
macro_rules! debug_assert_eq {
($($a:tt)*) => ({
if cfg!(not(ndebug)) {
assert_eq!($($a)*);
}
})
)
}
/// Runtime assertion, disableable at compile time
#[macro_export]
macro_rules! debug_assert(
macro_rules! debug_assert {
($($arg:tt)*) => (if cfg!(not(ndebug)) { assert!($($arg)*); })
)
}
/// Short circuiting evaluation on Err
#[macro_export]
macro_rules! try(
macro_rules! try {
($e:expr) => (match $e { Ok(e) => e, Err(e) => return Err(e) })
)
}
/// Writing a formatted string into a writer
#[macro_export]
macro_rules! write(
macro_rules! write {
($dst:expr, $($arg:tt)*) => ({
let dst = &mut *$dst;
format_args!(|args| { dst.write_fmt(args) }, $($arg)*)
})
)
}
/// Writing a formatted string plus a newline into a writer
#[macro_export]
macro_rules! writeln(
macro_rules! writeln {
($dst:expr, $fmt:expr $($arg:tt)*) => (
write!($dst, concat!($fmt, "\n") $($arg)*)
)
)
}
#[macro_export]
macro_rules! unreachable( () => (panic!("unreachable code")) )
macro_rules! unreachable { () => (panic!("unreachable code")) }

View File

@ -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);
})
)
}

View File

@ -13,4 +13,4 @@
#![stable]
#![doc(primitive = "i16")]
int_module!(i16, 16)
int_module! { i16, 16 }

View File

@ -13,4 +13,4 @@
#![stable]
#![doc(primitive = "i32")]
int_module!(i32, 32)
int_module! { i32, 32 }

View File

@ -13,4 +13,4 @@
#![stable]
#![doc(primitive = "i64")]
int_module!(i64, 64)
int_module! { i64, 64 }

View File

@ -13,4 +13,4 @@
#![stable]
#![doc(primitive = "i8")]
int_module!(i8, 8)
int_module! { i8, 8 }

View File

@ -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 }

View File

@ -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;
))
) }

View File

@ -458,61 +458,61 @@ macro_rules! uint_impl {
/// consistency with the other `bswap` intrinsics.
unsafe fn bswap8(x: u8) -> u8 { x }
uint_impl!(u8 = u8, 8,
uint_impl! { u8 = u8, 8,
intrinsics::ctpop8,
intrinsics::ctlz8,
intrinsics::cttz8,
bswap8,
intrinsics::u8_add_with_overflow,
intrinsics::u8_sub_with_overflow,
intrinsics::u8_mul_with_overflow)
intrinsics::u8_mul_with_overflow }
uint_impl!(u16 = u16, 16,
uint_impl! { u16 = u16, 16,
intrinsics::ctpop16,
intrinsics::ctlz16,
intrinsics::cttz16,
intrinsics::bswap16,
intrinsics::u16_add_with_overflow,
intrinsics::u16_sub_with_overflow,
intrinsics::u16_mul_with_overflow)
intrinsics::u16_mul_with_overflow }
uint_impl!(u32 = u32, 32,
uint_impl! { u32 = u32, 32,
intrinsics::ctpop32,
intrinsics::ctlz32,
intrinsics::cttz32,
intrinsics::bswap32,
intrinsics::u32_add_with_overflow,
intrinsics::u32_sub_with_overflow,
intrinsics::u32_mul_with_overflow)
intrinsics::u32_mul_with_overflow }
uint_impl!(u64 = u64, 64,
uint_impl! { u64 = u64, 64,
intrinsics::ctpop64,
intrinsics::ctlz64,
intrinsics::cttz64,
intrinsics::bswap64,
intrinsics::u64_add_with_overflow,
intrinsics::u64_sub_with_overflow,
intrinsics::u64_mul_with_overflow)
intrinsics::u64_mul_with_overflow }
#[cfg(target_word_size = "32")]
uint_impl!(uint = u32, 32,
uint_impl! { uint = u32, 32,
intrinsics::ctpop32,
intrinsics::ctlz32,
intrinsics::cttz32,
intrinsics::bswap32,
intrinsics::u32_add_with_overflow,
intrinsics::u32_sub_with_overflow,
intrinsics::u32_mul_with_overflow)
intrinsics::u32_mul_with_overflow }
#[cfg(target_word_size = "64")]
uint_impl!(uint = u64, 64,
uint_impl! { uint = u64, 64,
intrinsics::ctpop64,
intrinsics::ctlz64,
intrinsics::cttz64,
intrinsics::bswap64,
intrinsics::u64_add_with_overflow,
intrinsics::u64_sub_with_overflow,
intrinsics::u64_mul_with_overflow)
intrinsics::u64_mul_with_overflow }
macro_rules! int_impl {
($T:ty = $ActualT:ty, $UnsignedT:ty, $BITS:expr,
@ -579,37 +579,37 @@ macro_rules! int_impl {
}
}
int_impl!(i8 = i8, u8, 8,
int_impl! { i8 = i8, u8, 8,
intrinsics::i8_add_with_overflow,
intrinsics::i8_sub_with_overflow,
intrinsics::i8_mul_with_overflow)
intrinsics::i8_mul_with_overflow }
int_impl!(i16 = i16, u16, 16,
int_impl! { i16 = i16, u16, 16,
intrinsics::i16_add_with_overflow,
intrinsics::i16_sub_with_overflow,
intrinsics::i16_mul_with_overflow)
intrinsics::i16_mul_with_overflow }
int_impl!(i32 = i32, u32, 32,
int_impl! { i32 = i32, u32, 32,
intrinsics::i32_add_with_overflow,
intrinsics::i32_sub_with_overflow,
intrinsics::i32_mul_with_overflow)
intrinsics::i32_mul_with_overflow }
int_impl!(i64 = i64, u64, 64,
int_impl! { i64 = i64, u64, 64,
intrinsics::i64_add_with_overflow,
intrinsics::i64_sub_with_overflow,
intrinsics::i64_mul_with_overflow)
intrinsics::i64_mul_with_overflow }
#[cfg(target_word_size = "32")]
int_impl!(int = i32, u32, 32,
int_impl! { int = i32, u32, 32,
intrinsics::i32_add_with_overflow,
intrinsics::i32_sub_with_overflow,
intrinsics::i32_mul_with_overflow)
intrinsics::i32_mul_with_overflow }
#[cfg(target_word_size = "64")]
int_impl!(int = i64, u64, 64,
int_impl! { int = i64, u64, 64,
intrinsics::i64_add_with_overflow,
intrinsics::i64_sub_with_overflow,
intrinsics::i64_mul_with_overflow)
intrinsics::i64_mul_with_overflow }
/// A built-in two's complement integer.
#[unstable = "recently settled as part of numerics reform"]
@ -663,11 +663,11 @@ macro_rules! signed_int_impl {
}
}
signed_int_impl!(i8)
signed_int_impl!(i16)
signed_int_impl!(i32)
signed_int_impl!(i64)
signed_int_impl!(int)
signed_int_impl! { i8 }
signed_int_impl! { i16 }
signed_int_impl! { i32 }
signed_int_impl! { i64 }
signed_int_impl! { int }
/// A built-in unsigned integer.
#[unstable = "recently settled as part of numerics reform"]
@ -791,7 +791,7 @@ pub trait ToPrimitive {
}
}
macro_rules! impl_to_primitive_int_to_int(
macro_rules! impl_to_primitive_int_to_int {
($SrcT:ty, $DstT:ty, $slf:expr) => (
{
if size_of::<$SrcT>() <= size_of::<$DstT>() {
@ -808,9 +808,9 @@ macro_rules! impl_to_primitive_int_to_int(
}
}
)
)
}
macro_rules! impl_to_primitive_int_to_uint(
macro_rules! impl_to_primitive_int_to_uint {
($SrcT:ty, $DstT:ty, $slf:expr) => (
{
let zero: $SrcT = Int::zero();
@ -822,9 +822,9 @@ macro_rules! impl_to_primitive_int_to_uint(
}
}
)
)
}
macro_rules! impl_to_primitive_int(
macro_rules! impl_to_primitive_int {
($T:ty) => (
impl ToPrimitive for $T {
#[inline]
@ -855,15 +855,15 @@ macro_rules! impl_to_primitive_int(
fn to_f64(&self) -> Option<f64> { Some(*self as f64) }
}
)
)
}
impl_to_primitive_int!(int)
impl_to_primitive_int!(i8)
impl_to_primitive_int!(i16)
impl_to_primitive_int!(i32)
impl_to_primitive_int!(i64)
impl_to_primitive_int! { int }
impl_to_primitive_int! { i8 }
impl_to_primitive_int! { i16 }
impl_to_primitive_int! { i32 }
impl_to_primitive_int! { i64 }
macro_rules! impl_to_primitive_uint_to_int(
macro_rules! impl_to_primitive_uint_to_int {
($DstT:ty, $slf:expr) => (
{
let max_value: $DstT = Int::max_value();
@ -874,9 +874,9 @@ macro_rules! impl_to_primitive_uint_to_int(
}
}
)
)
}
macro_rules! impl_to_primitive_uint_to_uint(
macro_rules! impl_to_primitive_uint_to_uint {
($SrcT:ty, $DstT:ty, $slf:expr) => (
{
if size_of::<$SrcT>() <= size_of::<$DstT>() {
@ -892,9 +892,9 @@ macro_rules! impl_to_primitive_uint_to_uint(
}
}
)
)
}
macro_rules! impl_to_primitive_uint(
macro_rules! impl_to_primitive_uint {
($T:ty) => (
impl ToPrimitive for $T {
#[inline]
@ -925,15 +925,15 @@ macro_rules! impl_to_primitive_uint(
fn to_f64(&self) -> Option<f64> { Some(*self as f64) }
}
)
)
}
impl_to_primitive_uint!(uint)
impl_to_primitive_uint!(u8)
impl_to_primitive_uint!(u16)
impl_to_primitive_uint!(u32)
impl_to_primitive_uint!(u64)
impl_to_primitive_uint! { uint }
impl_to_primitive_uint! { u8 }
impl_to_primitive_uint! { u16 }
impl_to_primitive_uint! { u32 }
impl_to_primitive_uint! { u64 }
macro_rules! impl_to_primitive_float_to_float(
macro_rules! impl_to_primitive_float_to_float {
($SrcT:ty, $DstT:ty, $slf:expr) => (
if size_of::<$SrcT>() <= size_of::<$DstT>() {
Some($slf as $DstT)
@ -947,9 +947,9 @@ macro_rules! impl_to_primitive_float_to_float(
}
}
)
)
}
macro_rules! impl_to_primitive_float(
macro_rules! impl_to_primitive_float {
($T:ty) => (
impl ToPrimitive for $T {
#[inline]
@ -980,10 +980,10 @@ macro_rules! impl_to_primitive_float(
fn to_f64(&self) -> Option<f64> { impl_to_primitive_float_to_float!($T, f64, *self) }
}
)
)
}
impl_to_primitive_float!(f32)
impl_to_primitive_float!(f64)
impl_to_primitive_float! { f32 }
impl_to_primitive_float! { f64 }
/// A generic trait for converting a number to a value.
#[experimental = "trait is likely to be removed"]
@ -1139,7 +1139,7 @@ pub fn from_f64<A: FromPrimitive>(n: f64) -> Option<A> {
FromPrimitive::from_f64(n)
}
macro_rules! impl_from_primitive(
macro_rules! impl_from_primitive {
($T:ty, $to_ty:ident) => (
impl FromPrimitive for $T {
#[inline] fn from_int(n: int) -> Option<$T> { n.$to_ty() }
@ -1158,20 +1158,20 @@ macro_rules! impl_from_primitive(
#[inline] fn from_f64(n: f64) -> Option<$T> { n.$to_ty() }
}
)
)
}
impl_from_primitive!(int, to_int)
impl_from_primitive!(i8, to_i8)
impl_from_primitive!(i16, to_i16)
impl_from_primitive!(i32, to_i32)
impl_from_primitive!(i64, to_i64)
impl_from_primitive!(uint, to_uint)
impl_from_primitive!(u8, to_u8)
impl_from_primitive!(u16, to_u16)
impl_from_primitive!(u32, to_u32)
impl_from_primitive!(u64, to_u64)
impl_from_primitive!(f32, to_f32)
impl_from_primitive!(f64, to_f64)
impl_from_primitive! { int, to_int }
impl_from_primitive! { i8, to_i8 }
impl_from_primitive! { i16, to_i16 }
impl_from_primitive! { i32, to_i32 }
impl_from_primitive! { i64, to_i64 }
impl_from_primitive! { uint, to_uint }
impl_from_primitive! { u8, to_u8 }
impl_from_primitive! { u16, to_u16 }
impl_from_primitive! { u32, to_u32 }
impl_from_primitive! { u64, to_u64 }
impl_from_primitive! { f32, to_f32 }
impl_from_primitive! { f64, to_f64 }
/// Cast from one machine scalar to another.
///
@ -1198,7 +1198,7 @@ pub trait NumCast: ToPrimitive {
fn from<T: ToPrimitive>(n: T) -> Option<Self>;
}
macro_rules! impl_num_cast(
macro_rules! impl_num_cast {
($T:ty, $conv:ident) => (
impl NumCast for $T {
#[inline]
@ -1209,20 +1209,20 @@ macro_rules! impl_num_cast(
}
}
)
)
}
impl_num_cast!(u8, to_u8)
impl_num_cast!(u16, to_u16)
impl_num_cast!(u32, to_u32)
impl_num_cast!(u64, to_u64)
impl_num_cast!(uint, to_uint)
impl_num_cast!(i8, to_i8)
impl_num_cast!(i16, to_i16)
impl_num_cast!(i32, to_i32)
impl_num_cast!(i64, to_i64)
impl_num_cast!(int, to_int)
impl_num_cast!(f32, to_f32)
impl_num_cast!(f64, to_f64)
impl_num_cast! { u8, to_u8 }
impl_num_cast! { u16, to_u16 }
impl_num_cast! { u32, to_u32 }
impl_num_cast! { u64, to_u64 }
impl_num_cast! { uint, to_uint }
impl_num_cast! { i8, to_i8 }
impl_num_cast! { i16, to_i16 }
impl_num_cast! { i32, to_i32 }
impl_num_cast! { i64, to_i64 }
impl_num_cast! { int, to_int }
impl_num_cast! { f32, to_f32 }
impl_num_cast! { f64, to_f64 }
/// Used for representing the classification of floating point numbers
#[deriving(PartialEq, Show)]
@ -1638,8 +1638,8 @@ macro_rules! from_str_radix_float_impl {
}
}
}
from_str_radix_float_impl!(f32)
from_str_radix_float_impl!(f64)
from_str_radix_float_impl! { f32 }
from_str_radix_float_impl! { f64 }
macro_rules! from_str_radix_int_impl {
($T:ty) => {
@ -1705,16 +1705,16 @@ macro_rules! from_str_radix_int_impl {
}
}
}
from_str_radix_int_impl!(int)
from_str_radix_int_impl!(i8)
from_str_radix_int_impl!(i16)
from_str_radix_int_impl!(i32)
from_str_radix_int_impl!(i64)
from_str_radix_int_impl!(uint)
from_str_radix_int_impl!(u8)
from_str_radix_int_impl!(u16)
from_str_radix_int_impl!(u32)
from_str_radix_int_impl!(u64)
from_str_radix_int_impl! { int }
from_str_radix_int_impl! { i8 }
from_str_radix_int_impl! { i16 }
from_str_radix_int_impl! { i32 }
from_str_radix_int_impl! { i64 }
from_str_radix_int_impl! { uint }
from_str_radix_int_impl! { u8 }
from_str_radix_int_impl! { u16 }
from_str_radix_int_impl! { u32 }
from_str_radix_int_impl! { u64 }
// DEPRECATED
@ -1733,17 +1733,17 @@ pub trait Num: PartialEq + Zero + One
+ Mul<Self,Self>
+ Div<Self,Self>
+ Rem<Self,Self> {}
trait_impl!(Num for uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64)
trait_impl! { Num for uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 }
#[deprecated = "Generalised unsigned numbers are no longer supported"]
#[allow(deprecated)]
pub trait Unsigned: Num {}
trait_impl!(Unsigned for uint u8 u16 u32 u64)
trait_impl! { Unsigned for uint u8 u16 u32 u64 }
#[deprecated = "Use `Float` or `Int`"]
#[allow(deprecated)]
pub trait Primitive: Copy + Clone + Num + NumCast + PartialOrd {}
trait_impl!(Primitive for uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64)
trait_impl! { Primitive for uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 }
#[deprecated = "The generic `Zero` trait will be removed soon."]
pub trait Zero: Add<Self, Self> {
@ -1763,18 +1763,18 @@ macro_rules! zero_impl {
}
}
}
zero_impl!(uint, 0u)
zero_impl!(u8, 0u8)
zero_impl!(u16, 0u16)
zero_impl!(u32, 0u32)
zero_impl!(u64, 0u64)
zero_impl!(int, 0i)
zero_impl!(i8, 0i8)
zero_impl!(i16, 0i16)
zero_impl!(i32, 0i32)
zero_impl!(i64, 0i64)
zero_impl!(f32, 0.0f32)
zero_impl!(f64, 0.0f64)
zero_impl! { uint, 0u }
zero_impl! { u8, 0u8 }
zero_impl! { u16, 0u16 }
zero_impl! { u32, 0u32 }
zero_impl! { u64, 0u64 }
zero_impl! { int, 0i }
zero_impl! { i8, 0i8 }
zero_impl! { i16, 0i16 }
zero_impl! { i32, 0i32 }
zero_impl! { i64, 0i64 }
zero_impl! { f32, 0.0f32 }
zero_impl! { f64, 0.0f64 }
#[deprecated = "The generic `One` trait will be removed soon."]
pub trait One: Mul<Self, Self> {
@ -1791,18 +1791,18 @@ macro_rules! one_impl {
}
}
}
one_impl!(uint, 1u)
one_impl!(u8, 1u8)
one_impl!(u16, 1u16)
one_impl!(u32, 1u32)
one_impl!(u64, 1u64)
one_impl!(int, 1i)
one_impl!(i8, 1i8)
one_impl!(i16, 1i16)
one_impl!(i32, 1i32)
one_impl!(i64, 1i64)
one_impl!(f32, 1.0f32)
one_impl!(f64, 1.0f64)
one_impl! { uint, 1u }
one_impl! { u8, 1u8 }
one_impl! { u16, 1u16 }
one_impl! { u32, 1u32 }
one_impl! { u64, 1u64 }
one_impl! { int, 1i }
one_impl! { i8, 1i8 }
one_impl! { i16, 1i16 }
one_impl! { i32, 1i32 }
one_impl! { i64, 1i64 }
one_impl! { f32, 1.0f32 }
one_impl! { f64, 1.0f64 }
#[deprecated = "Use `UnsignedInt::next_power_of_two`"]
pub fn next_power_of_two<T: UnsignedInt>(n: T) -> T {
@ -1835,15 +1835,15 @@ macro_rules! bounded_impl {
}
};
}
bounded_impl!(uint, uint::MIN, uint::MAX)
bounded_impl!(u8, u8::MIN, u8::MAX)
bounded_impl!(u16, u16::MIN, u16::MAX)
bounded_impl!(u32, u32::MIN, u32::MAX)
bounded_impl!(u64, u64::MIN, u64::MAX)
bounded_impl!(int, int::MIN, int::MAX)
bounded_impl!(i8, i8::MIN, i8::MAX)
bounded_impl!(i16, i16::MIN, i16::MAX)
bounded_impl!(i32, i32::MIN, i32::MAX)
bounded_impl!(i64, i64::MIN, i64::MAX)
bounded_impl!(f32, f32::MIN_VALUE, f32::MAX_VALUE)
bounded_impl!(f64, f64::MIN_VALUE, f64::MAX_VALUE)
bounded_impl! { uint, uint::MIN, uint::MAX }
bounded_impl! { u8, u8::MIN, u8::MAX }
bounded_impl! { u16, u16::MIN, u16::MAX }
bounded_impl! { u32, u32::MIN, u32::MAX }
bounded_impl! { u64, u64::MIN, u64::MAX }
bounded_impl! { int, int::MIN, int::MAX }
bounded_impl! { i8, i8::MIN, i8::MAX }
bounded_impl! { i16, i16::MIN, i16::MAX }
bounded_impl! { i32, i32::MIN, i32::MAX }
bounded_impl! { i64, i64::MIN, i64::MAX }
bounded_impl! { f32, f32::MIN_VALUE, f32::MAX_VALUE }
bounded_impl! { f64, f64::MIN_VALUE, f64::MAX_VALUE }

View File

@ -13,4 +13,4 @@
#![stable]
#![doc(primitive = "u16")]
uint_module!(u16, i16, 16)
uint_module! { u16, i16, 16 }

View File

@ -13,4 +13,4 @@
#![stable]
#![doc(primitive = "u32")]
uint_module!(u32, i32, 32)
uint_module! { u32, i32, 32 }

View File

@ -13,4 +13,4 @@
#![stable]
#![doc(primitive = "u64")]
uint_module!(u64, i64, 64)
uint_module! { u64, i64, 64 }

View File

@ -13,4 +13,4 @@
#![stable]
#![doc(primitive = "u8")]
uint_module!(u8, i8, 8)
uint_module! { u8, i8, 8 }

View File

@ -13,5 +13,5 @@
#![unstable]
#![doc(primitive = "uint")]
uint_module!(uint, int, ::int::BITS)
uint_module! { uint, int, ::int::BITS }

View File

@ -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;
))
) }

View File

@ -113,14 +113,14 @@ pub trait Add<Sized? RHS,Result> for Sized? {
// NOTE(stage0): Remove macro after a snapshot
#[cfg(stage0)]
macro_rules! add_impl(
macro_rules! add_impl {
($($t:ty)*) => ($(
impl Add<$t, $t> for $t {
#[inline]
fn add(&self, other: &$t) -> $t { (*self) + (*other) }
}
)*)
)
}
/// The `Add` trait is used to specify the functionality of `+`.
///
@ -151,16 +151,16 @@ pub trait Add<RHS, Result> {
}
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
macro_rules! add_impl(
macro_rules! add_impl {
($($t:ty)*) => ($(
impl Add<$t, $t> for $t {
#[inline]
fn add(self, other: $t) -> $t { self + other }
}
)*)
)
}
add_impl!(uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64)
add_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 }
/// The `Sub` trait is used to specify the functionality of `-`.
///
@ -195,14 +195,14 @@ pub trait Sub<Sized? RHS, Result> for Sized? {
// NOTE(stage0): Remove macro after a snapshot
#[cfg(stage0)]
macro_rules! sub_impl(
macro_rules! sub_impl {
($($t:ty)*) => ($(
impl Sub<$t, $t> for $t {
#[inline]
fn sub(&self, other: &$t) -> $t { (*self) - (*other) }
}
)*)
)
}
/// The `Sub` trait is used to specify the functionality of `-`.
///
@ -233,16 +233,16 @@ pub trait Sub<RHS, Result> {
}
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
macro_rules! sub_impl(
macro_rules! sub_impl {
($($t:ty)*) => ($(
impl Sub<$t, $t> for $t {
#[inline]
fn sub(self, other: $t) -> $t { self - other }
}
)*)
)
}
sub_impl!(uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64)
sub_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 }
/// The `Mul` trait is used to specify the functionality of `*`.
///
@ -277,14 +277,14 @@ pub trait Mul<Sized? RHS, Result> for Sized? {
// NOTE(stage0): Remove macro after a snapshot
#[cfg(stage0)]
macro_rules! mul_impl(
macro_rules! mul_impl {
($($t:ty)*) => ($(
impl Mul<$t, $t> for $t {
#[inline]
fn mul(&self, other: &$t) -> $t { (*self) * (*other) }
}
)*)
)
}
/// The `Mul` trait is used to specify the functionality of `*`.
///
@ -315,16 +315,16 @@ pub trait Mul<RHS, Result> {
}
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
macro_rules! mul_impl(
macro_rules! mul_impl {
($($t:ty)*) => ($(
impl Mul<$t, $t> for $t {
#[inline]
fn mul(self, other: $t) -> $t { self * other }
}
)*)
)
}
mul_impl!(uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64)
mul_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 }
/// The `Div` trait is used to specify the functionality of `/`.
///
@ -359,14 +359,14 @@ pub trait Div<Sized? RHS, Result> for Sized? {
// NOTE(stage0): Remove macro after a snapshot
#[cfg(stage0)]
macro_rules! div_impl(
macro_rules! div_impl {
($($t:ty)*) => ($(
impl Div<$t, $t> for $t {
#[inline]
fn div(&self, other: &$t) -> $t { (*self) / (*other) }
}
)*)
)
}
/// The `Div` trait is used to specify the functionality of `/`.
///
@ -397,16 +397,16 @@ pub trait Div<RHS, Result> {
}
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
macro_rules! div_impl(
macro_rules! div_impl {
($($t:ty)*) => ($(
impl Div<$t, $t> for $t {
#[inline]
fn div(self, other: $t) -> $t { self / other }
}
)*)
)
}
div_impl!(uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64)
div_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 }
/// The `Rem` trait is used to specify the functionality of `%`.
///
@ -441,18 +441,18 @@ pub trait Rem<Sized? RHS, Result> for Sized? {
// NOTE(stage0): Remove macro after a snapshot
#[cfg(stage0)]
macro_rules! rem_impl(
macro_rules! rem_impl {
($($t:ty)*) => ($(
impl Rem<$t, $t> for $t {
#[inline]
fn rem(&self, other: &$t) -> $t { (*self) % (*other) }
}
)*)
)
}
// NOTE(stage0): Remove macro after a snapshot
#[cfg(stage0)]
macro_rules! rem_float_impl(
macro_rules! rem_float_impl {
($t:ty, $fmod:ident) => {
impl Rem<$t, $t> for $t {
#[inline]
@ -462,7 +462,7 @@ macro_rules! rem_float_impl(
}
}
}
)
}
/// The `Rem` trait is used to specify the functionality of `%`.
///
@ -493,17 +493,17 @@ pub trait Rem<RHS, Result> {
}
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
macro_rules! rem_impl(
macro_rules! rem_impl {
($($t:ty)*) => ($(
impl Rem<$t, $t> for $t {
#[inline]
fn rem(self, other: $t) -> $t { self % other }
}
)*)
)
}
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
macro_rules! rem_float_impl(
macro_rules! rem_float_impl {
($t:ty, $fmod:ident) => {
impl Rem<$t, $t> for $t {
#[inline]
@ -513,11 +513,11 @@ macro_rules! rem_float_impl(
}
}
}
)
}
rem_impl!(uint u8 u16 u32 u64 int i8 i16 i32 i64)
rem_float_impl!(f32, fmodf)
rem_float_impl!(f64, fmod)
rem_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 }
rem_float_impl! { f32, fmodf }
rem_float_impl! { f64, fmod }
/// The `Neg` trait is used to specify the functionality of unary `-`.
///
@ -548,31 +548,31 @@ pub trait Neg<Result> for Sized? {
fn neg(&self) -> Result;
}
macro_rules! neg_impl(
macro_rules! neg_impl {
($($t:ty)*) => ($(
impl Neg<$t> for $t {
#[inline]
fn neg(&self) -> $t { -*self }
}
)*)
)
}
macro_rules! neg_uint_impl(
macro_rules! neg_uint_impl {
($t:ty, $t_signed:ty) => {
impl Neg<$t> for $t {
#[inline]
fn neg(&self) -> $t { -(*self as $t_signed) as $t }
}
}
)
}
neg_impl!(int i8 i16 i32 i64 f32 f64)
neg_impl! { int i8 i16 i32 i64 f32 f64 }
neg_uint_impl!(uint, int)
neg_uint_impl!(u8, i8)
neg_uint_impl!(u16, i16)
neg_uint_impl!(u32, i32)
neg_uint_impl!(u64, i64)
neg_uint_impl! { uint, int }
neg_uint_impl! { u8, i8 }
neg_uint_impl! { u16, i16 }
neg_uint_impl! { u32, i32 }
neg_uint_impl! { u64, i64 }
/// The `Not` trait is used to specify the functionality of unary `!`.
@ -605,16 +605,16 @@ pub trait Not<Result> for Sized? {
}
macro_rules! not_impl(
macro_rules! not_impl {
($($t:ty)*) => ($(
impl Not<$t> for $t {
#[inline]
fn not(&self) -> $t { !*self }
}
)*)
)
}
not_impl!(bool uint u8 u16 u32 u64 int i8 i16 i32 i64)
not_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 }
/// The `BitAnd` trait is used to specify the functionality of `&`.
///
@ -649,14 +649,14 @@ pub trait BitAnd<Sized? RHS, Result> for Sized? {
// NOTE(stage0): Remove macro after a snapshot
#[cfg(stage0)]
macro_rules! bitand_impl(
macro_rules! bitand_impl {
($($t:ty)*) => ($(
impl BitAnd<$t, $t> for $t {
#[inline]
fn bitand(&self, rhs: &$t) -> $t { (*self) & (*rhs) }
}
)*)
)
}
/// The `BitAnd` trait is used to specify the functionality of `&`.
///
@ -687,16 +687,16 @@ pub trait BitAnd<RHS, Result> {
}
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
macro_rules! bitand_impl(
macro_rules! bitand_impl {
($($t:ty)*) => ($(
impl BitAnd<$t, $t> for $t {
#[inline]
fn bitand(self, rhs: $t) -> $t { self & rhs }
}
)*)
)
}
bitand_impl!(bool uint u8 u16 u32 u64 int i8 i16 i32 i64)
bitand_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 }
/// The `BitOr` trait is used to specify the functionality of `|`.
///
@ -731,14 +731,14 @@ pub trait BitOr<Sized? RHS, Result> for Sized? {
// NOTE(stage0): Remove macro after a snapshot
#[cfg(stage0)]
macro_rules! bitor_impl(
macro_rules! bitor_impl {
($($t:ty)*) => ($(
impl BitOr<$t,$t> for $t {
#[inline]
fn bitor(&self, rhs: &$t) -> $t { (*self) | (*rhs) }
}
)*)
)
}
/// The `BitOr` trait is used to specify the functionality of `|`.
///
@ -769,16 +769,16 @@ pub trait BitOr<RHS, Result> {
}
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
macro_rules! bitor_impl(
macro_rules! bitor_impl {
($($t:ty)*) => ($(
impl BitOr<$t,$t> for $t {
#[inline]
fn bitor(self, rhs: $t) -> $t { self | rhs }
}
)*)
)
}
bitor_impl!(bool uint u8 u16 u32 u64 int i8 i16 i32 i64)
bitor_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 }
/// The `BitXor` trait is used to specify the functionality of `^`.
///
@ -813,14 +813,14 @@ pub trait BitXor<Sized? RHS, Result> for Sized? {
// NOTE(stage0): Remove macro after a snapshot
#[cfg(stage0)]
macro_rules! bitxor_impl(
macro_rules! bitxor_impl {
($($t:ty)*) => ($(
impl BitXor<$t, $t> for $t {
#[inline]
fn bitxor(&self, other: &$t) -> $t { (*self) ^ (*other) }
}
)*)
)
}
/// The `BitXor` trait is used to specify the functionality of `^`.
///
@ -851,16 +851,16 @@ pub trait BitXor<RHS, Result> {
}
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
macro_rules! bitxor_impl(
macro_rules! bitxor_impl {
($($t:ty)*) => ($(
impl BitXor<$t, $t> for $t {
#[inline]
fn bitxor(self, other: $t) -> $t { self ^ other }
}
)*)
)
}
bitxor_impl!(bool uint u8 u16 u32 u64 int i8 i16 i32 i64)
bitxor_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 }
/// The `Shl` trait is used to specify the functionality of `<<`.
///
@ -895,7 +895,7 @@ pub trait Shl<Sized? RHS, Result> for Sized? {
// NOTE(stage0): Remove macro after a snapshot
#[cfg(stage0)]
macro_rules! shl_impl(
macro_rules! shl_impl {
($($t:ty)*) => ($(
impl Shl<uint, $t> for $t {
#[inline]
@ -904,7 +904,7 @@ macro_rules! shl_impl(
}
}
)*)
)
}
/// The `Shl` trait is used to specify the functionality of `<<`.
///
@ -935,7 +935,7 @@ pub trait Shl<RHS, Result> {
}
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
macro_rules! shl_impl(
macro_rules! shl_impl {
($($t:ty)*) => ($(
impl Shl<uint, $t> for $t {
#[inline]
@ -944,9 +944,9 @@ macro_rules! shl_impl(
}
}
)*)
)
}
shl_impl!(uint u8 u16 u32 u64 int i8 i16 i32 i64)
shl_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 }
/// The `Shr` trait is used to specify the functionality of `>>`.
///
@ -981,14 +981,14 @@ pub trait Shr<Sized? RHS, Result> for Sized? {
// NOTE(stage0): Remove macro after a snapshot
#[cfg(stage0)]
macro_rules! shr_impl(
macro_rules! shr_impl {
($($t:ty)*) => ($(
impl Shr<uint, $t> for $t {
#[inline]
fn shr(&self, other: &uint) -> $t { (*self) >> (*other) }
}
)*)
)
}
/// The `Shr` trait is used to specify the functionality of `>>`.
///
@ -1019,16 +1019,16 @@ pub trait Shr<RHS, Result> {
}
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
macro_rules! shr_impl(
macro_rules! shr_impl {
($($t:ty)*) => ($(
impl Shr<uint, $t> for $t {
#[inline]
fn shr(self, other: uint) -> $t { self >> other }
}
)*)
)
}
shr_impl!(uint u8 u16 u32 u64 int i8 i16 i32 i64)
shr_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 }
/// The `Index` trait is used to specify the functionality of indexing operations
/// like `arr[idx]` when used in an immutable context.

View File

@ -367,7 +367,7 @@ mod externfnpointers {
self_ == other_
}
}
macro_rules! fnptreq(
macro_rules! fnptreq {
($($p:ident),*) => {
impl<_R,$($p),*> PartialEq for extern "C" fn($($p),*) -> _R {
#[inline]
@ -379,12 +379,12 @@ mod externfnpointers {
}
}
}
)
fnptreq!(A)
fnptreq!(A,B)
fnptreq!(A,B,C)
fnptreq!(A,B,C,D)
fnptreq!(A,B,C,D,E)
}
fnptreq! { A }
fnptreq! { A,B }
fnptreq! { A,B,C }
fnptreq! { A,B,C,D }
fnptreq! { A,B,C,D,E }
}
// Comparison for pointers

View File

@ -222,7 +222,7 @@
//! # #![feature(macro_rules)]
//! macro_rules! try(
//! ($e:expr) => (match $e { Ok(e) => e, Err(e) => return Err(e) })
//! )
//! );
//! # fn main() { }
//! ```
//!

View File

@ -1540,16 +1540,16 @@ macro_rules! impl_mut_int_slice {
macro_rules! impl_int_slice {
($u:ty, $s:ty) => {
impl_immut_int_slice!($u, $s, $u)
impl_immut_int_slice!($u, $s, $s)
impl_mut_int_slice!($u, $s, $u)
impl_mut_int_slice!($u, $s, $s)
impl_immut_int_slice! { $u, $s, $u }
impl_immut_int_slice! { $u, $s, $s }
impl_mut_int_slice! { $u, $s, $u }
impl_mut_int_slice! { $u, $s, $s }
}
}
impl_int_slice!(u8, i8)
impl_int_slice!(u16, i16)
impl_int_slice!(u32, i32)
impl_int_slice!(u64, i64)
impl_int_slice!(uint, int)
impl_int_slice! { u8, i8 }
impl_int_slice! { u16, i16 }
impl_int_slice! { u32, i32 }
impl_int_slice! { u64, i64 }
impl_int_slice! { uint, int }

View File

@ -174,18 +174,18 @@ impl<'a> Copy for Chars<'a> {}
// Return the initial codepoint accumulator for the first byte.
// The first byte is special, only want bottom 5 bits for width 2, 4 bits
// for width 3, and 3 bits for width 4
macro_rules! utf8_first_byte(
macro_rules! utf8_first_byte {
($byte:expr, $width:expr) => (($byte & (0x7F >> $width)) as u32)
)
}
// return the value of $ch updated with continuation byte $byte
macro_rules! utf8_acc_cont_byte(
macro_rules! utf8_acc_cont_byte {
($ch:expr, $byte:expr) => (($ch << 6) | ($byte & CONT_MASK) as u32)
)
}
macro_rules! utf8_is_cont_byte(
macro_rules! utf8_is_cont_byte {
($byte:expr) => (($byte & !CONT_MASK) == TAG_CONT_U8)
)
}
#[inline]
fn unwrap_or_0(opt: Option<&u8>) -> u8 {
@ -959,7 +959,7 @@ pub fn is_utf16(v: &[u16]) -> bool {
macro_rules! next ( ($ret:expr) => {
match it.next() { Some(u) => *u, None => return $ret }
}
)
);
loop {
let u = next!(true);
@ -1660,10 +1660,10 @@ pub trait StrPrelude for Sized? {
/// # #![feature(unboxed_closures)]
///
/// # fn main() {
/// assert_eq!("11foo1bar11".trim_chars('1'), "foo1bar")
/// assert_eq!("11foo1bar11".trim_chars('1'), "foo1bar");
/// let x: &[_] = &['1', '2'];
/// assert_eq!("12foo1bar12".trim_chars(x), "foo1bar")
/// assert_eq!("123foo1bar123".trim_chars(|&: c: char| c.is_numeric()), "foo1bar")
/// assert_eq!("12foo1bar12".trim_chars(x), "foo1bar");
/// assert_eq!("123foo1bar123".trim_chars(|&: c: char| c.is_numeric()), "foo1bar");
/// # }
/// ```
fn trim_chars<'a, C: CharEq>(&'a self, to_trim: C) -> &'a str;
@ -1680,10 +1680,10 @@ pub trait StrPrelude for Sized? {
/// # #![feature(unboxed_closures)]
///
/// # fn main() {
/// assert_eq!("11foo1bar11".trim_left_chars('1'), "foo1bar11")
/// assert_eq!("11foo1bar11".trim_left_chars('1'), "foo1bar11");
/// let x: &[_] = &['1', '2'];
/// assert_eq!("12foo1bar12".trim_left_chars(x), "foo1bar12")
/// assert_eq!("123foo1bar123".trim_left_chars(|&: c: char| c.is_numeric()), "foo1bar123")
/// assert_eq!("12foo1bar12".trim_left_chars(x), "foo1bar12");
/// assert_eq!("123foo1bar123".trim_left_chars(|&: c: char| c.is_numeric()), "foo1bar123");
/// # }
/// ```
fn trim_left_chars<'a, C: CharEq>(&'a self, to_trim: C) -> &'a str;
@ -1700,10 +1700,10 @@ pub trait StrPrelude for Sized? {
/// # #![feature(unboxed_closures)]
///
/// # fn main() {
/// assert_eq!("11foo1bar11".trim_right_chars('1'), "11foo1bar")
/// assert_eq!("11foo1bar11".trim_right_chars('1'), "11foo1bar");
/// let x: &[_] = &['1', '2'];
/// assert_eq!("12foo1bar12".trim_right_chars(x), "12foo1bar")
/// assert_eq!("123foo1bar123".trim_right_chars(|&: c: char| c.is_numeric()), "123foo1bar")
/// assert_eq!("12foo1bar12".trim_right_chars(x), "12foo1bar");
/// assert_eq!("123foo1bar123".trim_right_chars(|&: c: char| c.is_numeric()), "123foo1bar");
/// # }
/// ```
fn trim_right_chars<'a, C: CharEq>(&'a self, to_trim: C) -> &'a str;
@ -2059,7 +2059,7 @@ impl StrPrelude for str {
#[inline]
fn match_indices<'a>(&'a self, sep: &'a str) -> MatchIndices<'a> {
assert!(!sep.is_empty())
assert!(!sep.is_empty());
MatchIndices {
haystack: self,
needle: sep,

View File

@ -522,15 +522,15 @@ fn test_double_ended_chain() {
let xs = [1i, 2, 3, 4, 5];
let ys = [7i, 9, 11];
let mut it = xs.iter().chain(ys.iter()).rev();
assert_eq!(it.next().unwrap(), &11)
assert_eq!(it.next().unwrap(), &9)
assert_eq!(it.next_back().unwrap(), &1)
assert_eq!(it.next_back().unwrap(), &2)
assert_eq!(it.next_back().unwrap(), &3)
assert_eq!(it.next_back().unwrap(), &4)
assert_eq!(it.next_back().unwrap(), &5)
assert_eq!(it.next_back().unwrap(), &7)
assert_eq!(it.next_back(), None)
assert_eq!(it.next().unwrap(), &11);
assert_eq!(it.next().unwrap(), &9);
assert_eq!(it.next_back().unwrap(), &1);
assert_eq!(it.next_back().unwrap(), &2);
assert_eq!(it.next_back().unwrap(), &3);
assert_eq!(it.next_back().unwrap(), &4);
assert_eq!(it.next_back().unwrap(), &5);
assert_eq!(it.next_back().unwrap(), &7);
assert_eq!(it.next_back(), None);
}
#[test]
@ -800,7 +800,7 @@ fn test_min_max() {
#[test]
fn test_min_max_result() {
let r: MinMaxResult<int> = NoElements;
assert_eq!(r.into_option(), None)
assert_eq!(r.into_option(), None);
let r = OneElement(1i);
assert_eq!(r.into_option(), Some((1,1)));

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -202,4 +202,4 @@ mod tests {
}
}
))
));

View File

@ -62,9 +62,9 @@ mod test {
let s : Option<i16> = from_str_radix("80000", 10);
assert_eq!(s, None);
let f : Option<f32> = from_str_radix("10000000000000000000000000000000000000000", 10);
assert_eq!(f, Some(Float::infinity()))
assert_eq!(f, Some(Float::infinity()));
let fe : Option<f32> = from_str_radix("1e40", 10);
assert_eq!(fe, Some(Float::infinity()))
assert_eq!(fe, Some(Float::infinity()));
}
#[test]

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -124,4 +124,4 @@ mod tests {
assert!(5u.checked_div(0) == None);
}
}
))
));

View File

@ -213,9 +213,11 @@ pub const WARN: u32 = 2;
/// Error log level
pub const ERROR: u32 = 1;
thread_local!(static LOCAL_LOGGER: RefCell<Option<Box<Logger + Send>>> = {
RefCell::new(None)
})
thread_local! {
static LOCAL_LOGGER: RefCell<Option<Box<Logger + Send>>> = {
RefCell::new(None)
}
}
/// A trait used to represent an interface to a task-local logger. Each task
/// can have its own custom logger which can respond to logging messages

View File

@ -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!())
})
)
}

View File

@ -434,7 +434,7 @@ impl Rng for Isaac64Rng {
// See corresponding location in IsaacRng.next_u32 for
// explanation.
debug_assert!(self.cnt < RAND_SIZE_64)
debug_assert!(self.cnt < RAND_SIZE_64);
self.rsl[(self.cnt % RAND_SIZE_64) as uint]
}
}

View File

@ -232,8 +232,8 @@ mod tests {
#[test]
fn floating_point_edge_cases() {
// the test for exact equality is correct here.
assert!(ConstantRng(0xffff_ffff).gen::<f32>() != 1.0)
assert!(ConstantRng(0xffff_ffff_ffff_ffff).gen::<f64>() != 1.0)
assert!(ConstantRng(0xffff_ffff).gen::<f32>() != 1.0);
assert!(ConstantRng(0xffff_ffff_ffff_ffff).gen::<f64>() != 1.0);
}
#[test]

View File

@ -139,7 +139,7 @@ pub mod reader {
pub type DecodeResult<T> = Result<T, Error>;
// rbml reading
macro_rules! try_or(
macro_rules! try_or {
($e:expr, $r:expr) => (
match $e {
Ok(e) => e,
@ -149,7 +149,7 @@ pub mod reader {
}
}
)
)
}
pub struct Res {
pub val: uint,

View File

@ -224,7 +224,7 @@ impl<'a> Parser<'a> {
},
'(' => {
if self.peek_is(1, '?') {
try!(self.expect('?'))
try!(self.expect('?'));
try!(self.parse_group_opts())
} else {
self.caps += 1;
@ -373,7 +373,7 @@ impl<'a> Parser<'a> {
fn parse_class(&mut self) -> Result<(), Error> {
let negated =
if self.peek_is(1, '^') {
try!(self.expect('^'))
try!(self.expect('^'));
FLAG_NEGATED
} else {
FLAG_EMPTY
@ -597,7 +597,7 @@ impl<'a> Parser<'a> {
// Parses all escape sequences.
// Assumes that '\' is the current character.
fn parse_escape(&mut self) -> Result<Ast, Error> {
try!(self.noteof("an escape sequence following a '\\'"))
try!(self.noteof("an escape sequence following a '\\'"));
let c = self.cur();
if is_punct(c) {
@ -639,7 +639,7 @@ impl<'a> Parser<'a> {
let negated = if self.cur() == 'P' { FLAG_NEGATED } else { FLAG_EMPTY };
let mut name: String;
if self.peek_is(1, '{') {
try!(self.expect('{'))
try!(self.expect('{'));
let closer =
match self.pos('}') {
Some(i) => i,
@ -677,10 +677,10 @@ impl<'a> Parser<'a> {
let mut end = start + 1;
let (d2, d3) = (self.peek(1), self.peek(2));
if d2 >= Some('0') && d2 <= Some('7') {
try!(self.noteof("expected octal character in [0-7]"))
try!(self.noteof("expected octal character in [0-7]"));
end += 1;
if d3 >= Some('0') && d3 <= Some('7') {
try!(self.noteof("expected octal character in [0-7]"))
try!(self.noteof("expected octal character in [0-7]"));
end += 1;
}
}
@ -698,7 +698,7 @@ impl<'a> Parser<'a> {
// Assumes that \x has been read.
fn parse_hex(&mut self) -> Result<Ast, Error> {
if !self.peek_is(1, '{') {
try!(self.expect('{'))
try!(self.expect('{'));
return self.parse_hex_two()
}
let start = self.chari + 2;
@ -723,7 +723,7 @@ impl<'a> Parser<'a> {
let (start, end) = (self.chari, self.chari + 2);
let bad = self.slice(start - 2, self.chars.len());
try!(self.noteof(format!("Invalid hex escape sequence '{}'",
bad).as_slice()))
bad).as_slice()));
self.parse_hex_digits(self.slice(start, end).as_slice())
}
@ -743,7 +743,7 @@ impl<'a> Parser<'a> {
// is '<'.
// When done, parser will be at the closing '>' character.
fn parse_named_capture(&mut self) -> Result<(), Error> {
try!(self.noteof("a capture name"))
try!(self.noteof("a capture name"));
let closer =
match self.pos('>') {
Some(i) => i,
@ -773,7 +773,8 @@ impl<'a> Parser<'a> {
// character.
fn parse_group_opts(&mut self) -> Result<(), Error> {
if self.peek_is(1, 'P') && self.peek_is(2, '<') {
try!(self.expect('P')) try!(self.expect('<'))
try!(self.expect('P'));
try!(self.expect('<'));
return self.parse_named_capture()
}
let start = self.chari;
@ -781,7 +782,8 @@ impl<'a> Parser<'a> {
let mut sign = 1i;
let mut saw_flag = false;
loop {
try!(self.noteof("expected non-empty set of flags or closing ')'"))
try!(self.noteof(
"expected non-empty set of flags or closing ')'"));
match self.cur() {
'i' => { flags = flags | FLAG_NOCASE; saw_flag = true},
'm' => { flags = flags | FLAG_MULTI; saw_flag = true},
@ -823,7 +825,7 @@ impl<'a> Parser<'a> {
// If it is, then the next character is consumed.
fn get_next_greedy(&mut self) -> Result<Greed, Error> {
Ok(if self.peek_is(1, '?') {
try!(self.expect('?'))
try!(self.expect('?'));
Ungreedy
} else {
Greedy

View File

@ -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}

View File

@ -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))}

View File

@ -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;

View File

@ -67,7 +67,7 @@ fn range_ends_with_escape() {
assert_eq!(ms, vec![(0, 1), (1, 2)]);
}
macro_rules! replace(
macro_rules! replace {
($name:ident, $which:ident, $re:expr,
$search:expr, $replace:expr, $result:expr) => (
#[test]
@ -76,23 +76,23 @@ macro_rules! replace(
assert_eq!(re.$which($search, $replace), String::from_str($result));
}
);
)
}
replace!(rep_first, replace, r"\d", "age: 26", "Z", "age: Z6")
replace!(rep_plus, replace, r"\d+", "age: 26", "Z", "age: Z")
replace!(rep_all, replace_all, r"\d", "age: 26", "Z", "age: ZZ")
replace!(rep_groups, replace, r"(\S+)\s+(\S+)", "w1 w2", "$2 $1", "w2 w1")
replace!(rep_double_dollar, replace,
r"(\S+)\s+(\S+)", "w1 w2", "$2 $$1", "w2 $1")
replace!(rep_no_expand, replace,
r"(\S+)\s+(\S+)", "w1 w2", NoExpand("$2 $1"), "$2 $1")
replace!(rep_named, replace_all,
replace!{rep_first, replace, r"\d", "age: 26", "Z", "age: Z6"}
replace!{rep_plus, replace, r"\d+", "age: 26", "Z", "age: Z"}
replace!{rep_all, replace_all, r"\d", "age: 26", "Z", "age: ZZ"}
replace!{rep_groups, replace, r"(\S+)\s+(\S+)", "w1 w2", "$2 $1", "w2 w1"}
replace!{rep_double_dollar, replace,
r"(\S+)\s+(\S+)", "w1 w2", "$2 $$1", "w2 $1"}
replace!{rep_no_expand, replace,
r"(\S+)\s+(\S+)", "w1 w2", NoExpand("$2 $1"), "$2 $1"}
replace!{rep_named, replace_all,
r"(?P<first>\S+)\s+(?P<last>\S+)(?P<space>\s*)",
"w1 w2 w3 w4", "$last $first$space", "w2 w1 w4 w3")
replace!(rep_trim, replace_all, "^[ \t]+|[ \t]+$", " \t trim me\t \t",
"", "trim me")
"w1 w2 w3 w4", "$last $first$space", "w2 w1 w4 w3"}
replace!{rep_trim, replace_all, "^[ \t]+|[ \t]+$", " \t trim me\t \t",
"", "trim me"}
macro_rules! noparse(
macro_rules! noparse {
($name:ident, $re:expr) => (
#[test]
fn $name() {
@ -103,47 +103,47 @@ macro_rules! noparse(
}
}
);
)
}
noparse!(fail_double_repeat, "a**")
noparse!(fail_no_repeat_arg, "*")
noparse!(fail_no_repeat_arg_begin, "^*")
noparse!(fail_incomplete_escape, "\\")
noparse!(fail_class_incomplete, "[A-")
noparse!(fail_class_not_closed, "[A")
noparse!(fail_class_no_begin, r"[\A]")
noparse!(fail_class_no_end, r"[\z]")
noparse!(fail_class_no_boundary, r"[\b]")
noparse!(fail_open_paren, "(")
noparse!(fail_close_paren, ")")
noparse!(fail_invalid_range, "[a-Z]")
noparse!(fail_empty_capture_name, "(?P<>a)")
noparse!(fail_empty_capture_exp, "(?P<name>)")
noparse!(fail_bad_capture_name, "(?P<na-me>)")
noparse!(fail_bad_flag, "(?a)a")
noparse!(fail_empty_alt_before, "|a")
noparse!(fail_empty_alt_after, "a|")
noparse!(fail_counted_big_exact, "a{1001}")
noparse!(fail_counted_big_min, "a{1001,}")
noparse!(fail_counted_no_close, "a{1001")
noparse!(fail_unfinished_cap, "(?")
noparse!(fail_unfinished_escape, "\\")
noparse!(fail_octal_digit, r"\8")
noparse!(fail_hex_digit, r"\xG0")
noparse!(fail_hex_short, r"\xF")
noparse!(fail_hex_long_digits, r"\x{fffg}")
noparse!(fail_flag_bad, "(?a)")
noparse!(fail_flag_empty, "(?)")
noparse!(fail_double_neg, "(?-i-i)")
noparse!(fail_neg_empty, "(?i-)")
noparse!(fail_empty_group, "()")
noparse!(fail_dupe_named, "(?P<a>.)(?P<a>.)")
noparse!(fail_range_end_no_class, "[a-[:lower:]]")
noparse!(fail_range_end_no_begin, r"[a-\A]")
noparse!(fail_range_end_no_end, r"[a-\z]")
noparse!(fail_range_end_no_boundary, r"[a-\b]")
noparse!{fail_double_repeat, "a**"}
noparse!{fail_no_repeat_arg, "*"}
noparse!{fail_no_repeat_arg_begin, "^*"}
noparse!{fail_incomplete_escape, "\\"}
noparse!{fail_class_incomplete, "[A-"}
noparse!{fail_class_not_closed, "[A"}
noparse!{fail_class_no_begin, r"[\A]"}
noparse!{fail_class_no_end, r"[\z]"}
noparse!{fail_class_no_boundary, r"[\b]"}
noparse!{fail_open_paren, "("}
noparse!{fail_close_paren, ")"}
noparse!{fail_invalid_range, "[a-Z]"}
noparse!{fail_empty_capture_name, "(?P<>a)"}
noparse!{fail_empty_capture_exp, "(?P<name>)"}
noparse!{fail_bad_capture_name, "(?P<na-me>)"}
noparse!{fail_bad_flag, "(?a)a"}
noparse!{fail_empty_alt_before, "|a"}
noparse!{fail_empty_alt_after, "a|"}
noparse!{fail_counted_big_exact, "a{1001}"}
noparse!{fail_counted_big_min, "a{1001,}"}
noparse!{fail_counted_no_close, "a{1001"}
noparse!{fail_unfinished_cap, "(?"}
noparse!{fail_unfinished_escape, "\\"}
noparse!{fail_octal_digit, r"\8"}
noparse!{fail_hex_digit, r"\xG0"}
noparse!{fail_hex_short, r"\xF"}
noparse!{fail_hex_long_digits, r"\x{fffg}"}
noparse!{fail_flag_bad, "(?a)"}
noparse!{fail_flag_empty, "(?)"}
noparse!{fail_double_neg, "(?-i-i)"}
noparse!{fail_neg_empty, "(?i-)"}
noparse!{fail_empty_group, "()"}
noparse!{fail_dupe_named, "(?P<a>.)(?P<a>.)"}
noparse!{fail_range_end_no_class, "[a-[:lower:]]"}
noparse!{fail_range_end_no_begin, r"[a-\A]"}
noparse!{fail_range_end_no_end, r"[a-\z]"}
noparse!{fail_range_end_no_boundary, r"[a-\b]"}
macro_rules! mat(
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", "", None)
mat!(uni_boundary_ogham, r"\d\b", "6", Some((0, 1)))
mat!{uni_boundary_none, r"\d\b", "", 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.

View File

@ -10,16 +10,16 @@
#![allow(non_snake_case)]
register_diagnostic!(E0001, r##"
register_diagnostic! { E0001, r##"
This error suggests that the expression arm corresponding to the noted pattern
will never be reached as for all possible values of the expression being matched,
one of the preceeding patterns will match.
This means that perhaps some of the preceeding patterns are too general, this
one is too specific or the ordering is incorrect.
"##)
"## }
register_diagnostics!(
register_diagnostics! {
E0002,
E0003,
E0004,
@ -68,4 +68,4 @@ register_diagnostics!(
E0174,
E0177,
E0178
)
}

View File

@ -121,7 +121,7 @@ pub mod lib {
pub use llvm;
}
__build_diagnostic_array!(DIAGNOSTICS)
__build_diagnostic_array! { DIAGNOSTICS }
// A private module so that macro-expanded idents like
// `::rustc::lint::Lint` will also work in `rustc` itself.

View File

@ -50,8 +50,11 @@ use syntax::ast_util;
use syntax::ptr::P;
use syntax::visit::{mod, Visitor};
declare_lint!(WHILE_TRUE, Warn,
"suggest using `loop { }` instead of `while true { }`")
declare_lint! {
WHILE_TRUE,
Warn,
"suggest using `loop { }` instead of `while true { }`"
}
pub struct WhileTrue;
@ -74,8 +77,11 @@ impl LintPass for WhileTrue {
}
}
declare_lint!(UNUSED_TYPECASTS, Allow,
"detects unnecessary type casts, that can be removed")
declare_lint! {
UNUSED_TYPECASTS,
Allow,
"detects unnecessary type casts that can be removed"
}
pub struct UnusedCasts;
@ -96,17 +102,29 @@ impl LintPass for UnusedCasts {
}
}
declare_lint!(UNSIGNED_NEGATION, Warn,
"using an unary minus operator on unsigned type")
declare_lint! {
UNSIGNED_NEGATION,
Warn,
"using an unary minus operator on unsigned type"
}
declare_lint!(UNUSED_COMPARISONS, Warn,
"comparisons made useless by limits of the types involved")
declare_lint! {
UNUSED_COMPARISONS,
Warn,
"comparisons made useless by limits of the types involved"
}
declare_lint!(OVERFLOWING_LITERALS, Warn,
"literal out of range for its type")
declare_lint! {
OVERFLOWING_LITERALS,
Warn,
"literal out of range for its type"
}
declare_lint!(EXCEEDING_BITSHIFTS, Deny,
"shift exceeds the type's number of bits")
declare_lint! {
EXCEEDING_BITSHIFTS,
Deny,
"shift exceeds the type's number of bits"
}
pub struct TypeLimits {
/// Id of the last visited negated expression
@ -373,8 +391,11 @@ impl LintPass for TypeLimits {
}
}
declare_lint!(IMPROPER_CTYPES, Warn,
"proper use of libc types in foreign modules")
declare_lint! {
IMPROPER_CTYPES,
Warn,
"proper use of libc types in foreign modules"
}
struct ImproperCTypesVisitor<'a, 'tcx: 'a> {
cx: &'a Context<'a, 'tcx>
@ -459,8 +480,11 @@ impl LintPass for ImproperCTypes {
}
}
declare_lint!(BOX_POINTERS, Allow,
"use of owned (Box type) heap memory")
declare_lint! {
BOX_POINTERS,
Allow,
"use of owned (Box type) heap memory"
}
pub struct BoxPointers;
@ -527,8 +551,11 @@ impl LintPass for BoxPointers {
}
}
declare_lint!(RAW_POINTER_DERIVING, Warn,
"uses of #[deriving] with raw pointers are rarely correct")
declare_lint! {
RAW_POINTER_DERIVING,
Warn,
"uses of #[deriving] with raw pointers are rarely correct"
}
struct RawPtrDerivingVisitor<'a, 'tcx: 'a> {
cx: &'a Context<'a, 'tcx>
@ -594,8 +621,11 @@ impl LintPass for RawPointerDeriving {
}
}
declare_lint!(UNUSED_ATTRIBUTES, Warn,
"detects attributes that were not used by the compiler")
declare_lint! {
UNUSED_ATTRIBUTES,
Warn,
"detects attributes that were not used by the compiler"
}
pub struct UnusedAttributes;
@ -675,8 +705,11 @@ impl LintPass for UnusedAttributes {
}
}
declare_lint!(pub PATH_STATEMENTS, Warn,
"path statements with no effect")
declare_lint! {
pub PATH_STATEMENTS,
Warn,
"path statements with no effect"
}
pub struct PathStatements;
@ -701,11 +734,17 @@ impl LintPass for PathStatements {
}
}
declare_lint!(pub UNUSED_MUST_USE, Warn,
"unused result of a type flagged as #[must_use]")
declare_lint! {
pub UNUSED_MUST_USE,
Warn,
"unused result of a type flagged as #[must_use]"
}
declare_lint!(pub UNUSED_RESULTS, Allow,
"unused result of an expression in a statement")
declare_lint! {
pub UNUSED_RESULTS,
Allow,
"unused result of an expression in a statement"
}
pub struct UnusedResults;
@ -770,8 +809,11 @@ impl LintPass for UnusedResults {
}
}
declare_lint!(pub NON_CAMEL_CASE_TYPES, Warn,
"types, variants, traits and type parameters should have camel case names")
declare_lint! {
pub NON_CAMEL_CASE_TYPES,
Warn,
"types, variants, traits and type parameters should have camel case names"
}
pub struct NonCamelCaseTypes;
@ -891,8 +933,11 @@ fn method_context(cx: &Context, m: &ast::Method) -> MethodContext {
}
}
declare_lint!(pub NON_SNAKE_CASE, Warn,
"methods, functions, lifetime parameters and modules should have snake case names")
declare_lint! {
pub NON_SNAKE_CASE,
Warn,
"methods, functions, lifetime parameters and modules should have snake case names"
}
pub struct NonSnakeCase;
@ -1002,8 +1047,11 @@ impl LintPass for NonSnakeCase {
}
}
declare_lint!(pub NON_UPPER_CASE_GLOBALS, Warn,
"static constants should have uppercase identifiers")
declare_lint! {
pub NON_UPPER_CASE_GLOBALS,
Warn,
"static constants should have uppercase identifiers"
}
pub struct NonUpperCaseGlobals;
@ -1053,8 +1101,11 @@ impl LintPass for NonUpperCaseGlobals {
}
}
declare_lint!(UNUSED_PARENS, Warn,
"`if`, `match`, `while` and `return` do not need parentheses")
declare_lint! {
UNUSED_PARENS,
Warn,
"`if`, `match`, `while` and `return` do not need parentheses"
}
pub struct UnusedParens;
@ -1145,8 +1196,11 @@ impl LintPass for UnusedParens {
}
}
declare_lint!(UNUSED_IMPORT_BRACES, Allow,
"unnecessary braces around an imported item")
declare_lint! {
UNUSED_IMPORT_BRACES,
Allow,
"unnecessary braces around an imported item"
}
pub struct UnusedImportBraces;
@ -1182,8 +1236,11 @@ impl LintPass for UnusedImportBraces {
}
}
declare_lint!(NON_SHORTHAND_FIELD_PATTERNS, Warn,
"using `Struct { x: x }` instead of `Struct { x }`")
declare_lint! {
NON_SHORTHAND_FIELD_PATTERNS,
Warn,
"using `Struct { x: x }` instead of `Struct { x }`"
}
pub struct NonShorthandFieldPatterns;
@ -1213,8 +1270,11 @@ impl LintPass for NonShorthandFieldPatterns {
}
}
declare_lint!(pub UNUSED_UNSAFE, Warn,
"unnecessary use of an `unsafe` block")
declare_lint! {
pub UNUSED_UNSAFE,
Warn,
"unnecessary use of an `unsafe` block"
}
pub struct UnusedUnsafe;
@ -1236,8 +1296,11 @@ impl LintPass for UnusedUnsafe {
}
}
declare_lint!(UNSAFE_BLOCKS, Allow,
"usage of an `unsafe` block")
declare_lint! {
UNSAFE_BLOCKS,
Allow,
"usage of an `unsafe` block"
}
pub struct UnsafeBlocks;
@ -1258,8 +1321,11 @@ impl LintPass for UnsafeBlocks {
}
}
declare_lint!(pub UNUSED_MUT, Warn,
"detect mut variables which don't need to be mutable")
declare_lint! {
pub UNUSED_MUT,
Warn,
"detect mut variables which don't need to be mutable"
}
pub struct UnusedMut;
@ -1325,8 +1391,11 @@ impl LintPass for UnusedMut {
}
}
declare_lint!(UNUSED_ALLOCATION, Warn,
"detects unnecessary allocations that can be eliminated")
declare_lint! {
UNUSED_ALLOCATION,
Warn,
"detects unnecessary allocations that can be eliminated"
}
pub struct UnusedAllocation;
@ -1361,8 +1430,11 @@ impl LintPass for UnusedAllocation {
}
}
declare_lint!(MISSING_DOCS, Allow,
"detects missing documentation for public members")
declare_lint! {
MISSING_DOCS,
Allow,
"detects missing documentation for public members"
}
pub struct MissingDoc {
/// Stack of IDs of struct definitions.
@ -1572,15 +1644,24 @@ impl LintPass for MissingCopyImplementations {
}
}
declare_lint!(DEPRECATED, Warn,
"detects use of #[deprecated] items")
declare_lint! {
DEPRECATED,
Warn,
"detects use of #[deprecated] items"
}
// FIXME #6875: Change to Warn after std library stabilization is complete
declare_lint!(EXPERIMENTAL, Allow,
"detects use of #[experimental] items")
declare_lint! {
EXPERIMENTAL,
Allow,
"detects use of #[experimental] items"
}
declare_lint!(UNSTABLE, Allow,
"detects use of #[unstable] items (incl. items with no stability attribute)")
declare_lint! {
UNSTABLE,
Allow,
"detects use of #[unstable] items (incl. items with no stability attribute)"
}
/// Checks for use of items with `#[deprecated]`, `#[experimental]` and
/// `#[unstable]` attributes, or no stability attribute.
@ -1738,47 +1819,89 @@ impl LintPass for Stability {
}
}
declare_lint!(pub UNUSED_IMPORTS, Warn,
"imports that are never used")
declare_lint! {
pub UNUSED_IMPORTS,
Warn,
"imports that are never used"
}
declare_lint!(pub UNUSED_EXTERN_CRATES, Allow,
"extern crates that are never used")
declare_lint! {
pub UNUSED_EXTERN_CRATES,
Allow,
"extern crates that are never used"
}
declare_lint!(pub UNUSED_QUALIFICATIONS, Allow,
"detects unnecessarily qualified names")
declare_lint! {
pub UNUSED_QUALIFICATIONS,
Allow,
"detects unnecessarily qualified names"
}
declare_lint!(pub UNKNOWN_LINTS, Warn,
"unrecognized lint attribute")
declare_lint! {
pub UNKNOWN_LINTS,
Warn,
"unrecognized lint attribute"
}
declare_lint!(pub UNUSED_VARIABLES, Warn,
"detect variables which are not used in any way")
declare_lint! {
pub UNUSED_VARIABLES,
Warn,
"detect variables which are not used in any way"
}
declare_lint!(pub UNUSED_ASSIGNMENTS, Warn,
"detect assignments that will never be read")
declare_lint! {
pub UNUSED_ASSIGNMENTS,
Warn,
"detect assignments that will never be read"
}
declare_lint!(pub DEAD_CODE, Warn,
"detect unused, unexported items")
declare_lint! {
pub DEAD_CODE,
Warn,
"detect unused, unexported items"
}
declare_lint!(pub UNREACHABLE_CODE, Warn,
"detects unreachable code paths")
declare_lint! {
pub UNREACHABLE_CODE,
Warn,
"detects unreachable code paths"
}
declare_lint!(pub WARNINGS, Warn,
"mass-change the level for lints which produce warnings")
declare_lint! {
pub WARNINGS,
Warn,
"mass-change the level for lints which produce warnings"
}
declare_lint!(pub UNKNOWN_FEATURES, Deny,
"unknown features found in crate-level #[feature] directives")
declare_lint! {
pub UNKNOWN_FEATURES,
Deny,
"unknown features found in crate-level #[feature] directives"
}
declare_lint!(pub UNKNOWN_CRATE_TYPES, Deny,
"unknown crate type found in #[crate_type] directive")
declare_lint! {
pub UNKNOWN_CRATE_TYPES,
Deny,
"unknown crate type found in #[crate_type] directive"
}
declare_lint!(pub VARIANT_SIZE_DIFFERENCES, Allow,
"detects enums with widely varying variant sizes")
declare_lint! {
pub VARIANT_SIZE_DIFFERENCES,
Allow,
"detects enums with widely varying variant sizes"
}
declare_lint!(pub FAT_PTR_TRANSMUTES, Allow,
"detects transmutes of fat pointers")
declare_lint! {
pub FAT_PTR_TRANSMUTES,
Allow,
"detects transmutes of fat pointers"
}
declare_lint!(pub MISSING_COPY_IMPLEMENTATIONS, Warn,
"detects potentially-forgotten implementations of `Copy`")
declare_lint!{
pub MISSING_COPY_IMPLEMENTATIONS,
Warn,
"detects potentially-forgotten implementations of `Copy`"
}
/// Does nothing as a lint pass, but registers some `Lint`s
/// which are used by other parts of the compiler.

View File

@ -171,17 +171,17 @@ impl LintStore {
{$(
self.register_pass($sess, false, box builtin::$name as LintPassObject);
)*}
))
));
macro_rules! add_builtin_with_new ( ( $sess:ident, $($name:ident),*, ) => (
{$(
self.register_pass($sess, false, box builtin::$name::new() as LintPassObject);
)*}
))
));
macro_rules! add_lint_group ( ( $sess:ident, $name:expr, $($lint:ident),* ) => (
self.register_group($sess, false, $name, vec![$(LintId::of(builtin::$lint)),*]);
))
));
add_builtin!(sess,
HardwiredLints,
@ -204,21 +204,21 @@ impl LintStore {
UnusedAllocation,
Stability,
MissingCopyImplementations,
)
);
add_builtin_with_new!(sess,
TypeLimits,
RawPointerDeriving,
MissingDoc,
)
);
add_lint_group!(sess, "bad_style",
NON_CAMEL_CASE_TYPES, NON_SNAKE_CASE, NON_UPPER_CASE_GLOBALS)
NON_CAMEL_CASE_TYPES, NON_SNAKE_CASE, NON_UPPER_CASE_GLOBALS);
add_lint_group!(sess, "unused",
UNUSED_IMPORTS, UNUSED_VARIABLES, UNUSED_ASSIGNMENTS, DEAD_CODE,
UNUSED_MUT, UNREACHABLE_CODE, UNUSED_MUST_USE,
UNUSED_UNSAFE, PATH_STATEMENTS)
UNUSED_UNSAFE, PATH_STATEMENTS);
// We have one lint pass defined in this module.
self.register_pass(sess, false, box GatherNodeLevels as LintPassObject);
@ -318,7 +318,7 @@ pub struct Context<'a, 'tcx: 'a> {
}
/// Convenience macro for calling a `LintPass` method on every pass in the context.
macro_rules! run_lints ( ($cx:expr, $f:ident, $($args:expr),*) => ({
macro_rules! run_lints { ($cx:expr, $f:ident, $($args:expr),*) => ({
// Move the vector of passes out of `$cx` so that we can
// iterate over it mutably while passing `$cx` to the methods.
let mut passes = $cx.lints.passes.take().unwrap();
@ -326,7 +326,7 @@ macro_rules! run_lints ( ($cx:expr, $f:ident, $($args:expr),*) => ({
obj.$f($cx, $($args),*);
}
$cx.lints.passes = Some(passes);
}))
}) }
/// Parse the lint attributes into a vector, with `Err`s for malformed lint
/// attributes. Writing this as an iterator is an enormous mess.

View File

@ -75,7 +75,7 @@ impl Lint {
/// Build a `Lint` initializer.
#[macro_export]
macro_rules! lint_initializer (
macro_rules! lint_initializer {
($name:ident, $level:ident, $desc:expr) => (
::rustc::lint::Lint {
name: stringify!($name),
@ -83,11 +83,11 @@ macro_rules! lint_initializer (
desc: $desc,
}
)
)
}
/// Declare a static item of type `&'static Lint`.
#[macro_export]
macro_rules! declare_lint (
macro_rules! declare_lint {
// FIXME(#14660): deduplicate
(pub $name:ident, $level:ident, $desc:expr) => (
pub static $name: &'static ::rustc::lint::Lint
@ -97,17 +97,17 @@ macro_rules! declare_lint (
static $name: &'static ::rustc::lint::Lint
= &lint_initializer!($name, $level, $desc);
);
)
}
/// Declare a static `LintArray` and return it as an expression.
#[macro_export]
macro_rules! lint_array ( ($( $lint:expr ),*) => (
macro_rules! lint_array { ($( $lint:expr ),*) => (
{
#[allow(non_upper_case_globals)]
static array: LintArray = &[ $( &$lint ),* ];
array
}
))
) }
pub type LintArray = &'static [&'static &'static Lint];

View File

@ -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,

View File

@ -525,7 +525,7 @@ pub fn eval_const_expr_partial(tcx: &ty::ctxt, e: &Expr) -> Result<const_val, St
},)*
_ => Err("can't cast this type".to_string())
})
)
);
eval_const_expr_partial(tcx, &**base)
.and_then(|val| define_casts!(val, {

View File

@ -320,14 +320,14 @@ pub struct ExprUseVisitor<'d,'t,'tcx,TYPER:'t> {
//
// Note that this macro appears similar to try!(), but, unlike try!(),
// it does not propagate the error.
macro_rules! return_if_err(
macro_rules! return_if_err {
($inp: expr) => (
match $inp {
Ok(v) => v,
Err(()) => return
}
)
)
}
/// Whether the elements of an overloaded operation are passed by value or by reference
enum PassArgs {

View File

@ -224,7 +224,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
for error in errors.iter() {
match error.clone() {
ConcreteFailure(origin, sub, sup) => {
debug!("processing ConcreteFailure")
debug!("processing ConcreteFailure");
let trace = match origin {
infer::Subtype(trace) => Some(trace),
_ => None,
@ -241,7 +241,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
}
}
SubSupConflict(var_origin, _, sub_r, _, sup_r) => {
debug!("processing SubSupConflict")
debug!("processing SubSupConflict");
match free_regions_from_same_fn(self.tcx, sub_r, sup_r) {
Some(ref same_frs) => {
var_origins.push(var_origin);
@ -324,7 +324,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
_ => None
},
None => {
debug!("no parent node of scope_id {}", scope_id)
debug!("no parent node of scope_id {}", scope_id);
None
}
}

View File

@ -389,14 +389,14 @@ impl MutabilityCategory {
}
}
macro_rules! if_ok(
macro_rules! if_ok {
($inp: expr) => (
match $inp {
Ok(v) => { v }
Err(e) => { return Err(e); }
}
)
)
}
impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
pub fn new(typer: &'t TYPER) -> MemCategorizationContext<'t,TYPER> {

View File

@ -1223,7 +1223,7 @@ pub fn mk_prim_t<'tcx>(primitive: &'tcx TyS<'static>) -> Ty<'tcx> {
// Do not change these from static to const, interning types requires
// the primitives to have a significant address.
macro_rules! def_prim_tys(
macro_rules! def_prim_tys {
($($name:ident -> $sty:expr;)*) => (
$(#[inline] pub fn $name<'tcx>() -> Ty<'tcx> {
static PRIM_TY: TyS<'static> = TyS {
@ -1234,7 +1234,7 @@ macro_rules! def_prim_tys(
mk_prim_t(&PRIM_TY)
})*
)
)
}
def_prim_tys!{
mk_bool -> ty_bool;
@ -2739,7 +2739,7 @@ pub struct TypeContents {
impl Copy for TypeContents {}
macro_rules! def_type_content_sets(
macro_rules! def_type_content_sets {
(mod $mname:ident { $($name:ident = $bits:expr),+ }) => {
#[allow(non_snake_case)]
mod $mname {
@ -2750,9 +2750,9 @@ macro_rules! def_type_content_sets(
)+
}
}
)
}
def_type_content_sets!(
def_type_content_sets! {
mod TC {
None = 0b0000_0000__0000_0000__0000,
@ -2790,7 +2790,7 @@ def_type_content_sets!(
// All bits
All = 0b1111_1111__1111_1111__1111
}
)
}
impl TypeContents {
pub fn when(&self, cond: bool) -> TypeContents {
@ -3113,7 +3113,7 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
ty_open(ty) => {
let result = tc_ty(cx, ty, cache);
assert!(!result.is_sized(cx))
assert!(!result.is_sized(cx));
result.unsafe_pointer() | TC::Nonsized
}
@ -3644,7 +3644,7 @@ pub fn unsized_part_of_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
let unsized_fields: Vec<_> = struct_fields(cx, def_id, substs).iter()
.map(|f| f.mt.ty).filter(|ty| !type_is_sized(cx, *ty)).collect();
// Exactly one of the fields must be unsized.
assert!(unsized_fields.len() == 1)
assert!(unsized_fields.len() == 1);
unsized_part_of_type(cx, unsized_fields[0])
}

View File

@ -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;
)
}

View File

@ -239,17 +239,17 @@ pub enum CrateType {
impl Copy for CrateType {}
macro_rules! debugging_opts(
macro_rules! debugging_opts {
([ $opt:ident ] $cnt:expr ) => (
pub const $opt: u64 = 1 << $cnt;
);
([ $opt:ident, $($rest:ident),* ] $cnt:expr ) => (
pub const $opt: u64 = 1 << $cnt;
debugging_opts!([ $($rest),* ] $cnt + 1)
debugging_opts! { [ $($rest),* ] $cnt + 1 }
)
)
}
debugging_opts!(
debugging_opts! {
[
VERBOSE,
TIME_PASSES,
@ -280,7 +280,7 @@ debugging_opts!(
PRINT_REGION_GRAPH
]
0
)
}
pub fn debugging_opts_map() -> Vec<(&'static str, &'static str, u64)> {
vec![("verbose", "in general, enable more debug printouts", VERBOSE),
@ -354,7 +354,7 @@ impl Passes {
/// cgsetters module which is a bunch of generated code to parse an option into
/// its respective field in the struct. There are a few hand-written parsers for
/// parsing specific types of values in this module.
macro_rules! cgoptions(
macro_rules! cgoptions {
($($opt:ident : $t:ty = ($init:expr, $parse:ident, $desc:expr)),* ,) =>
(
#[deriving(Clone)]
@ -469,9 +469,9 @@ macro_rules! cgoptions(
}
}
}
) )
) }
cgoptions!(
cgoptions! {
ar: Option<String> = (None, parse_opt_string,
"tool to assemble archives with"),
linker: Option<String> = (None, parse_opt_string,
@ -520,7 +520,7 @@ cgoptions!(
"print remarks for these optimization passes (space separated, or \"all\")"),
no_stack_check: bool = (false, parse_bool,
"disable checks for stack exhaustion (a memory-safety hazard!)"),
)
}
pub fn build_codegen_options(matches: &getopts::Matches) -> CodegenOptions
{

View File

@ -349,7 +349,7 @@ impl Engine256State {
macro_rules! schedule_round( ($t:expr) => (
w[$t] = sigma1(w[$t - 2]) + w[$t - 7] + sigma0(w[$t - 15]) + w[$t - 16];
)
)
);
macro_rules! sha2_round(
($A:ident, $B:ident, $C:ident, $D:ident,
@ -360,7 +360,7 @@ impl Engine256State {
$H += sum0($A) + maj($A, $B, $C);
}
)
)
);
read_u32v_be(w[mut 0..16], data);
@ -454,7 +454,7 @@ impl Engine256 {
}
fn input(&mut self, input: &[u8]) {
assert!(!self.finished)
assert!(!self.finished);
// Assumes that input.len() can be converted to u64 without overflow
self.length_bits = add_bytes_to_bits(self.length_bits, input.len() as u64);
let self_state = &mut self.state;

View File

@ -340,14 +340,17 @@ mod svh_visitor {
// expensive; a direct content-based hash on token
// trees might be faster. Implementing this is far
// easier in short term.
let macro_defn_as_string =
pprust::to_string(|pp_state| pp_state.print_mac(macro));
let macro_defn_as_string = pprust::to_string(|pp_state| {
pp_state.print_mac(macro, token::Paren)
});
macro_defn_as_string.hash(self.st);
} else {
// It is not possible to observe any kind of macro
// invocation at this stage except `macro_rules!`.
panic!("reached macro somehow: {}",
pprust::to_string(|pp_state| pp_state.print_mac(macro)));
pprust::to_string(|pp_state| {
pp_state.print_mac(macro, token::Paren)
}));
}
visit::walk_mac(self, macro);

View File

@ -256,7 +256,7 @@ impl Target {
)
);
} );
)
);
key!(cpu);
key!(linker);
@ -325,7 +325,7 @@ impl Target {
}
}
)
)
);
load_specific!(
x86_64_unknown_linux_gnu,
@ -348,7 +348,7 @@ impl Target {
x86_64_pc_windows_gnu,
i686_pc_windows_gnu
)
);
let path = Path::new(target);

View File

@ -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;

View File

@ -2290,5 +2290,5 @@ pub unsafe fn static_link_hack_this_sucks() {
// Works to the above fix for #15460 to ensure LLVM dependencies that
// are only used by rustllvm don't get stripped by the linker.
mod llvmdeps {
include!(env!("CFG_LLVM_LINKAGE_FILE"))
include! { env!("CFG_LLVM_LINKAGE_FILE") }
}

View File

@ -676,7 +676,7 @@ fn extract_vec_elems<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
// pattern. Note that, because the macro is well-typed, either ALL of the
// matches should fit that sort of pattern or NONE (however, some of the
// matches may be wildcards like _ or identifiers).
macro_rules! any_pat (
macro_rules! any_pat {
($m:expr, $col:expr, $pattern:pat) => (
($m).iter().any(|br| {
match br.pats[$col].node {
@ -685,7 +685,7 @@ macro_rules! any_pat (
}
})
)
)
}
fn any_uniq_pat(m: &[Match], col: uint) -> bool {
any_pat!(m, col, ast::PatBox(_))

View File

@ -147,7 +147,7 @@ pub fn represent_type<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
}
let repr = Rc::new(represent_type_uncached(cx, t));
debug!("Represented as: {}", repr)
debug!("Represented as: {}", repr);
cx.adt_reprs().borrow_mut().insert(t, repr.clone());
repr
}

View File

@ -103,9 +103,11 @@ use syntax::visit::Visitor;
use syntax::visit;
use syntax::{ast, ast_util, ast_map};
thread_local!(static TASK_LOCAL_INSN_KEY: RefCell<Option<Vec<&'static str>>> = {
RefCell::new(None)
})
thread_local! {
static TASK_LOCAL_INSN_KEY: RefCell<Option<Vec<&'static str>>> = {
RefCell::new(None)
}
}
pub fn with_insn_ctxt<F>(blk: F) where
F: FnOnce(&[&'static str]),

View File

@ -749,10 +749,10 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef
return Some(f);
}
)
)
);
macro_rules! mk_struct (
($($field_ty:expr),*) => (Type::struct_(ccx, &[$($field_ty),*], false))
)
);
let i8p = Type::i8p(ccx);
let void = Type::void(ccx);
@ -886,7 +886,7 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef
return Some(f);
}
)
)
);
compatible_ifn!("llvm.copysign.f32", copysignf(t_f32, t_f32) -> t_f32);
compatible_ifn!("llvm.copysign.f64", copysign(t_f64, t_f64) -> t_f64);

View File

@ -583,7 +583,7 @@ impl<'tcx, K: KindOps + fmt::Show> Datum<'tcx, K> {
}
pub fn to_llbool<'blk>(self, bcx: Block<'blk, 'tcx>) -> ValueRef {
assert!(ty::type_is_bool(self.ty))
assert!(ty::type_is_bool(self.ty));
self.to_llscalarish(bcx)
}
}

View File

@ -634,7 +634,7 @@ impl<'tcx> TypeMap<'tcx> {
// Returns from the enclosing function if the type metadata with the given
// unique id can be found in the type map
macro_rules! return_if_metadata_created_in_meantime(
macro_rules! return_if_metadata_created_in_meantime {
($cx: expr, $unique_type_id: expr) => (
match debug_context($cx).type_map
.borrow()
@ -643,7 +643,7 @@ macro_rules! return_if_metadata_created_in_meantime(
None => { /* proceed normally */ }
};
)
)
}
/// A context object for maintaining all state needed by the debuginfo module.

View File

@ -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
}
)
)
}

View File

@ -33,9 +33,9 @@ pub struct Type {
impl Copy for Type {}
macro_rules! ty (
macro_rules! ty {
($e:expr) => ( Type::from_ref(unsafe { $e }))
)
}
/// Wrapper for LLVM TypeRef
impl Type {

View File

@ -18,14 +18,14 @@ pub struct Value(pub ValueRef);
impl Copy for Value {}
macro_rules! opt_val ( ($e:expr) => (
macro_rules! opt_val { ($e:expr) => (
unsafe {
match $e {
p if p.is_not_null() => Some(Value(p)),
_ => None
}
}
))
) }
/// Wrapper for LLVM ValueRef
impl Value {

View File

@ -199,14 +199,14 @@ pub fn regionck_ensure_component_tys_wf<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
// check failed (or will fail, when the error is uncovered and
// reported during writeback). In this case, we just ignore this part
// of the code and don't try to add any more region constraints.
macro_rules! ignore_err(
macro_rules! ignore_err {
($inp: expr) => (
match $inp {
Ok(v) => v,
Err(()) => return
}
)
)
}
// Stores parameters for a potential call to link_region()
// to perform if an upvar reference is marked unique/mutable after

View File

@ -10,16 +10,18 @@
#![allow(non_snake_case)]
register_diagnostic!(E0001, r##"
register_diagnostic! {
E0001,
r##"
This error suggests that the expression arm corresponding to the noted pattern
will never be reached as for all possible values of the expression being matched,
one of the preceeding patterns will match.
This means that perhaps some of the preceeding patterns are too general, this
one is too specific or the ordering is incorrect.
"##)
"## }
register_diagnostics!(
register_diagnostics! {
E0002,
E0003,
E0004,
@ -156,4 +158,4 @@ register_diagnostics!(
E0181,
E0182,
E0183
)
}

View File

@ -779,7 +779,7 @@ The counts do not include methods or trait
implementations that are visible only through a re-exported type.",
stable, unstable, experimental, deprecated, unmarked,
name=self.name));
try!(write!(f, "<table>"))
try!(write!(f, "<table>"));
try!(fmt_inner(f, &mut context, self));
write!(f, "</table>")
}

View File

@ -149,12 +149,12 @@ fn stripped_filtered_line<'a>(s: &'a str) -> Option<&'a str> {
thread_local!(static USED_HEADER_MAP: RefCell<HashMap<String, uint>> = {
RefCell::new(HashMap::new())
})
thread_local!(static TEST_IDX: Cell<uint> = Cell::new(0))
});
thread_local!(static TEST_IDX: Cell<uint> = Cell::new(0));
thread_local!(pub static PLAYGROUND_KRATE: RefCell<Option<Option<String>>> = {
RefCell::new(None)
})
});
pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
extern fn block(ob: *mut hoedown_buffer, orig_text: *const hoedown_buffer,

View File

@ -246,9 +246,9 @@ struct IndexItem {
// TLS keys used to carry information around during rendering.
thread_local!(static CACHE_KEY: RefCell<Arc<Cache>> = Default::default())
thread_local!(static CACHE_KEY: RefCell<Arc<Cache>> = Default::default());
thread_local!(pub static CURRENT_LOCATION_KEY: RefCell<Vec<String>> =
RefCell::new(Vec::new()))
RefCell::new(Vec::new()));
/// Generates the documentation for `crate` into the directory `dst`
pub fn run(mut krate: clean::Crate,

View File

@ -93,7 +93,7 @@ static DEFAULT_PASSES: &'static [&'static str] = &[
thread_local!(pub static ANALYSISKEY: Rc<RefCell<Option<core::CrateAnalysis>>> = {
Rc::new(RefCell::new(None))
})
});
struct Output {
krate: clean::Crate,

View File

@ -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)*))
)
}

View File

@ -385,7 +385,7 @@ mod tests {
#[test]
fn test_from_base64_invalid_char() {
assert!("Zm$=".from_base64().is_err())
assert!("Zm$=".from_base64().is_err());
assert!("Zg==$".from_base64().is_err());
}

View File

@ -1970,7 +1970,7 @@ impl Decoder {
}
}
macro_rules! expect(
macro_rules! expect {
($e:expr, Null) => ({
match $e {
Json::Null => Ok(()),
@ -1987,7 +1987,7 @@ macro_rules! expect(
}
}
})
)
}
macro_rules! read_primitive {
($name:ident, $ty:ty) => {
@ -2020,16 +2020,16 @@ impl ::Decoder<DecoderError> for Decoder {
expect!(self.pop(), Null)
}
read_primitive!(read_uint, uint)
read_primitive!(read_u8, u8)
read_primitive!(read_u16, u16)
read_primitive!(read_u32, u32)
read_primitive!(read_u64, u64)
read_primitive!(read_int, int)
read_primitive!(read_i8, i8)
read_primitive!(read_i16, i16)
read_primitive!(read_i32, i32)
read_primitive!(read_i64, i64)
read_primitive! { read_uint, uint }
read_primitive! { read_u8, u8 }
read_primitive! { read_u16, u16 }
read_primitive! { read_u32, u32 }
read_primitive! { read_u64, u64 }
read_primitive! { read_int, int }
read_primitive! { read_i8, i8 }
read_primitive! { read_i16, i16 }
read_primitive! { read_i32, i32 }
read_primitive! { read_i64, i64 }
fn read_f32(&mut self) -> DecodeResult<f32> { self.read_f64().map(|x| x as f32) }
@ -2298,25 +2298,25 @@ pub trait ToJson for Sized? {
fn to_json(&self) -> Json;
}
macro_rules! to_json_impl_i64(
macro_rules! to_json_impl_i64 {
($($t:ty), +) => (
$(impl ToJson for $t {
fn to_json(&self) -> Json { Json::I64(*self as i64) }
})+
)
)
}
to_json_impl_i64!(int, i8, i16, i32, i64)
to_json_impl_i64! { int, i8, i16, i32, i64 }
macro_rules! to_json_impl_u64(
macro_rules! to_json_impl_u64 {
($($t:ty), +) => (
$(impl ToJson for $t {
fn to_json(&self) -> Json { Json::U64(*self as u64) }
})+
)
)
}
to_json_impl_u64!(uint, u8, u16, u32, u64)
to_json_impl_u64! { uint, u8, u16, u32, u64 }
impl ToJson for Json {
fn to_json(&self) -> Json { self.clone() }
@ -2730,7 +2730,7 @@ mod tests {
);
}
macro_rules! check_encoder_for_simple(
macro_rules! check_encoder_for_simple {
($value:expr, $expected:expr) => ({
let s = with_str_writer(|writer| {
let mut encoder = Encoder::new(writer);
@ -2744,7 +2744,7 @@ mod tests {
});
assert_eq!(s, $expected);
})
)
}
#[test]
fn test_write_some() {
@ -2948,7 +2948,7 @@ mod tests {
#[test]
fn test_decode_tuple() {
let t: (uint, uint, uint) = super::decode("[1, 2, 3]").unwrap();
assert_eq!(t, (1u, 2, 3))
assert_eq!(t, (1u, 2, 3));
let t: (uint, string::String) = super::decode("[1, \"two\"]").unwrap();
assert_eq!(t, (1u, "two".into_string()));

Some files were not shown because too many files have changed in this diff Show More