diff options
Diffstat (limited to 'src/libstd')
39 files changed, 472 insertions, 463 deletions
diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index edf88a84893..c436de0d193 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -638,14 +638,14 @@ mod tests { use char::from_u32; use str::StrPrelude; - macro_rules! v2ascii ( + macro_rules! v2ascii { ( [$($e:expr),*]) => (&[$(Ascii{chr:$e}),*]); (&[$($e:expr),*]) => (&[$(Ascii{chr:$e}),*]); - ) + } - macro_rules! vec2ascii ( + macro_rules! vec2ascii { ($($e:expr),*) => ([$(Ascii{chr:$e}),*].to_vec()); - ) + } #[test] fn test_ascii() { @@ -788,7 +788,7 @@ mod tests { let upper = if 'a' as u32 <= i && i <= 'z' as u32 { i + 'A' as u32 - 'a' as u32 } else { i }; assert_eq!((from_u32(i).unwrap()).to_string().to_ascii_upper(), - (from_u32(upper).unwrap()).to_string()) + (from_u32(upper).unwrap()).to_string()); i += 1; } } @@ -804,7 +804,7 @@ mod tests { let lower = if 'A' as u32 <= i && i <= 'Z' as u32 { i + 'a' as u32 - 'A' as u32 } else { i }; assert_eq!((from_u32(i).unwrap()).to_string().to_ascii_lower(), - (from_u32(lower).unwrap()).to_string()) + (from_u32(lower).unwrap()).to_string()); i += 1; } } @@ -820,7 +820,7 @@ mod tests { let upper = if 'a' as u32 <= i && i <= 'z' as u32 { i + 'A' as u32 - 'a' as u32 } else { i }; assert_eq!((from_u32(i).unwrap()).to_string().into_ascii_upper(), - (from_u32(upper).unwrap()).to_string()) + (from_u32(upper).unwrap()).to_string()); i += 1; } } @@ -837,7 +837,7 @@ mod tests { let lower = if 'A' as u32 <= i && i <= 'Z' as u32 { i + 'a' as u32 - 'A' as u32 } else { i }; assert_eq!((from_u32(i).unwrap()).to_string().into_ascii_lower(), - (from_u32(lower).unwrap()).to_string()) + (from_u32(lower).unwrap()).to_string()); i += 1; } } diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 0ff29a94f2f..04dd5afdfa2 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -1471,7 +1471,7 @@ mod test_map { assert_eq!(*m.get(&2).unwrap(), 4); } - thread_local!(static DROP_VECTOR: RefCell<Vec<int>> = RefCell::new(Vec::new())) + thread_local! { static DROP_VECTOR: RefCell<Vec<int>> = RefCell::new(Vec::new()) } #[deriving(Hash, PartialEq, Eq)] struct Dropable { diff --git a/src/libstd/comm/mod.rs b/src/libstd/comm/mod.rs index 72ddbe19f54..29a7b0dd0cc 100644 --- a/src/libstd/comm/mod.rs +++ b/src/libstd/comm/mod.rs @@ -136,7 +136,7 @@ //! select! { //! val = rx.recv() => println!("Received {}", val), //! () = timeout.recv() => { -//! println!("timed out, total time was more than 10 seconds") +//! println!("timed out, total time was more than 10 seconds"); //! break; //! } //! } @@ -160,7 +160,7 @@ //! select! { //! val = rx.recv() => println!("Received {}", val), //! () = timeout.recv() => { -//! println!("timed out, no message received in 5 seconds") +//! println!("timed out, no message received in 5 seconds"); //! break; //! } //! } @@ -331,7 +331,7 @@ use rustrt::task::BlockedTask; pub use comm::select::{Select, Handle}; -macro_rules! test ( +macro_rules! test { { fn $name:ident() $b:block $(#[$a:meta])*} => ( mod $name { #![allow(unused_imports)] @@ -347,7 +347,7 @@ macro_rules! test ( $(#[$a])* #[test] fn f() { $b } } ) -) +} mod oneshot; mod select; @@ -1036,70 +1036,70 @@ mod test { } } - test!(fn smoke() { + test! { fn smoke() { let (tx, rx) = channel::<int>(); tx.send(1); assert_eq!(rx.recv(), 1); - }) + } } - test!(fn drop_full() { + test! { fn drop_full() { let (tx, _rx) = channel(); tx.send(box 1i); - }) + } } - test!(fn drop_full_shared() { + test! { fn drop_full_shared() { let (tx, _rx) = channel(); drop(tx.clone()); drop(tx.clone()); tx.send(box 1i); - }) + } } - test!(fn smoke_shared() { + test! { fn smoke_shared() { let (tx, rx) = channel::<int>(); tx.send(1); assert_eq!(rx.recv(), 1); let tx = tx.clone(); tx.send(1); assert_eq!(rx.recv(), 1); - }) + } } - test!(fn smoke_threads() { + test! { fn smoke_threads() { let (tx, rx) = channel::<int>(); spawn(move|| { tx.send(1); }); assert_eq!(rx.recv(), 1); - }) + } } - test!(fn smoke_port_gone() { + test! { fn smoke_port_gone() { let (tx, rx) = channel::<int>(); drop(rx); tx.send(1); - } #[should_fail]) + } #[should_fail] } - test!(fn smoke_shared_port_gone() { + test! { fn smoke_shared_port_gone() { let (tx, rx) = channel::<int>(); drop(rx); tx.send(1); - } #[should_fail]) + } #[should_fail] } - test!(fn smoke_shared_port_gone2() { + test! { fn smoke_shared_port_gone2() { let (tx, rx) = channel::<int>(); drop(rx); let tx2 = tx.clone(); drop(tx); tx2.send(1); - } #[should_fail]) + } #[should_fail] } - test!(fn port_gone_concurrent() { + test! { fn port_gone_concurrent() { let (tx, rx) = channel::<int>(); spawn(move|| { rx.recv(); }); loop { tx.send(1) } - } #[should_fail]) + } #[should_fail] } - test!(fn port_gone_concurrent_shared() { + test! { fn port_gone_concurrent_shared() { let (tx, rx) = channel::<int>(); let tx2 = tx.clone(); spawn(move|| { @@ -1109,32 +1109,32 @@ mod test { tx.send(1); tx2.send(1); } - } #[should_fail]) + } #[should_fail] } - test!(fn smoke_chan_gone() { + test! { fn smoke_chan_gone() { let (tx, rx) = channel::<int>(); drop(tx); rx.recv(); - } #[should_fail]) + } #[should_fail] } - test!(fn smoke_chan_gone_shared() { + test! { fn smoke_chan_gone_shared() { let (tx, rx) = channel::<()>(); let tx2 = tx.clone(); drop(tx); drop(tx2); rx.recv(); - } #[should_fail]) + } #[should_fail] } - test!(fn chan_gone_concurrent() { + test! { fn chan_gone_concurrent() { let (tx, rx) = channel::<int>(); spawn(move|| { tx.send(1); tx.send(1); }); loop { rx.recv(); } - } #[should_fail]) + } #[should_fail] } - test!(fn stress() { + test! { fn stress() { let (tx, rx) = channel::<int>(); spawn(move|| { for _ in range(0u, 10000) { tx.send(1i); } @@ -1142,9 +1142,9 @@ mod test { for _ in range(0u, 10000) { assert_eq!(rx.recv(), 1); } - }) + } } - test!(fn stress_shared() { + test! { fn stress_shared() { static AMT: uint = 10000; static NTHREADS: uint = 8; let (tx, rx) = channel::<int>(); @@ -1169,7 +1169,7 @@ mod test { } drop(tx); drx.recv(); - }) + } } #[test] fn send_from_outside_runtime() { @@ -1231,26 +1231,26 @@ mod test { rx3.recv(); } - test!(fn oneshot_single_thread_close_port_first() { + test! { fn oneshot_single_thread_close_port_first() { // Simple test of closing without sending let (_tx, rx) = channel::<int>(); drop(rx); - }) + } } - test!(fn oneshot_single_thread_close_chan_first() { + test! { fn oneshot_single_thread_close_chan_first() { // Simple test of closing without sending let (tx, _rx) = channel::<int>(); drop(tx); - }) + } } - test!(fn oneshot_single_thread_send_port_close() { + test! { fn oneshot_single_thread_send_port_close() { // Testing that the sender cleans up the payload if receiver is closed let (tx, rx) = channel::<Box<int>>(); drop(rx); tx.send(box 0); - } #[should_fail]) + } #[should_fail] } - test!(fn oneshot_single_thread_recv_chan_close() { + test! { fn oneshot_single_thread_recv_chan_close() { // Receiving on a closed chan will panic let res = task::try(move|| { let (tx, rx) = channel::<int>(); @@ -1259,67 +1259,67 @@ mod test { }); // What is our res? assert!(res.is_err()); - }) + } } - test!(fn oneshot_single_thread_send_then_recv() { + test! { fn oneshot_single_thread_send_then_recv() { let (tx, rx) = channel::<Box<int>>(); tx.send(box 10); assert!(rx.recv() == box 10); - }) + } } - test!(fn oneshot_single_thread_try_send_open() { + test! { fn oneshot_single_thread_try_send_open() { let (tx, rx) = channel::<int>(); assert!(tx.send_opt(10).is_ok()); assert!(rx.recv() == 10); - }) + } } - test!(fn oneshot_single_thread_try_send_closed() { + test! { fn oneshot_single_thread_try_send_closed() { let (tx, rx) = channel::<int>(); drop(rx); assert!(tx.send_opt(10).is_err()); - }) + } } - test!(fn oneshot_single_thread_try_recv_open() { + test! { fn oneshot_single_thread_try_recv_open() { let (tx, rx) = channel::<int>(); tx.send(10); assert!(rx.recv_opt() == Ok(10)); - }) + } } - test!(fn oneshot_single_thread_try_recv_closed() { + test! { fn oneshot_single_thread_try_recv_closed() { let (tx, rx) = channel::<int>(); drop(tx); assert!(rx.recv_opt() == Err(())); - }) + } } - test!(fn oneshot_single_thread_peek_data() { + test! { fn oneshot_single_thread_peek_data() { let (tx, rx) = channel::<int>(); - assert_eq!(rx.try_recv(), Err(Empty)) + assert_eq!(rx.try_recv(), Err(Empty)); tx.send(10); assert_eq!(rx.try_recv(), Ok(10)); - }) + } } - test!(fn oneshot_single_thread_peek_close() { + test! { fn oneshot_single_thread_peek_close() { let (tx, rx) = channel::<int>(); drop(tx); assert_eq!(rx.try_recv(), Err(Disconnected)); assert_eq!(rx.try_recv(), Err(Disconnected)); - }) + } } - test!(fn oneshot_single_thread_peek_open() { + test! { fn oneshot_single_thread_peek_open() { let (_tx, rx) = channel::<int>(); assert_eq!(rx.try_recv(), Err(Empty)); - }) + } } - test!(fn oneshot_multi_task_recv_then_send() { + test! { fn oneshot_multi_task_recv_then_send() { let (tx, rx) = channel::<Box<int>>(); spawn(move|| { assert!(rx.recv() == box 10); }); tx.send(box 10); - }) + } } - test!(fn oneshot_multi_task_recv_then_close() { + test! { fn oneshot_multi_task_recv_then_close() { let (tx, rx) = channel::<Box<int>>(); spawn(move|| { drop(tx); @@ -1328,9 +1328,9 @@ mod test { assert!(rx.recv() == box 10); }); assert!(res.is_err()); - }) + } } - test!(fn oneshot_multi_thread_close_stress() { + test! { fn oneshot_multi_thread_close_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = channel::<int>(); spawn(move|| { @@ -1338,9 +1338,9 @@ mod test { }); drop(tx); } - }) + } } - test!(fn oneshot_multi_thread_send_close_stress() { + test! { fn oneshot_multi_thread_send_close_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = channel::<int>(); spawn(move|| { @@ -1350,9 +1350,9 @@ mod test { tx.send(1); }); } - }) + } } - test!(fn oneshot_multi_thread_recv_close_stress() { + test! { fn oneshot_multi_thread_recv_close_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = channel::<int>(); spawn(move|| { @@ -1367,9 +1367,9 @@ mod test { }); }); } - }) + } } - test!(fn oneshot_multi_thread_send_recv_stress() { + test! { fn oneshot_multi_thread_send_recv_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = channel(); spawn(move|| { @@ -1379,9 +1379,9 @@ mod test { assert!(rx.recv() == box 10i); }); } - }) + } } - test!(fn stream_send_recv_stress() { + test! { fn stream_send_recv_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = channel(); @@ -1406,16 +1406,16 @@ mod test { }); } } - }) + } } - test!(fn recv_a_lot() { + test! { fn recv_a_lot() { // Regression test that we don't run out of stack in scheduler context let (tx, rx) = channel(); for _ in range(0i, 10000) { tx.send(()); } for _ in range(0i, 10000) { rx.recv(); } - }) + } } - test!(fn shared_chan_stress() { + test! { fn shared_chan_stress() { let (tx, rx) = channel(); let total = stress_factor() + 100; for _ in range(0, total) { @@ -1428,9 +1428,9 @@ mod test { for _ in range(0, total) { rx.recv(); } - }) + } } - test!(fn test_nested_recv_iter() { + test! { fn test_nested_recv_iter() { let (tx, rx) = channel::<int>(); let (total_tx, total_rx) = channel::<int>(); @@ -1447,9 +1447,9 @@ mod test { tx.send(2); drop(tx); assert_eq!(total_rx.recv(), 6); - }) + } } - test!(fn test_recv_iter_break() { + test! { fn test_recv_iter_break() { let (tx, rx) = channel::<int>(); let (count_tx, count_rx) = channel(); @@ -1471,9 +1471,9 @@ mod test { let _ = tx.send_opt(2); drop(tx); assert_eq!(count_rx.recv(), 4); - }) + } } - test!(fn try_recv_states() { + test! { fn try_recv_states() { let (tx1, rx1) = channel::<int>(); let (tx2, rx2) = channel::<()>(); let (tx3, rx3) = channel::<()>(); @@ -1494,11 +1494,11 @@ mod test { tx2.send(()); rx3.recv(); assert_eq!(rx1.try_recv(), Err(Disconnected)); - }) + } } // This bug used to end up in a livelock inside of the Receiver destructor // because the internal state of the Shared packet was corrupted - test!(fn destroy_upgraded_shared_port_when_sender_still_active() { + test! { fn destroy_upgraded_shared_port_when_sender_still_active() { let (tx, rx) = channel(); let (tx2, rx2) = channel(); spawn(move|| { @@ -1516,9 +1516,9 @@ mod test { // wait for the child task to exit before we exit rx2.recv(); - }) + } } - test!(fn sends_off_the_runtime() { + test! { fn sends_off_the_runtime() { use rustrt::thread::Thread; let (tx, rx) = channel(); @@ -1531,9 +1531,9 @@ mod test { rx.recv(); } t.join(); - }) + } } - test!(fn try_recvs_off_the_runtime() { + test! { fn try_recvs_off_the_runtime() { use rustrt::thread::Thread; let (tx, rx) = channel(); @@ -1554,7 +1554,7 @@ mod test { } t.join(); pdone.recv(); - }) + } } } #[cfg(test)] @@ -1569,57 +1569,57 @@ mod sync_tests { } } - test!(fn smoke() { + test! { fn smoke() { let (tx, rx) = sync_channel::<int>(1); tx.send(1); assert_eq!(rx.recv(), 1); - }) + } } - test!(fn drop_full() { + test! { fn drop_full() { let (tx, _rx) = sync_channel(1); tx.send(box 1i); - }) + } } - test!(fn smoke_shared() { + test! { fn smoke_shared() { let (tx, rx) = sync_channel::<int>(1); tx.send(1); assert_eq!(rx.recv(), 1); let tx = tx.clone(); tx.send(1); assert_eq!(rx.recv(), 1); - }) + } } - test!(fn smoke_threads() { + test! { fn smoke_threads() { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { tx.send(1); }); assert_eq!(rx.recv(), 1); - }) + } } - test!(fn smoke_port_gone() { + test! { fn smoke_port_gone() { let (tx, rx) = sync_channel::<int>(0); drop(rx); tx.send(1); - } #[should_fail]) + } #[should_fail] } - test!(fn smoke_shared_port_gone2() { + test! { fn smoke_shared_port_gone2() { let (tx, rx) = sync_channel::<int>(0); drop(rx); let tx2 = tx.clone(); drop(tx); tx2.send(1); - } #[should_fail]) + } #[should_fail] } - test!(fn port_gone_concurrent() { + test! { fn port_gone_concurrent() { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { rx.recv(); }); loop { tx.send(1) } - } #[should_fail]) + } #[should_fail] } - test!(fn port_gone_concurrent_shared() { + test! { fn port_gone_concurrent_shared() { let (tx, rx) = sync_channel::<int>(0); let tx2 = tx.clone(); spawn(move|| { @@ -1629,32 +1629,32 @@ mod sync_tests { tx.send(1); tx2.send(1); } - } #[should_fail]) + } #[should_fail] } - test!(fn smoke_chan_gone() { + test! { fn smoke_chan_gone() { let (tx, rx) = sync_channel::<int>(0); drop(tx); rx.recv(); - } #[should_fail]) + } #[should_fail] } - test!(fn smoke_chan_gone_shared() { + test! { fn smoke_chan_gone_shared() { let (tx, rx) = sync_channel::<()>(0); let tx2 = tx.clone(); drop(tx); drop(tx2); rx.recv(); - } #[should_fail]) + } #[should_fail] } - test!(fn chan_gone_concurrent() { + test! { fn chan_gone_concurrent() { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { tx.send(1); tx.send(1); }); loop { rx.recv(); } - } #[should_fail]) + } #[should_fail] } - test!(fn stress() { + test! { fn stress() { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { for _ in range(0u, 10000) { tx.send(1); } @@ -1662,9 +1662,9 @@ mod sync_tests { for _ in range(0u, 10000) { assert_eq!(rx.recv(), 1); } - }) + } } - test!(fn stress_shared() { + test! { fn stress_shared() { static AMT: uint = 1000; static NTHREADS: uint = 8; let (tx, rx) = sync_channel::<int>(0); @@ -1689,28 +1689,28 @@ mod sync_tests { } drop(tx); drx.recv(); - }) + } } - test!(fn oneshot_single_thread_close_port_first() { + test! { fn oneshot_single_thread_close_port_first() { // Simple test of closing without sending let (_tx, rx) = sync_channel::<int>(0); drop(rx); - }) + } } - test!(fn oneshot_single_thread_close_chan_first() { + test! { fn oneshot_single_thread_close_chan_first() { // Simple test of closing without sending let (tx, _rx) = sync_channel::<int>(0); drop(tx); - }) + } } - test!(fn oneshot_single_thread_send_port_close() { + test! { fn oneshot_single_thread_send_port_close() { // Testing that the sender cleans up the payload if receiver is closed let (tx, rx) = sync_channel::<Box<int>>(0); drop(rx); tx.send(box 0); - } #[should_fail]) + } #[should_fail] } - test!(fn oneshot_single_thread_recv_chan_close() { + test! { fn oneshot_single_thread_recv_chan_close() { // Receiving on a closed chan will panic let res = task::try(move|| { let (tx, rx) = sync_channel::<int>(0); @@ -1719,72 +1719,72 @@ mod sync_tests { }); // What is our res? assert!(res.is_err()); - }) + } } - test!(fn oneshot_single_thread_send_then_recv() { + test! { fn oneshot_single_thread_send_then_recv() { let (tx, rx) = sync_channel::<Box<int>>(1); tx.send(box 10); assert!(rx.recv() == box 10); - }) + } } - test!(fn oneshot_single_thread_try_send_open() { + test! { fn oneshot_single_thread_try_send_open() { let (tx, rx) = sync_channel::<int>(1); assert_eq!(tx.try_send(10), Ok(())); assert!(rx.recv() == 10); - }) + } } - test!(fn oneshot_single_thread_try_send_closed() { + test! { fn oneshot_single_thread_try_send_closed() { let (tx, rx) = sync_channel::<int>(0); drop(rx); assert_eq!(tx.try_send(10), Err(RecvDisconnected(10))); - }) + } } - test!(fn oneshot_single_thread_try_send_closed2() { + test! { fn oneshot_single_thread_try_send_closed2() { let (tx, _rx) = sync_channel::<int>(0); assert_eq!(tx.try_send(10), Err(Full(10))); - }) + } } - test!(fn oneshot_single_thread_try_recv_open() { + test! { fn oneshot_single_thread_try_recv_open() { let (tx, rx) = sync_channel::<int>(1); tx.send(10); assert!(rx.recv_opt() == Ok(10)); - }) + } } - test!(fn oneshot_single_thread_try_recv_closed() { + test! { fn oneshot_single_thread_try_recv_closed() { let (tx, rx) = sync_channel::<int>(0); drop(tx); assert!(rx.recv_opt() == Err(())); - }) + } } - test!(fn oneshot_single_thread_peek_data() { + test! { fn oneshot_single_thread_peek_data() { let (tx, rx) = sync_channel::<int>(1); - assert_eq!(rx.try_recv(), Err(Empty)) + assert_eq!(rx.try_recv(), Err(Empty)); tx.send(10); assert_eq!(rx.try_recv(), Ok(10)); - }) + } } - test!(fn oneshot_single_thread_peek_close() { + test! { fn oneshot_single_thread_peek_close() { let (tx, rx) = sync_channel::<int>(0); drop(tx); assert_eq!(rx.try_recv(), Err(Disconnected)); assert_eq!(rx.try_recv(), Err(Disconnected)); - }) + } } - test!(fn oneshot_single_thread_peek_open() { + test! { fn oneshot_single_thread_peek_open() { let (_tx, rx) = sync_channel::<int>(0); assert_eq!(rx.try_recv(), Err(Empty)); - }) + } } - test!(fn oneshot_multi_task_recv_then_send() { + test! { fn oneshot_multi_task_recv_then_send() { let (tx, rx) = sync_channel::<Box<int>>(0); spawn(move|| { assert!(rx.recv() == box 10); }); tx.send(box 10); - }) + } } - test!(fn oneshot_multi_task_recv_then_close() { + test! { fn oneshot_multi_task_recv_then_close() { let (tx, rx) = sync_channel::<Box<int>>(0); spawn(move|| { drop(tx); @@ -1793,9 +1793,9 @@ mod sync_tests { assert!(rx.recv() == box 10); }); assert!(res.is_err()); - }) + } } - test!(fn oneshot_multi_thread_close_stress() { + test! { fn oneshot_multi_thread_close_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { @@ -1803,9 +1803,9 @@ mod sync_tests { }); drop(tx); } - }) + } } - test!(fn oneshot_multi_thread_send_close_stress() { + test! { fn oneshot_multi_thread_send_close_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { @@ -1815,9 +1815,9 @@ mod sync_tests { tx.send(1); }); } - }) + } } - test!(fn oneshot_multi_thread_recv_close_stress() { + test! { fn oneshot_multi_thread_recv_close_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { @@ -1832,9 +1832,9 @@ mod sync_tests { }); }); } - }) + } } - test!(fn oneshot_multi_thread_send_recv_stress() { + test! { fn oneshot_multi_thread_send_recv_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = sync_channel::<Box<int>>(0); spawn(move|| { @@ -1844,9 +1844,9 @@ mod sync_tests { assert!(rx.recv() == box 10i); }); } - }) + } } - test!(fn stream_send_recv_stress() { + test! { fn stream_send_recv_stress() { for _ in range(0, stress_factor()) { let (tx, rx) = sync_channel::<Box<int>>(0); @@ -1871,16 +1871,16 @@ mod sync_tests { }); } } - }) + } } - test!(fn recv_a_lot() { + test! { fn recv_a_lot() { // Regression test that we don't run out of stack in scheduler context let (tx, rx) = sync_channel(10000); for _ in range(0u, 10000) { tx.send(()); } for _ in range(0u, 10000) { rx.recv(); } - }) + } } - test!(fn shared_chan_stress() { + test! { fn shared_chan_stress() { let (tx, rx) = sync_channel(0); let total = stress_factor() + 100; for _ in range(0, total) { @@ -1893,9 +1893,9 @@ mod sync_tests { for _ in range(0, total) { rx.recv(); } - }) + } } - test!(fn test_nested_recv_iter() { + test! { fn test_nested_recv_iter() { let (tx, rx) = sync_channel::<int>(0); let (total_tx, total_rx) = sync_channel::<int>(0); @@ -1912,9 +1912,9 @@ mod sync_tests { tx.send(2); drop(tx); assert_eq!(total_rx.recv(), 6); - }) + } } - test!(fn test_recv_iter_break() { + test! { fn test_recv_iter_break() { let (tx, rx) = sync_channel::<int>(0); let (count_tx, count_rx) = sync_channel(0); @@ -1936,9 +1936,9 @@ mod sync_tests { let _ = tx.try_send(2); drop(tx); assert_eq!(count_rx.recv(), 4); - }) + } } - test!(fn try_recv_states() { + test! { fn try_recv_states() { let (tx1, rx1) = sync_channel::<int>(1); let (tx2, rx2) = sync_channel::<()>(1); let (tx3, rx3) = sync_channel::<()>(1); @@ -1959,11 +1959,11 @@ mod sync_tests { tx2.send(()); rx3.recv(); assert_eq!(rx1.try_recv(), Err(Disconnected)); - }) + } } // This bug used to end up in a livelock inside of the Receiver destructor // because the internal state of the Shared packet was corrupted - test!(fn destroy_upgraded_shared_port_when_sender_still_active() { + test! { fn destroy_upgraded_shared_port_when_sender_still_active() { let (tx, rx) = sync_channel::<()>(0); let (tx2, rx2) = sync_channel::<()>(0); spawn(move|| { @@ -1981,9 +1981,9 @@ mod sync_tests { // wait for the child task to exit before we exit rx2.recv(); - }) + } } - test!(fn try_recvs_off_the_runtime() { + test! { fn try_recvs_off_the_runtime() { use rustrt::thread::Thread; let (tx, rx) = sync_channel::<()>(0); @@ -2004,28 +2004,28 @@ mod sync_tests { } t.join(); pdone.recv(); - }) + } } - test!(fn send_opt1() { + test! { fn send_opt1() { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { rx.recv(); }); assert_eq!(tx.send_opt(1), Ok(())); - }) + } } - test!(fn send_opt2() { + test! { fn send_opt2() { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { drop(rx); }); assert_eq!(tx.send_opt(1), Err(1)); - }) + } } - test!(fn send_opt3() { + test! { fn send_opt3() { let (tx, rx) = sync_channel::<int>(1); assert_eq!(tx.send_opt(1), Ok(())); spawn(move|| { drop(rx); }); assert_eq!(tx.send_opt(1), Err(1)); - }) + } } - test!(fn send_opt4() { + test! { fn send_opt4() { let (tx, rx) = sync_channel::<int>(0); let tx2 = tx.clone(); let (done, donerx) = channel(); @@ -2041,36 +2041,36 @@ mod sync_tests { drop(rx); donerx.recv(); donerx.recv(); - }) + } } - test!(fn try_send1() { + test! { fn try_send1() { let (tx, _rx) = sync_channel::<int>(0); assert_eq!(tx.try_send(1), Err(Full(1))); - }) + } } - test!(fn try_send2() { + test! { fn try_send2() { let (tx, _rx) = sync_channel::<int>(1); assert_eq!(tx.try_send(1), Ok(())); assert_eq!(tx.try_send(1), Err(Full(1))); - }) + } } - test!(fn try_send3() { + test! { fn try_send3() { let (tx, rx) = sync_channel::<int>(1); assert_eq!(tx.try_send(1), Ok(())); drop(rx); assert_eq!(tx.try_send(1), Err(RecvDisconnected(1))); - }) + } } - test!(fn try_send4() { + test! { fn try_send4() { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { for _ in range(0u, 1000) { task::deschedule(); } assert_eq!(tx.try_send(1), Ok(())); }); assert_eq!(rx.recv(), 1); - } #[ignore(reason = "flaky on libnative")]) + } #[ignore(reason = "flaky on libnative")] } - test!(fn issue_15761() { + test! { fn issue_15761() { fn repro() { let (tx1, rx1) = sync_channel::<()>(3); let (tx2, rx2) = sync_channel::<()>(3); @@ -2087,5 +2087,5 @@ mod sync_tests { for _ in range(0u, 100) { repro() } - }) + } } } diff --git a/src/libstd/comm/select.rs b/src/libstd/comm/select.rs index e145b0df7f3..de2b84b083c 100644 --- a/src/libstd/comm/select.rs +++ b/src/libstd/comm/select.rs @@ -347,58 +347,58 @@ mod test { }) } - test!(fn smoke() { + test! { fn smoke() { let (tx1, rx1) = channel::<int>(); let (tx2, rx2) = channel::<int>(); tx1.send(1); - select! ( + select! { foo = rx1.recv() => { assert_eq!(foo, 1); }, _bar = rx2.recv() => { panic!() } - ) + } tx2.send(2); - select! ( + select! { _foo = rx1.recv() => { panic!() }, bar = rx2.recv() => { assert_eq!(bar, 2) } - ) + } drop(tx1); - select! ( + select! { foo = rx1.recv_opt() => { assert_eq!(foo, Err(())); }, _bar = rx2.recv() => { panic!() } - ) + } drop(tx2); - select! ( + select! { bar = rx2.recv_opt() => { assert_eq!(bar, Err(())); } - ) - }) + } + } } - test!(fn smoke2() { + test! { fn smoke2() { let (_tx1, rx1) = channel::<int>(); let (_tx2, rx2) = channel::<int>(); let (_tx3, rx3) = channel::<int>(); let (_tx4, rx4) = channel::<int>(); let (tx5, rx5) = channel::<int>(); tx5.send(4); - select! ( + select! { _foo = rx1.recv() => { panic!("1") }, _foo = rx2.recv() => { panic!("2") }, _foo = rx3.recv() => { panic!("3") }, _foo = rx4.recv() => { panic!("4") }, foo = rx5.recv() => { assert_eq!(foo, 4); } - ) - }) + } + } } - test!(fn closed() { + test! { fn closed() { let (_tx1, rx1) = channel::<int>(); let (tx2, rx2) = channel::<int>(); drop(tx2); - select! ( + select! { _a1 = rx1.recv_opt() => { panic!() }, a2 = rx2.recv_opt() => { assert_eq!(a2, Err(())); } - ) - }) + } + } } - test!(fn unblocks() { + test! { fn unblocks() { let (tx1, rx1) = channel::<int>(); let (_tx2, rx2) = channel::<int>(); let (tx3, rx3) = channel::<int>(); @@ -410,18 +410,18 @@ mod test { for _ in range(0u, 20) { task::deschedule(); } }); - select! ( + select! { a = rx1.recv() => { assert_eq!(a, 1); }, _b = rx2.recv() => { panic!() } - ) + } tx3.send(1); - select! ( + select! { a = rx1.recv_opt() => { assert_eq!(a, Err(())); }, _b = rx2.recv() => { panic!() } - ) - }) + } + } } - test!(fn both_ready() { + test! { fn both_ready() { let (tx1, rx1) = channel::<int>(); let (tx2, rx2) = channel::<int>(); let (tx3, rx3) = channel::<()>(); @@ -433,20 +433,20 @@ mod test { rx3.recv(); }); - select! ( + select! { a = rx1.recv() => { assert_eq!(a, 1); }, a = rx2.recv() => { assert_eq!(a, 2); } - ) - select! ( + } + select! { a = rx1.recv() => { assert_eq!(a, 1); }, a = rx2.recv() => { assert_eq!(a, 2); } - ) + } assert_eq!(rx1.try_recv(), Err(Empty)); assert_eq!(rx2.try_recv(), Err(Empty)); tx3.send(()); - }) + } } - test!(fn stress() { + test! { fn stress() { static AMT: int = 10000; let (tx1, rx1) = channel::<int>(); let (tx2, rx2) = channel::<int>(); @@ -464,15 +464,15 @@ mod test { }); for i in range(0, AMT) { - select! ( + select! { i1 = rx1.recv() => { assert!(i % 2 == 0 && i == i1); }, i2 = rx2.recv() => { assert!(i % 2 == 1 && i == i2); } - ) + } tx3.send(()); } - }) + } } - test!(fn cloning() { + test! { fn cloning() { let (tx1, rx1) = channel::<int>(); let (_tx2, rx2) = channel::<int>(); let (tx3, rx3) = channel::<()>(); @@ -486,14 +486,14 @@ mod test { }); tx3.send(()); - select!( + select! { _i1 = rx1.recv() => {}, _i2 = rx2.recv() => panic!() - ) + } tx3.send(()); - }) + } } - test!(fn cloning2() { + test! { fn cloning2() { let (tx1, rx1) = channel::<int>(); let (_tx2, rx2) = channel::<int>(); let (tx3, rx3) = channel::<()>(); @@ -507,14 +507,14 @@ mod test { }); tx3.send(()); - select!( + select! { _i1 = rx1.recv() => {}, _i2 = rx2.recv() => panic!() - ) + } tx3.send(()); - }) + } } - test!(fn cloning3() { + test! { fn cloning3() { let (tx1, rx1) = channel::<()>(); let (tx2, rx2) = channel::<()>(); let (tx3, rx3) = channel::<()>(); @@ -532,44 +532,44 @@ mod test { drop(tx1.clone()); tx2.send(()); rx3.recv(); - }) + } } - test!(fn preflight1() { + test! { fn preflight1() { let (tx, rx) = channel(); tx.send(()); - select!( + select! { () = rx.recv() => {} - ) - }) + } + } } - test!(fn preflight2() { + test! { fn preflight2() { let (tx, rx) = channel(); tx.send(()); tx.send(()); - select!( + select! { () = rx.recv() => {} - ) - }) + } + } } - test!(fn preflight3() { + test! { fn preflight3() { let (tx, rx) = channel(); drop(tx.clone()); tx.send(()); - select!( + select! { () = rx.recv() => {} - ) - }) + } + } } - test!(fn preflight4() { + test! { fn preflight4() { let (tx, rx) = channel(); tx.send(()); let s = Select::new(); let mut h = s.handle(&rx); unsafe { h.add(); } assert_eq!(s.wait2(false), h.id); - }) + } } - test!(fn preflight5() { + test! { fn preflight5() { let (tx, rx) = channel(); tx.send(()); tx.send(()); @@ -577,9 +577,9 @@ mod test { let mut h = s.handle(&rx); unsafe { h.add(); } assert_eq!(s.wait2(false), h.id); - }) + } } - test!(fn preflight6() { + test! { fn preflight6() { let (tx, rx) = channel(); drop(tx.clone()); tx.send(()); @@ -587,18 +587,18 @@ mod test { let mut h = s.handle(&rx); unsafe { h.add(); } assert_eq!(s.wait2(false), h.id); - }) + } } - test!(fn preflight7() { + test! { fn preflight7() { let (tx, rx) = channel::<()>(); drop(tx); let s = Select::new(); let mut h = s.handle(&rx); unsafe { h.add(); } assert_eq!(s.wait2(false), h.id); - }) + } } - test!(fn preflight8() { + test! { fn preflight8() { let (tx, rx) = channel(); tx.send(()); drop(tx); @@ -607,9 +607,9 @@ mod test { let mut h = s.handle(&rx); unsafe { h.add(); } assert_eq!(s.wait2(false), h.id); - }) + } } - test!(fn preflight9() { + test! { fn preflight9() { let (tx, rx) = channel(); drop(tx.clone()); tx.send(()); @@ -619,9 +619,9 @@ mod test { let mut h = s.handle(&rx); unsafe { h.add(); } assert_eq!(s.wait2(false), h.id); - }) + } } - test!(fn oneshot_data_waiting() { + test! { fn oneshot_data_waiting() { let (tx1, rx1) = channel(); let (tx2, rx2) = channel(); spawn(move|| { @@ -634,9 +634,9 @@ mod test { for _ in range(0u, 100) { task::deschedule() } tx1.send(()); rx2.recv(); - }) + } } - test!(fn stream_data_waiting() { + test! { fn stream_data_waiting() { let (tx1, rx1) = channel(); let (tx2, rx2) = channel(); tx1.send(()); @@ -653,9 +653,9 @@ mod test { for _ in range(0u, 100) { task::deschedule() } tx1.send(()); rx2.recv(); - }) + } } - test!(fn shared_data_waiting() { + test! { fn shared_data_waiting() { let (tx1, rx1) = channel(); let (tx2, rx2) = channel(); drop(tx1.clone()); @@ -671,17 +671,17 @@ mod test { for _ in range(0u, 100) { task::deschedule() } tx1.send(()); rx2.recv(); - }) + } } - test!(fn sync1() { + test! { fn sync1() { let (tx, rx) = sync_channel::<int>(1); tx.send(1); select! { n = rx.recv() => { assert_eq!(n, 1); } } - }) + } } - test!(fn sync2() { + test! { fn sync2() { let (tx, rx) = sync_channel::<int>(0); spawn(move|| { for _ in range(0u, 100) { task::deschedule() } @@ -690,9 +690,9 @@ mod test { select! { n = rx.recv() => { assert_eq!(n, 1); } } - }) + } } - test!(fn sync3() { + test! { fn sync3() { let (tx1, rx1) = sync_channel::<int>(0); let (tx2, rx2): (Sender<int>, Receiver<int>) = channel(); spawn(move|| { tx1.send(1); }); @@ -707,5 +707,5 @@ mod test { assert_eq!(rx1.recv(), 1); } } - }) + } } } diff --git a/src/libstd/failure.rs b/src/libstd/failure.rs index 58a41f4d7d5..89bccb8b99f 100644 --- a/src/libstd/failure.rs +++ b/src/libstd/failure.rs @@ -27,9 +27,11 @@ use str::Str; use string::String; // Defined in this module instead of io::stdio so that the unwinding -thread_local!(pub static LOCAL_STDERR: RefCell<Option<Box<Writer + Send>>> = { - RefCell::new(None) -}) +thread_local! { + pub static LOCAL_STDERR: RefCell<Option<Box<Writer + Send>>> = { + RefCell::new(None) + } +} impl Writer for Stdio { fn write(&mut self, bytes: &[u8]) -> IoResult<()> { diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs index 24a000adef2..c1f1a5b7869 100644 --- a/src/libstd/io/extensions.rs +++ b/src/libstd/io/extensions.rs @@ -511,7 +511,7 @@ mod bench { use self::test::Bencher; // why is this a macro? wouldn't an inlined function work just as well? - macro_rules! u64_from_be_bytes_bench_impl( + macro_rules! u64_from_be_bytes_bench_impl { ($b:expr, $size:expr, $stride:expr, $start_index:expr) => ({ use super::u64_from_be_bytes; @@ -526,7 +526,7 @@ mod bench { } }); }) - ) + } #[bench] fn u64_from_be_bytes_4_aligned(b: &mut Bencher) { diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index f8df7e9b1f3..fd3bae73cd3 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -828,20 +828,20 @@ mod test { use ops::Drop; use str::StrPrelude; - macro_rules! check( ($e:expr) => ( + macro_rules! check { ($e:expr) => ( match $e { Ok(t) => t, Err(e) => panic!("{} failed with: {}", stringify!($e), e), } - ) ) + ) } - macro_rules! error( ($e:expr, $s:expr) => ( + macro_rules! error { ($e:expr, $s:expr) => ( match $e { Ok(_) => panic!("Unexpected success. Should've been: {}", $s), Err(ref err) => assert!(err.to_string().contains($s.as_slice()), format!("`{}` did not contain `{}`", err, $s)) } - ) ) + ) } pub struct TempDir(Path); diff --git a/src/libstd/io/net/ip.rs b/src/libstd/io/net/ip.rs index 092410fbc8e..5a3f5bd4668 100644 --- a/src/libstd/io/net/ip.rs +++ b/src/libstd/io/net/ip.rs @@ -478,7 +478,7 @@ fn resolve_socket_addr(s: &str, p: u16) -> IoResult<Vec<SocketAddr>> { } fn parse_and_resolve_socket_addr(s: &str) -> IoResult<Vec<SocketAddr>> { - macro_rules! try_opt( + macro_rules! try_opt { ($e:expr, $msg:expr) => ( match $e { Some(r) => r, @@ -489,7 +489,7 @@ fn parse_and_resolve_socket_addr(s: &str) -> IoResult<Vec<SocketAddr>> { }) } ) - ) + } // split the string by ':' and convert the second part to u16 let mut parts_iter = s.rsplitn(2, ':'); diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index 844814fbfdd..73be389bb91 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -95,9 +95,11 @@ fn src<T, F>(fd: libc::c_int, _readable: bool, f: F) -> T where } } -thread_local!(static LOCAL_STDOUT: RefCell<Option<Box<Writer + Send>>> = { - RefCell::new(None) -}) +thread_local! { + static LOCAL_STDOUT: RefCell<Option<Box<Writer + Send>>> = { + RefCell::new(None) + } +} /// A synchronized wrapper around a buffered reader from stdin #[deriving(Clone)] diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index a02b37fcfd1..798dac1a72f 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -37,7 +37,7 @@ /// panic!("this is a {} {message}", "fancy", message = "message"); /// ``` #[macro_export] -macro_rules! panic( +macro_rules! panic { () => ({ panic!("explicit panic") }); @@ -70,7 +70,7 @@ macro_rules! panic( } format_args!(_run_fmt, $fmt, $($arg)*) }); -) +} /// Ensure that a boolean expression is `true` at runtime. /// @@ -93,7 +93,7 @@ macro_rules! panic( /// assert!(a + b == 30, "a = {}, b = {}", a, b); /// ``` #[macro_export] -macro_rules! assert( +macro_rules! assert { ($cond:expr) => ( if !$cond { panic!(concat!("assertion failed: ", stringify!($cond))) @@ -104,7 +104,7 @@ macro_rules! assert( panic!($($arg),+) } ); -) +} /// Asserts that two expressions are equal to each other, testing equality in /// both directions. @@ -119,7 +119,7 @@ macro_rules! assert( /// assert_eq!(a, b); /// ``` #[macro_export] -macro_rules! assert_eq( +macro_rules! assert_eq { ($left:expr , $right:expr) => ({ match (&($left), &($right)) { (left_val, right_val) => { @@ -132,7 +132,7 @@ macro_rules! assert_eq( } } }) -) +} /// Ensure that a boolean expression is `true` at runtime. /// @@ -160,9 +160,9 @@ macro_rules! assert_eq( /// debug_assert!(a + b == 30, "a = {}, b = {}", a, b); /// ``` #[macro_export] -macro_rules! debug_assert( +macro_rules! debug_assert { ($($arg:tt)*) => (if cfg!(not(ndebug)) { assert!($($arg)*); }) -) +} /// Asserts that two expressions are equal to each other, testing equality in /// both directions. @@ -182,9 +182,9 @@ macro_rules! debug_assert( /// debug_assert_eq!(a, b); /// ``` #[macro_export] -macro_rules! debug_assert_eq( +macro_rules! debug_assert_eq { ($($arg:tt)*) => (if cfg!(not(ndebug)) { assert_eq!($($arg)*); }) -) +} /// A utility macro for indicating unreachable code. /// @@ -226,7 +226,7 @@ macro_rules! debug_assert_eq( /// } /// ``` #[macro_export] -macro_rules! unreachable( +macro_rules! unreachable { () => ({ panic!("internal error: entered unreachable code") }); @@ -236,14 +236,14 @@ macro_rules! unreachable( ($fmt:expr, $($arg:tt)*) => ({ panic!(concat!("internal error: entered unreachable code: ", $fmt), $($arg)*) }); -) +} /// A standardised placeholder for marking unfinished code. It panics with the /// message `"not yet implemented"` when executed. #[macro_export] -macro_rules! unimplemented( +macro_rules! unimplemented { () => (panic!("not yet implemented")) -) +} /// Use the syntax described in `std::fmt` to create a value of type `String`. /// See `std::fmt` for more information. @@ -257,11 +257,11 @@ macro_rules! unimplemented( /// ``` #[macro_export] #[stable] -macro_rules! format( +macro_rules! format { ($($arg:tt)*) => ( format_args!(::std::fmt::format, $($arg)*) ) -) +} /// Use the `format!` syntax to write data into a buffer of type `&mut Writer`. /// See `std::fmt` for more information. @@ -277,30 +277,30 @@ macro_rules! format( /// ``` #[macro_export] #[stable] -macro_rules! write( +macro_rules! write { ($dst:expr, $($arg:tt)*) => ({ let dst = &mut *$dst; format_args!(|args| { dst.write_fmt(args) }, $($arg)*) }) -) +} /// Equivalent to the `write!` macro, except that a newline is appended after /// the message is written. #[macro_export] #[stable] -macro_rules! writeln( +macro_rules! writeln { ($dst:expr, $fmt:expr $($arg:tt)*) => ( write!($dst, concat!($fmt, "\n") $($arg)*) ) -) +} /// Equivalent to the `println!` macro except that a newline is not printed at /// the end of the message. #[macro_export] #[stable] -macro_rules! print( +macro_rules! print { ($($arg:tt)*) => (format_args!(::std::io::stdio::print_args, $($arg)*)) -) +} /// Macro for printing to a task's stdout handle. /// @@ -316,33 +316,33 @@ macro_rules! print( /// ``` #[macro_export] #[stable] -macro_rules! println( +macro_rules! println { ($($arg:tt)*) => (format_args!(::std::io::stdio::println_args, $($arg)*)) -) +} /// Helper macro for unwrapping `Result` values while returning early with an /// error if the value of the expression is `Err`. For more information, see /// `std::io`. #[macro_export] -macro_rules! try ( +macro_rules! try { ($expr:expr) => ({ match $expr { Ok(val) => val, Err(err) => return Err(::std::error::FromError::from_error(err)) } }) -) +} /// Create a `std::vec::Vec` containing the arguments. #[macro_export] -macro_rules! vec[ +macro_rules! vec { ($($x:expr),*) => ({ use std::slice::BoxedSliceExt; let xs: ::std::boxed::Box<[_]> = box [$($x),*]; xs.into_vec() }); ($($x:expr,)*) => (vec![$($x),*]) -] +} /// A macro to select an event from a number of receivers. /// @@ -394,11 +394,11 @@ macro_rules! select { // uses. To get around this difference, we redefine the log!() macro here to be // just a dumb version of what it should be. #[cfg(test)] -macro_rules! log ( +macro_rules! log { ($lvl:expr, $($args:tt)*) => ( if log_enabled!($lvl) { println!($($args)*) } ) -) +} /// Built-in macros to the compiler itself. /// @@ -430,9 +430,9 @@ pub mod builtin { /// }, "hello {}", "world"); /// ``` #[macro_export] - macro_rules! format_args( ($closure:expr, $fmt:expr $($args:tt)*) => ({ + macro_rules! format_args { ($closure:expr, $fmt:expr $($args:tt)*) => ({ /* compiler built-in */ - }) ) + }) } /// Inspect an environment variable at compile time. /// @@ -450,7 +450,7 @@ pub mod builtin { /// println!("the $PATH variable at the time of compiling was: {}", path); /// ``` #[macro_export] - macro_rules! env( ($name:expr) => ({ /* compiler built-in */ }) ) + macro_rules! env { ($name:expr) => ({ /* compiler built-in */ }) } /// Optionally inspect an environment variable at compile time. /// @@ -469,7 +469,7 @@ pub mod builtin { /// println!("the secret key might be: {}", key); /// ``` #[macro_export] - macro_rules! option_env( ($name:expr) => ({ /* compiler built-in */ }) ) + macro_rules! option_env { ($name:expr) => ({ /* compiler built-in */ }) } /// Concatenate literals into a static byte slice. /// @@ -489,7 +489,7 @@ pub mod builtin { /// assert_eq!(rust[4], 255); /// ``` #[macro_export] - macro_rules! bytes( ($($e:expr),*) => ({ /* compiler built-in */ }) ) + macro_rules! bytes { ($($e:expr),*) => ({ /* compiler built-in */ }) } /// Concatenate identifiers into one identifier. /// @@ -513,7 +513,9 @@ pub mod builtin { /// # } /// ``` #[macro_export] - macro_rules! concat_idents( ($($e:ident),*) => ({ /* compiler built-in */ }) ) + macro_rules! concat_idents { + ($($e:ident),*) => ({ /* compiler built-in */ }) + } /// Concatenates literals into a static string slice. /// @@ -531,7 +533,7 @@ pub mod builtin { /// assert_eq!(s, "test10btrue"); /// ``` #[macro_export] - macro_rules! concat( ($($e:expr),*) => ({ /* compiler built-in */ }) ) + macro_rules! concat { ($($e:expr),*) => ({ /* compiler built-in */ }) } /// A macro which expands to the line number on which it was invoked. /// @@ -546,7 +548,7 @@ pub mod builtin { /// println!("defined on line: {}", current_line); /// ``` #[macro_export] - macro_rules! line( () => ({ /* compiler built-in */ }) ) + macro_rules! line { () => ({ /* compiler built-in */ }) } /// A macro which expands to the column number on which it was invoked. /// @@ -561,7 +563,7 @@ pub mod builtin { /// println!("defined on column: {}", current_col); /// ``` #[macro_export] - macro_rules! column( () => ({ /* compiler built-in */ }) ) + macro_rules! column { () => ({ /* compiler built-in */ }) } /// A macro which expands to the file name from which it was invoked. /// @@ -577,7 +579,7 @@ pub mod builtin { /// println!("defined in file: {}", this_file); /// ``` #[macro_export] - macro_rules! file( () => ({ /* compiler built-in */ }) ) + macro_rules! file { () => ({ /* compiler built-in */ }) } /// A macro which stringifies its argument. /// @@ -592,7 +594,7 @@ pub mod builtin { /// assert_eq!(one_plus_one, "1 + 1"); /// ``` #[macro_export] - macro_rules! stringify( ($t:tt) => ({ /* compiler built-in */ }) ) + macro_rules! stringify { ($t:tt) => ({ /* compiler built-in */ }) } /// Includes a utf8-encoded file as a string. /// @@ -606,7 +608,7 @@ pub mod builtin { /// let secret_key = include_str!("secret-key.ascii"); /// ``` #[macro_export] - macro_rules! include_str( ($file:expr) => ({ /* compiler built-in */ }) ) + macro_rules! include_str { ($file:expr) => ({ /* compiler built-in */ }) } /// Includes a file as a byte slice. /// @@ -620,7 +622,7 @@ pub mod builtin { /// let secret_key = include_bin!("secret-key.bin"); /// ``` #[macro_export] - macro_rules! include_bin( ($file:expr) => ({ /* compiler built-in */ }) ) + macro_rules! include_bin { ($file:expr) => ({ /* compiler built-in */ }) } /// Expands to a string that represents the current module path. /// @@ -640,7 +642,7 @@ pub mod builtin { /// test::foo(); /// ``` #[macro_export] - macro_rules! module_path( () => ({ /* compiler built-in */ }) ) + macro_rules! module_path { () => ({ /* compiler built-in */ }) } /// Boolean evaluation of configuration flags. /// @@ -661,5 +663,5 @@ pub mod builtin { /// }; /// ``` #[macro_export] - macro_rules! cfg( ($cfg:tt) => ({ /* compiler built-in */ }) ) + macro_rules! cfg { ($cfg:tt) => ({ /* compiler built-in */ }) } } diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index 9aac857bb65..60b17de1718 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -671,8 +671,8 @@ mod tests { let inf: f32 = Float::infinity(); let neg_inf: f32 = Float::neg_infinity(); let nan: f32 = Float::nan(); - assert_eq!(match inf.frexp() { (x, _) => x }, inf) - assert_eq!(match neg_inf.frexp() { (x, _) => x }, neg_inf) + assert_eq!(match inf.frexp() { (x, _) => x }, inf); + assert_eq!(match neg_inf.frexp() { (x, _) => x }, neg_inf); assert!(match nan.frexp() { (x, _) => x.is_nan() }) } diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index 29ccfe512b9..4b31e33236d 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -673,8 +673,8 @@ mod tests { let inf: f64 = Float::infinity(); let neg_inf: f64 = Float::neg_infinity(); let nan: f64 = Float::nan(); - assert_eq!(match inf.frexp() { (x, _) => x }, inf) - assert_eq!(match neg_inf.frexp() { (x, _) => x }, neg_inf) + assert_eq!(match inf.frexp() { (x, _) => x }, inf); + assert_eq!(match neg_inf.frexp() { (x, _) => x }, neg_inf); assert!(match nan.frexp() { (x, _) => x.is_nan() }) } diff --git a/src/libstd/num/float_macros.rs b/src/libstd/num/float_macros.rs index 4b3727ead61..fd00f15662a 100644 --- a/src/libstd/num/float_macros.rs +++ b/src/libstd/num/float_macros.rs @@ -12,11 +12,11 @@ #![macro_escape] #![doc(hidden)] -macro_rules! assert_approx_eq( +macro_rules! assert_approx_eq { ($a:expr, $b:expr) => ({ use num::Float; let (a, b) = (&$a, &$b); assert!((*a - *b).abs() < 1.0e-6, "{} is not approximately equal to {}", *a, *b); }) -) +} diff --git a/src/libstd/num/i16.rs b/src/libstd/num/i16.rs index 333d1d7df0b..367147b84be 100644 --- a/src/libstd/num/i16.rs +++ b/src/libstd/num/i16.rs @@ -15,4 +15,4 @@ pub use core::i16::{BITS, BYTES, MIN, MAX}; -int_module!(i16) +int_module! { i16 } diff --git a/src/libstd/num/i32.rs b/src/libstd/num/i32.rs index 44b5397bf74..19fb40c9644 100644 --- a/src/libstd/num/i32.rs +++ b/src/libstd/num/i32.rs @@ -15,4 +15,4 @@ pub use core::i32::{BITS, BYTES, MIN, MAX}; -int_module!(i32) +int_module! { i32 } diff --git a/src/libstd/num/i64.rs b/src/libstd/num/i64.rs index de6fa0d3ef8..2379b03c64f 100644 --- a/src/libstd/num/i64.rs +++ b/src/libstd/num/i64.rs @@ -15,4 +15,4 @@ pub use core::i64::{BITS, BYTES, MIN, MAX}; -int_module!(i64) +int_module! { i64 } diff --git a/src/libstd/num/i8.rs b/src/libstd/num/i8.rs index 3b9fbcb768b..a09ceefc6a0 100644 --- a/src/libstd/num/i8.rs +++ b/src/libstd/num/i8.rs @@ -15,4 +15,4 @@ pub use core::i8::{BITS, BYTES, MIN, MAX}; -int_module!(i8) +int_module! { i8 } diff --git a/src/libstd/num/int.rs b/src/libstd/num/int.rs index 36c021efe0a..f59dab4b20b 100644 --- a/src/libstd/num/int.rs +++ b/src/libstd/num/int.rs @@ -15,4 +15,4 @@ pub use core::int::{BITS, BYTES, MIN, MAX}; -int_module!(int) +int_module! { int } diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs index 2f1162d28e5..fce150c4ad1 100644 --- a/src/libstd/num/int_macros.rs +++ b/src/libstd/num/int_macros.rs @@ -12,6 +12,6 @@ #![macro_escape] #![doc(hidden)] -macro_rules! int_module (($T:ty) => ( +macro_rules! int_module { ($T:ty) => ( -)) +) } diff --git a/src/libstd/num/mod.rs b/src/libstd/num/mod.rs index 9aaaceb87e6..a568aafe1ed 100644 --- a/src/libstd/num/mod.rs +++ b/src/libstd/num/mod.rs @@ -161,7 +161,7 @@ mod tests { use u64; use uint; - macro_rules! test_cast_20( + macro_rules! test_cast_20 { ($_20:expr) => ({ let _20 = $_20; @@ -204,7 +204,7 @@ mod tests { assert_eq!(_20, cast(20f32).unwrap()); assert_eq!(_20, cast(20f64).unwrap()); }) - ) + } #[test] fn test_u8_cast() { test_cast_20!(20u8) } #[test] fn test_u16_cast() { test_cast_20!(20u16) } @@ -664,7 +664,7 @@ mod tests { assert_eq!(third.checked_mul(4), None); } - macro_rules! test_next_power_of_two( + macro_rules! test_next_power_of_two { ($test_name:ident, $T:ident) => ( fn $test_name() { #![test] @@ -676,15 +676,15 @@ mod tests { } } ) - ) + } - test_next_power_of_two!(test_next_power_of_two_u8, u8) - test_next_power_of_two!(test_next_power_of_two_u16, u16) - test_next_power_of_two!(test_next_power_of_two_u32, u32) - test_next_power_of_two!(test_next_power_of_two_u64, u64) - test_next_power_of_two!(test_next_power_of_two_uint, uint) + test_next_power_of_two! { test_next_power_of_two_u8, u8 } + test_next_power_of_two! { test_next_power_of_two_u16, u16 } + test_next_power_of_two! { test_next_power_of_two_u32, u32 } + test_next_power_of_two! { test_next_power_of_two_u64, u64 } + test_next_power_of_two! { test_next_power_of_two_uint, uint } - macro_rules! test_checked_next_power_of_two( + macro_rules! test_checked_next_power_of_two { ($test_name:ident, $T:ident) => ( fn $test_name() { #![test] @@ -699,13 +699,13 @@ mod tests { assert_eq!($T::MAX.checked_next_power_of_two(), None); } ) - ) + } - test_checked_next_power_of_two!(test_checked_next_power_of_two_u8, u8) - test_checked_next_power_of_two!(test_checked_next_power_of_two_u16, u16) - test_checked_next_power_of_two!(test_checked_next_power_of_two_u32, u32) - test_checked_next_power_of_two!(test_checked_next_power_of_two_u64, u64) - test_checked_next_power_of_two!(test_checked_next_power_of_two_uint, uint) + test_checked_next_power_of_two! { test_checked_next_power_of_two_u8, u8 } + test_checked_next_power_of_two! { test_checked_next_power_of_two_u16, u16 } + test_checked_next_power_of_two! { test_checked_next_power_of_two_u32, u32 } + test_checked_next_power_of_two! { test_checked_next_power_of_two_u64, u64 } + test_checked_next_power_of_two! { test_checked_next_power_of_two_uint, uint } #[deriving(PartialEq, Show)] struct Value { x: int } @@ -759,13 +759,13 @@ mod tests { let one: T = Int::one(); range(0, exp).fold(one, |acc, _| acc * base) } - macro_rules! assert_pow( + macro_rules! assert_pow { (($num:expr, $exp:expr) => $expected:expr) => {{ let result = $num.pow($exp); assert_eq!(result, $expected); assert_eq!(result, naive_pow($num, $exp)); }} - ) + } assert_pow!((3i, 0 ) => 1); assert_pow!((5i, 1 ) => 5); assert_pow!((-4i, 2 ) => 16); diff --git a/src/libstd/num/u16.rs b/src/libstd/num/u16.rs index 6d9b177574a..46699b78599 100644 --- a/src/libstd/num/u16.rs +++ b/src/libstd/num/u16.rs @@ -17,4 +17,4 @@ pub use core::u16::{BITS, BYTES, MIN, MAX}; use ops::FnOnce; -uint_module!(u16) +uint_module! { u16 } diff --git a/src/libstd/num/u32.rs b/src/libstd/num/u32.rs index 0d6d17fa007..45ee9251d2f 100644 --- a/src/libstd/num/u32.rs +++ b/src/libstd/num/u32.rs @@ -17,4 +17,4 @@ pub use core::u32::{BITS, BYTES, MIN, MAX}; use ops::FnOnce; -uint_module!(u32) +uint_module! { u32 } diff --git a/src/libstd/num/u64.rs b/src/libstd/num/u64.rs index ebb5d2946c5..1d8ff77dac8 100644 --- a/src/libstd/num/u64.rs +++ b/src/libstd/num/u64.rs @@ -17,4 +17,4 @@ pub use core::u64::{BITS, BYTES, MIN, MAX}; use ops::FnOnce; -uint_module!(u64) +uint_module! { u64 } diff --git a/src/libstd/num/u8.rs b/src/libstd/num/u8.rs index 59aea214aae..0663ace2e5b 100644 --- a/src/libstd/num/u8.rs +++ b/src/libstd/num/u8.rs @@ -17,4 +17,4 @@ pub use core::u8::{BITS, BYTES, MIN, MAX}; use ops::FnOnce; -uint_module!(u8) +uint_module! { u8 } diff --git a/src/libstd/num/uint.rs b/src/libstd/num/uint.rs index 484d28dfed0..7f8edee571f 100644 --- a/src/libstd/num/uint.rs +++ b/src/libstd/num/uint.rs @@ -17,4 +17,4 @@ pub use core::uint::{BITS, BYTES, MIN, MAX}; use ops::FnOnce; -uint_module!(uint) +uint_module! { uint } diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs index bd6f3d4bb28..c42b7eebfdd 100644 --- a/src/libstd/num/uint_macros.rs +++ b/src/libstd/num/uint_macros.rs @@ -13,7 +13,7 @@ #![doc(hidden)] #![allow(unsigned_negation)] -macro_rules! uint_module (($T:ty) => ( +macro_rules! uint_module { ($T:ty) => ( // String conversion functions and impl num -> str @@ -141,4 +141,4 @@ mod tests { } } -)) +) } diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index bea51712253..f872aa8e9a4 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -447,7 +447,7 @@ mod tests { use str; use str::StrPrelude; - macro_rules! t( + macro_rules! t { (s: $path:expr, $exp:expr) => ( { let path = $path; @@ -460,7 +460,7 @@ mod tests { assert!(path.as_vec() == $exp); } ) - ) + } #[test] fn test_paths() { @@ -533,14 +533,14 @@ mod tests { #[test] fn test_display_str() { - macro_rules! t( + macro_rules! t { ($path:expr, $disp:ident, $exp:expr) => ( { let path = Path::new($path); assert!(path.$disp().to_string() == $exp); } ) - ) + } t!("foo", display, "foo"); t!(b"foo\x80", display, "foo\u{FFFD}"); t!(b"foo\xFFbar", display, "foo\u{FFFD}bar"); @@ -563,7 +563,7 @@ mod tests { assert!(mo.as_slice() == $exp); } ) - ) + ); t!("foo", "foo"); t!(b"foo\x80", "foo\u{FFFD}"); @@ -585,7 +585,7 @@ mod tests { assert!(f == $expf); } ) - ) + ); t!(b"foo", "foo", "foo"); t!(b"foo/bar", "foo/bar", "bar"); @@ -619,7 +619,7 @@ mod tests { assert!(path.$op() == $exp); } ); - ) + ); t!(v: b"a/b/c", filename, Some(b"c")); t!(v: b"a/b/c\xFF", filename, Some(b"c\xFF")); @@ -693,7 +693,7 @@ mod tests { assert!(p1 == p2.join(join)); } ) - ) + ); t!(s: "a/b/c", ".."); t!(s: "/a/b/c", "d"); @@ -712,7 +712,7 @@ mod tests { assert!(p.as_str() == Some($exp)); } ) - ) + ); t!(s: "a/b/c", "d", "a/b/c/d"); t!(s: "/a/b/c", "d", "/a/b/c/d"); @@ -739,7 +739,7 @@ mod tests { assert!(p.as_vec() == $exp); } ) - ) + ); t!(s: "a/b/c", ["d", "e"], "a/b/c/d/e"); t!(s: "a/b/c", ["d", "/e"], "/e"); @@ -769,7 +769,7 @@ mod tests { assert!(result == $right); } ) - ) + ); t!(b: b"a/b/c", b"a/b", true); t!(b: b"a", b".", true); @@ -817,7 +817,7 @@ mod tests { assert!(res.as_str() == Some($exp)); } ) - ) + ); t!(s: "a/b/c", "..", "a/b"); t!(s: "/a/b/c", "d", "/a/b/c/d"); @@ -844,7 +844,7 @@ mod tests { assert!(res.as_vec() == $exp); } ) - ) + ); t!(s: "a/b/c", ["d", "e"], "a/b/c/d/e"); t!(s: "a/b/c", ["..", "d"], "a/b/d"); @@ -928,7 +928,7 @@ mod tests { assert!(p1 == p2.$with(arg)); } ) - ) + ); t!(v: b"a/b/c", set_filename, with_filename, b"d"); t!(v: b"/", set_filename, with_filename, b"foo"); @@ -982,7 +982,7 @@ mod tests { assert!(path.extension() == $ext); } ) - ) + ); t!(v: Path::new(b"a/b/c"), Some(b"c"), b"a/b", Some(b"c"), None); t!(v: Path::new(b"a/b/\xFF"), Some(b"\xFF"), b"a/b", Some(b"\xFF"), None); @@ -1029,7 +1029,7 @@ mod tests { assert_eq!(path.is_relative(), $rel); } ) - ) + ); t!(s: "a/b/c", false, true); t!(s: "/a/b/c", true, false); t!(s: "a", false, true); @@ -1050,7 +1050,7 @@ mod tests { assert_eq!(path.is_ancestor_of(&dest), $exp); } ) - ) + ); t!(s: "a/b/c", "a/b/c/d", true); t!(s: "a/b/c", "a/b/c", true); @@ -1091,7 +1091,7 @@ mod tests { assert_eq!(path.ends_with_path(&child), $exp); } ) - ) + ); t!(s: "a/b/c", "c", true); t!(s: "a/b/c", "d", false); @@ -1124,7 +1124,7 @@ mod tests { assert_eq!(res.as_ref().and_then(|x| x.as_str()), $exp); } ) - ) + ); t!(s: "a/b/c", "a/b", Some("c")); t!(s: "a/b/c", "a/b/d", Some("../c")); @@ -1186,7 +1186,7 @@ mod tests { assert_eq!(comps, exp) } ) - ) + ); t!(b: b"a/b/c", [b"a", b"b", b"c"]); t!(b: b"/\xFF/a/\x80", [b"\xFF", b"a", b"\x80"]); @@ -1218,7 +1218,7 @@ mod tests { assert_eq!(comps, exp); } ) - ) + ); t!(b: b"a/b/c", [Some("a"), Some("b"), Some("c")]); t!(b: b"/\xFF/a/\x80", [None, Some("a"), None]); diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index 8b18d1d8cd4..b376f6d0d5b 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -1122,7 +1122,7 @@ mod tests { use super::*; use super::parse_prefix; - macro_rules! t( + macro_rules! t { (s: $path:expr, $exp:expr) => ( { let path = $path; @@ -1135,7 +1135,7 @@ mod tests { assert!(path.as_vec() == $exp); } ) - ) + } #[test] fn test_parse_prefix() { @@ -1149,7 +1149,7 @@ mod tests { "parse_prefix(\"{}\"): expected {}, found {}", path, exp, res); } ) - ) + ); t!("\\\\SERVER\\share\\foo", Some(UNCPrefix(6,5))); t!("\\\\", None); @@ -1348,7 +1348,7 @@ mod tests { assert_eq!(f, $expf); } ) - ) + ); t!("foo", "foo", "foo"); t!("foo\\bar", "foo\\bar", "bar"); @@ -1380,7 +1380,7 @@ mod tests { assert!(path.$op() == $exp); } ) - ) + ); t!(v: b"a\\b\\c", filename, Some(b"c")); t!(s: "a\\b\\c", filename_str, "c"); @@ -1491,7 +1491,7 @@ mod tests { assert!(p1 == p2.join(join)); } ) - ) + ); t!(s: "a\\b\\c", ".."); t!(s: "\\a\\b\\c", "d"); @@ -1524,7 +1524,7 @@ mod tests { assert_eq!(p.as_str(), Some($exp)); } ) - ) + ); t!(s: "a\\b\\c", "d", "a\\b\\c\\d"); t!(s: "\\a\\b\\c", "d", "\\a\\b\\c\\d"); @@ -1582,7 +1582,7 @@ mod tests { assert_eq!(p.as_vec(), $exp); } ) - ) + ); t!(s: "a\\b\\c", ["d", "e"], "a\\b\\c\\d\\e"); t!(s: "a\\b\\c", ["d", "\\e"], "\\e"); @@ -1617,7 +1617,7 @@ mod tests { assert!(result == $right); } ) - ) + ); t!(s: "a\\b\\c", "a\\b", true); t!(s: "a", ".", true); @@ -1694,7 +1694,7 @@ mod tests { assert_eq!(res.as_str(), Some($exp)); } ) - ) + ); t!(s: "a\\b\\c", "..", "a\\b"); t!(s: "\\a\\b\\c", "d", "\\a\\b\\c\\d"); @@ -1723,7 +1723,7 @@ mod tests { assert_eq!(res.as_vec(), $exp); } ) - ) + ); t!(s: "a\\b\\c", ["d", "e"], "a\\b\\c\\d\\e"); t!(s: "a\\b\\c", ["..", "d"], "a\\b\\d"); @@ -1749,7 +1749,7 @@ mod tests { pstr, stringify!($op), arg, exp, res.as_str().unwrap()); } ) - ) + ); t!(s: "a\\b\\c", with_filename, "d", "a\\b\\d"); t!(s: ".", with_filename, "foo", "foo"); @@ -1842,7 +1842,7 @@ mod tests { assert!(p1 == p2.$with(arg)); } ) - ) + ); t!(v: b"a\\b\\c", set_filename, with_filename, b"d"); t!(v: b"\\", set_filename, with_filename, b"foo"); @@ -1897,7 +1897,7 @@ mod tests { assert!(path.extension() == $ext); } ) - ) + ); t!(v: Path::new(b"a\\b\\c"), Some(b"c"), b"a\\b", Some(b"c"), None); t!(s: Path::new("a\\b\\c"), Some("c"), Some("a\\b"), Some("c"), None); @@ -1951,7 +1951,7 @@ mod tests { path.as_str().unwrap(), rel, b); } ) - ) + ); t!("a\\b\\c", false, false, false, true); t!("\\a\\b\\c", false, true, false, false); t!("a", false, false, false, true); @@ -1984,7 +1984,7 @@ mod tests { path.as_str().unwrap(), dest.as_str().unwrap(), exp, res); } ) - ) + ); t!(s: "a\\b\\c", "a\\b\\c\\d", true); t!(s: "a\\b\\c", "a\\b\\c", true); @@ -2083,7 +2083,7 @@ mod tests { assert_eq!(path.ends_with_path(&child), $exp); } ); - ) + ); t!(s: "a\\b\\c", "c", true); t!(s: "a\\b\\c", "d", false); @@ -2120,7 +2120,7 @@ mod tests { res.as_ref().and_then(|x| x.as_str())); } ) - ) + ); t!(s: "a\\b\\c", "a\\b", Some("c")); t!(s: "a\\b\\c", "a\\b\\d", Some("..\\c")); @@ -2255,7 +2255,7 @@ mod tests { assert_eq!(comps, exp); } ); - ) + ); t!(s: b"a\\b\\c", ["a", "b", "c"]); t!(s: "a\\b\\c", ["a", "b", "c"]); @@ -2311,7 +2311,7 @@ mod tests { assert_eq!(comps, exp); } ) - ) + ); t!(s: "a\\b\\c", [b"a", b"b", b"c"]); t!(s: ".", [b"."]); @@ -2329,7 +2329,7 @@ mod tests { assert!(make_non_verbatim(&path) == exp); } ) - ) + ); t!(r"\a\b\c", Some(r"\a\b\c")); t!(r"a\b\c", Some(r"a\b\c")); diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs index 5b5fa2952e6..d8e1fc25654 100644 --- a/src/libstd/rand/mod.rs +++ b/src/libstd/rand/mod.rs @@ -350,7 +350,7 @@ pub fn task_rng() -> TaskRng { TASK_RNG_RESEED_THRESHOLD, TaskRngReseeder); Rc::new(RefCell::new(rng)) - }) + }); TaskRng { rng: TASK_RNG_KEY.with(|t| t.clone()) } } diff --git a/src/libstd/rt/backtrace.rs b/src/libstd/rt/backtrace.rs index ad4695eb7fe..c2fc7653b09 100644 --- a/src/libstd/rt/backtrace.rs +++ b/src/libstd/rt/backtrace.rs @@ -109,7 +109,7 @@ fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> { rest = rest.slice_to(i); while rest.len() > 0 { if rest.starts_with("$") { - macro_rules! demangle( + macro_rules! demangle { ($($pat:expr => $demangled:expr),*) => ({ $(if rest.starts_with($pat) { try!(writer.write_str($demangled)); @@ -121,7 +121,8 @@ fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> { } }) - ) + } + // see src/librustc/back/link.rs for these mappings demangle! ( "$SP$" => "@", @@ -933,12 +934,12 @@ mod imp { Err(..) => return Ok(()), }; - macro_rules! sym( ($e:expr, $t:ident) => (unsafe { + macro_rules! sym { ($e:expr, $t:ident) => (unsafe { match lib.symbol($e) { Ok(f) => mem::transmute::<*mut u8, $t>(f), Err(..) => return Ok(()) } - }) ) + }) } // Fetch the symbols necessary from dbghelp.dll let SymFromAddr = sym!("SymFromAddr", SymFromAddrFn); @@ -1003,11 +1004,13 @@ mod imp { #[cfg(test)] mod test { use prelude::*; - macro_rules! t( ($a:expr, $b:expr) => ({ + use io::MemWriter; + + macro_rules! t { ($a:expr, $b:expr) => ({ let mut m = Vec::new(); super::demangle(&mut m, $a).unwrap(); assert_eq!(String::from_utf8(m).unwrap(), $b); - }) ) + }) } #[test] fn demangle() { diff --git a/src/libstd/sys/unix/mod.rs b/src/libstd/sys/unix/mod.rs index 107263c31a7..acbf2096326 100644 --- a/src/libstd/sys/unix/mod.rs +++ b/src/libstd/sys/unix/mod.rs @@ -23,7 +23,7 @@ use prelude::*; use io::{mod, IoResult, IoError}; use sys_common::mkerr_libc; -macro_rules! helper_init( (static $name:ident: Helper<$m:ty>) => ( +macro_rules! helper_init { (static $name:ident: Helper<$m:ty>) => ( static $name: Helper<$m> = Helper { lock: ::sync::MUTEX_INIT, cond: ::sync::CONDVAR_INIT, @@ -32,7 +32,7 @@ macro_rules! helper_init( (static $name:ident: Helper<$m:ty>) => ( initialized: ::cell::UnsafeCell { value: false }, shutdown: ::cell::UnsafeCell { value: false }, }; -) ) +) } pub mod c; pub mod ext; diff --git a/src/libstd/sys/unix/process.rs b/src/libstd/sys/unix/process.rs index 4ef1757cc3a..835f4279d9b 100644 --- a/src/libstd/sys/unix/process.rs +++ b/src/libstd/sys/unix/process.rs @@ -28,7 +28,7 @@ use sys_common::{AsInner, mkerr_libc, timeout}; pub use sys_common::ProcessConfig; -helper_init!(static HELPER: Helper<Req>) +helper_init! { static HELPER: Helper<Req> } /// The unique id of the process (this should never be negative). pub struct Process { diff --git a/src/libstd/sys/unix/timer.rs b/src/libstd/sys/unix/timer.rs index 6ebbedb8e90..79a6a871f8d 100644 --- a/src/libstd/sys/unix/timer.rs +++ b/src/libstd/sys/unix/timer.rs @@ -60,7 +60,7 @@ use sys_common::helper_thread::Helper; use prelude::*; use io::IoResult; -helper_init!(static HELPER: Helper<Req>) +helper_init! { static HELPER: Helper<Req> } pub trait Callback { fn call(&mut self); diff --git a/src/libstd/sys/windows/c.rs b/src/libstd/sys/windows/c.rs index e46765f25b8..d1cb91bcdb3 100644 --- a/src/libstd/sys/windows/c.rs +++ b/src/libstd/sys/windows/c.rs @@ -169,7 +169,7 @@ pub mod compat { /// /// Note that arguments unused by the fallback implementation should not be called `_` as /// they are used to be passed to the real function if available. - macro_rules! compat_fn( + macro_rules! compat_fn { ($module:ident::$symbol:ident($($argname:ident: $argtype:ty),*) -> $rettype:ty $fallback:block) => ( #[inline(always)] @@ -195,7 +195,7 @@ pub mod compat { ($module:ident::$symbol:ident($($argname:ident: $argtype:ty),*) $fallback:block) => ( compat_fn!($module::$symbol($($argname: $argtype),*) -> () $fallback) ) - ) + } /// Compatibility layer for functions in `kernel32.dll` /// @@ -211,20 +211,20 @@ pub mod compat { fn SetLastError(dwErrCode: DWORD); } - compat_fn!(kernel32::CreateSymbolicLinkW(_lpSymlinkFileName: LPCWSTR, + compat_fn! { kernel32::CreateSymbolicLinkW(_lpSymlinkFileName: LPCWSTR, _lpTargetFileName: LPCWSTR, _dwFlags: DWORD) -> BOOLEAN { unsafe { SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); } 0 - }) + } } - compat_fn!(kernel32::GetFinalPathNameByHandleW(_hFile: HANDLE, + compat_fn! { kernel32::GetFinalPathNameByHandleW(_hFile: HANDLE, _lpszFilePath: LPCWSTR, _cchFilePath: DWORD, _dwFlags: DWORD) -> DWORD { unsafe { SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); } 0 - }) + } } } } diff --git a/src/libstd/sys/windows/mod.rs b/src/libstd/sys/windows/mod.rs index 41361a0cde6..d22d4e0f534 100644 --- a/src/libstd/sys/windows/mod.rs +++ b/src/libstd/sys/windows/mod.rs @@ -24,7 +24,7 @@ use prelude::*; use io::{mod, IoResult, IoError}; use sync::{Once, ONCE_INIT}; -macro_rules! helper_init( (static $name:ident: Helper<$m:ty>) => ( +macro_rules! helper_init { (static $name:ident: Helper<$m:ty>) => ( static $name: Helper<$m> = Helper { lock: ::sync::MUTEX_INIT, cond: ::sync::CONDVAR_INIT, @@ -33,7 +33,7 @@ macro_rules! helper_init( (static $name:ident: Helper<$m:ty>) => ( initialized: ::cell::UnsafeCell { value: false }, shutdown: ::cell::UnsafeCell { value: false }, }; -) ) +) } pub mod c; pub mod ext; diff --git a/src/libstd/sys/windows/timer.rs b/src/libstd/sys/windows/timer.rs index 9af3a7c8b6e..e2f9e2a9201 100644 --- a/src/libstd/sys/windows/timer.rs +++ b/src/libstd/sys/windows/timer.rs @@ -32,7 +32,7 @@ use sys_common::helper_thread::Helper; use prelude::*; use io::IoResult; -helper_init!(static HELPER: Helper<Req>) +helper_init! { static HELPER: Helper<Req> } pub trait Callback { fn call(&mut self); diff --git a/src/libstd/thread_local/mod.rs b/src/libstd/thread_local/mod.rs index 76fb703514b..1268ab8e0cf 100644 --- a/src/libstd/thread_local/mod.rs +++ b/src/libstd/thread_local/mod.rs @@ -109,7 +109,7 @@ pub struct Key<T> { /// Declare a new thread local storage key of type `std::thread_local::Key`. #[macro_export] #[doc(hidden)] -macro_rules! thread_local( +macro_rules! thread_local { (static $name:ident: $t:ty = $init:expr) => ( static $name: ::std::thread_local::Key<$t> = { use std::cell::UnsafeCell as __UnsafeCell; @@ -119,7 +119,7 @@ macro_rules! thread_local( __thread_local_inner!(static __KEY: __UnsafeCell<__Option<$t>> = { __UnsafeCell { value: __None } - }) + }); fn __init() -> $t { $init } fn __getit() -> &'static __KeyInner<__UnsafeCell<__Option<$t>>> { &__KEY @@ -136,7 +136,7 @@ macro_rules! thread_local( __thread_local_inner!(static __KEY: __UnsafeCell<__Option<$t>> = { __UnsafeCell { value: __None } - }) + }); fn __init() -> $t { $init } fn __getit() -> &'static __KeyInner<__UnsafeCell<__Option<$t>>> { &__KEY @@ -144,7 +144,7 @@ macro_rules! thread_local( ::std::thread_local::Key { inner: __getit, init: __init } }; ); -) +} // Macro pain #4586: // @@ -167,7 +167,7 @@ macro_rules! thread_local( // itself. Woohoo. #[macro_export] -macro_rules! __thread_local_inner( +macro_rules! __thread_local_inner { (static $name:ident: $t:ty = $init:expr) => ( #[cfg_attr(any(target_os = "macos", target_os = "linux"), thread_local)] static $name: ::std::thread_local::KeyInner<$t> = @@ -204,7 +204,7 @@ macro_rules! __thread_local_inner( INIT }); -) +} impl<T: 'static> Key<T> { /// Acquire a reference to the value in this TLS key. @@ -459,7 +459,7 @@ mod tests { #[test] fn smoke_no_dtor() { - thread_local!(static FOO: UnsafeCell<int> = UnsafeCell { value: 1 }) + thread_local!(static FOO: UnsafeCell<int> = UnsafeCell { value: 1 }); FOO.with(|f| unsafe { assert_eq!(*f.get(), 1); @@ -483,7 +483,7 @@ mod tests { fn smoke_dtor() { thread_local!(static FOO: UnsafeCell<Option<Foo>> = UnsafeCell { value: None - }) + }); let (tx, rx) = channel(); spawn(move|| unsafe { @@ -501,10 +501,10 @@ mod tests { struct S2; thread_local!(static K1: UnsafeCell<Option<S1>> = UnsafeCell { value: None - }) + }); thread_local!(static K2: UnsafeCell<Option<S2>> = UnsafeCell { value: None - }) + }); static mut HITS: uint = 0; impl Drop for S1 { @@ -544,7 +544,7 @@ mod tests { struct S1; thread_local!(static K1: UnsafeCell<Option<S1>> = UnsafeCell { value: None - }) + }); impl Drop for S1 { fn drop(&mut self) { @@ -562,10 +562,10 @@ mod tests { struct S1(Sender<()>); thread_local!(static K1: UnsafeCell<Option<S1>> = UnsafeCell { value: None - }) + }); thread_local!(static K2: UnsafeCell<Option<Foo>> = UnsafeCell { value: None - }) + }); impl Drop for S1 { fn drop(&mut self) { @@ -597,7 +597,7 @@ mod dynamic_tests { #[test] fn smoke() { fn square(i: int) -> int { i * i } - thread_local!(static FOO: int = square(3)) + thread_local!(static FOO: int = square(3)); FOO.with(|f| { assert_eq!(*f, 9); @@ -611,7 +611,7 @@ mod dynamic_tests { m.insert(1, 2); RefCell::new(m) } - thread_local!(static FOO: RefCell<HashMap<int, int>> = map()) + thread_local!(static FOO: RefCell<HashMap<int, int>> = map()); FOO.with(|map| { assert_eq!(map.borrow()[1], 2); @@ -620,7 +620,7 @@ mod dynamic_tests { #[test] fn refcell_vec() { - thread_local!(static FOO: RefCell<Vec<uint>> = RefCell::new(vec![1, 2, 3])) + thread_local!(static FOO: RefCell<Vec<uint>> = RefCell::new(vec![1, 2, 3])); FOO.with(|vec| { assert_eq!(vec.borrow().len(), 3); diff --git a/src/libstd/thread_local/scoped.rs b/src/libstd/thread_local/scoped.rs index ee742ab8375..7762d225b9a 100644 --- a/src/libstd/thread_local/scoped.rs +++ b/src/libstd/thread_local/scoped.rs @@ -24,7 +24,7 @@ //! # Example //! //! ``` -//! scoped_thread_local!(static FOO: uint) +//! scoped_thread_local!(static FOO: uint); //! //! // Initially each scoped slot is empty. //! assert!(!FOO.is_set()); @@ -60,18 +60,18 @@ pub struct Key<T> { #[doc(hidden)] pub inner: KeyInner<T> } /// This macro declares a `static` item on which methods are used to get and /// set the value stored within. #[macro_export] -macro_rules! scoped_thread_local( +macro_rules! scoped_thread_local { (static $name:ident: $t:ty) => ( __scoped_thread_local_inner!(static $name: $t) ); (pub static $name:ident: $t:ty) => ( __scoped_thread_local_inner!(pub static $name: $t) ); -) +} #[macro_export] #[doc(hidden)] -macro_rules! __scoped_thread_local_inner( +macro_rules! __scoped_thread_local_inner { (static $name:ident: $t:ty) => ( #[cfg_attr(not(any(windows, target_os = "android", target_os = "ios")), thread_local)] @@ -104,7 +104,7 @@ macro_rules! __scoped_thread_local_inner( INIT }) -) +} impl<T> Key<T> { /// Insert a value into this scoped thread local storage slot for a @@ -119,7 +119,7 @@ impl<T> Key<T> { /// # Example /// /// ``` - /// scoped_thread_local!(static FOO: uint) + /// scoped_thread_local!(static FOO: uint); /// /// FOO.set(&100, || { /// let val = FOO.with(|v| *v); @@ -171,7 +171,7 @@ impl<T> Key<T> { /// # Example /// /// ```no_run - /// scoped_thread_local!(static FOO: uint) + /// scoped_thread_local!(static FOO: uint); /// /// FOO.with(|slot| { /// // work with `slot` @@ -239,7 +239,7 @@ mod tests { #[test] fn smoke() { - scoped_thread_local!(static BAR: uint) + scoped_thread_local!(static BAR: uint); assert!(!BAR.is_set()); BAR.set(&1, || { @@ -253,7 +253,7 @@ mod tests { #[test] fn cell_allowed() { - scoped_thread_local!(static BAR: Cell<uint>) + scoped_thread_local!(static BAR: Cell<uint>); BAR.set(&Cell::new(1), || { BAR.with(|slot| { diff --git a/src/libstd/time/duration.rs b/src/libstd/time/duration.rs index f98cebd9675..8c4a5a6b8c7 100644 --- a/src/libstd/time/duration.rs +++ b/src/libstd/time/duration.rs @@ -40,9 +40,9 @@ const SECS_PER_DAY: i64 = 86400; /// The number of (non-leap) seconds in a week. const SECS_PER_WEEK: i64 = 604800; -macro_rules! try_opt( +macro_rules! try_opt { ($e:expr) => (match $e { Some(v) => v, None => return None }) -) +} /// ISO 8601 time duration with nanosecond precision. |
