From 416137eb3186c05b7a601e94cde354e9b3ec0a78 Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Fri, 2 Jan 2015 14:44:21 -0800 Subject: [PATCH] Modernize macro_rules! invocations macro_rules! is like an item that defines a macro. Other items don't have a trailing semicolon, or use a paren-delimited body. If there's an argument for matching the invocation syntax, e.g. parentheses for an expr macro, then I think that applies more strongly to the *inner* delimiters on the LHS, wrapping the individual argument patterns. --- src/grammar/verify.rs | 4 +- src/libcollections/slice.rs | 8 +- src/libcollections/str.rs | 8 +- src/libcollections/string.rs | 4 +- src/libcore/result.rs | 4 +- src/libcore/str/mod.rs | 9 +- src/libcoretest/num/int_macros.rs | 4 +- src/libcoretest/num/uint_macros.rs | 5 +- src/librand/distributions/mod.rs | 4 +- src/librand/distributions/range.rs | 8 +- src/librand/isaac.rs | 141 +++++++++--------- src/librustc/lint/context.rs | 36 +++-- src/librustc/middle/const_eval.rs | 4 +- src/librustc/middle/ty.rs | 4 +- src/librustc_back/sha2.rs | 8 +- src/librustc_back/target/mod.rs | 8 +- src/librustc_trans/trans/context.rs | 12 +- src/libstd/path/posix.rs | 68 ++++----- src/libstd/path/windows.rs | 76 +++++----- src/libsyntax/ext/deriving/cmp/eq.rs | 4 +- src/libsyntax/ext/deriving/cmp/ord.rs | 4 +- src/libsyntax/ext/deriving/mod.rs | 8 +- src/libsyntax/ext/tt/macro_rules.rs | 4 +- src/libterm/terminfo/parser/compiled.rs | 4 +- src/test/auxiliary/lint_stability.rs | 12 +- src/test/auxiliary/macro_crate_def_only.rs | 4 +- src/test/auxiliary/macro_crate_test.rs | 4 +- .../auxiliary/macro_export_inner_module.rs | 4 +- src/test/bench/core-std.rs | 5 +- src/test/compile-fail/gated-macro-rules.rs | 2 +- .../compile-fail/infinite-macro-expansion.rs | 8 +- src/test/compile-fail/issue-15167.rs | 2 +- src/test/compile-fail/issue-6596.rs | 4 +- .../liveness-return-last-stmt-semi.rs | 2 +- .../compile-fail/macro-inner-attributes.rs | 4 +- .../compile-fail/macro-match-nonterminal.rs | 2 +- .../compile-fail/macro-outer-attributes.rs | 4 +- .../compile-fail/macros-no-semicolon-items.rs | 1 - .../compile-fail/method-macro-backtrace.rs | 6 +- .../compile-fail/pattern-macro-hygiene.rs | 2 +- .../borrowck-macro-interaction-issue-6304.rs | 4 +- src/test/run-pass/cleanup-rvalue-scopes.rs | 8 +- src/test/run-pass/const-binops.rs | 4 +- src/test/run-pass/core-run-destroy.rs | 4 +- src/test/run-pass/deriving-in-macro.rs | 4 +- src/test/run-pass/exponential-notation.rs | 4 +- src/test/run-pass/html-literals.rs | 8 +- src/test/run-pass/ifmt.rs | 4 +- src/test/run-pass/intrinsics-math.rs | 4 +- src/test/run-pass/issue-15189.rs | 4 +- src/test/run-pass/issue-15221.rs | 10 +- src/test/run-pass/issue-5060.rs | 4 +- src/test/run-pass/issue-7911.rs | 4 +- src/test/run-pass/issue-8709.rs | 8 +- src/test/run-pass/issue-8851.rs | 4 +- src/test/run-pass/issue-9110.rs | 4 +- src/test/run-pass/issue-9129.rs | 4 +- src/test/run-pass/issue-9737.rs | 4 +- src/test/run-pass/lambda-var-hygiene.rs | 4 +- src/test/run-pass/let-var-hygiene.rs | 5 +- src/test/run-pass/macro-2.rs | 4 +- src/test/run-pass/macro-interpolation.rs | 4 +- ...vocation-in-count-expr-fixed-array-type.rs | 4 +- src/test/run-pass/macro-multiple-items.rs | 4 +- src/test/run-pass/macro-nt-list.rs | 8 +- src/test/run-pass/macro-of-higher-order.rs | 6 +- src/test/run-pass/macro-pat.rs | 20 +-- src/test/run-pass/macro-stmt.rs | 12 +- src/test/run-pass/macro-with-attrs1.rs | 4 +- src/test/run-pass/macro-with-attrs2.rs | 4 +- .../macro-with-braces-in-expr-position.rs | 2 +- src/test/run-pass/match-in-macro.rs | 4 +- src/test/run-pass/match-var-hygiene.rs | 4 +- src/test/run-pass/non-built-in-quote.rs | 2 +- .../run-pass/syntax-extension-source-utils.rs | 2 +- .../typeck-macro-interaction-issue-8852.rs | 4 +- 76 files changed, 361 insertions(+), 331 deletions(-) diff --git a/src/grammar/verify.rs b/src/grammar/verify.rs index ad271d230904e..2e8bce3f5064b 100644 --- a/src/grammar/verify.rs +++ b/src/grammar/verify.rs @@ -268,7 +268,7 @@ fn main() { assert!(rustc_tok.sp == antlr_tok.sp, "{} and {} have different spans", rustc_tok, antlr_tok); - macro_rules! matches ( + macro_rules! matches { ( $($x:pat),+ ) => ( match rustc_tok.tok { $($x => match antlr_tok.tok { @@ -284,7 +284,7 @@ fn main() { ref c => assert!(c == &antlr_tok.tok, "{} is not {}", rustc_tok, antlr_tok) } ) - ); + } matches!( token::Literal(token::Byte(..), _), diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index 3602bfc10c307..6a9abfbd22ee5 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -2460,13 +2460,13 @@ mod tests { #[test] fn test_show() { - macro_rules! test_show_vec( + macro_rules! test_show_vec { ($x:expr, $x_str:expr) => ({ let (x, x_str) = ($x, $x_str); assert_eq!(format!("{}", x), x_str); assert_eq!(format!("{}", x.as_slice()), x_str); }) - ); + } let empty: Vec = vec![]; test_show_vec!(empty, "[]"); test_show_vec!(vec![1i], "[1]"); @@ -2486,12 +2486,12 @@ mod tests { #[test] fn test_vec_default() { - macro_rules! t ( + macro_rules! t { ($ty:ty) => {{ let v: $ty = Default::default(); assert!(v.is_empty()); }} - ); + } t!(&[int]); t!(Vec); diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index ecf17820d2d8f..69403ccd88be8 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -1838,7 +1838,9 @@ mod tests { #[test] fn test_is_utf16() { use unicode::str::is_utf16; - macro_rules! pos ( ($($e:expr),*) => { { $(assert!(is_utf16($e));)* } }); + macro_rules! pos { + ($($e:expr),*) => { { $(assert!(is_utf16($e));)* } } + } // non-surrogates pos!(&[0x0000], @@ -1858,7 +1860,9 @@ mod tests { &[0x0067, 0xd8ff, 0xddb7, 0x000f, 0xd900, 0xdc80]); // negative tests - macro_rules! neg ( ($($e:expr),*) => { { $(assert!(!is_utf16($e));)* } }); + macro_rules! neg { + ($($e:expr),*) => { { $(assert!(!is_utf16($e));)* } } + } neg!( // surrogate + regular unit diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index e7451331908ae..8fe636f8cd392 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -182,7 +182,7 @@ impl String { let byte = unsafe_get(v, i); i += 1; - macro_rules! error(() => ({ + macro_rules! error { () => ({ unsafe { if subseqidx != i_ { res.as_mut_vec().push_all(v[subseqidx..i_]); @@ -190,7 +190,7 @@ impl String { subseqidx = i; res.as_mut_vec().push_all(REPLACEMENT); } - })); + })} if byte < 128u8 { // subseqidx handles this diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 7135faaa76516..3ed0116c28911 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -220,9 +220,9 @@ //! //! ``` //! # #![feature(macro_rules)] -//! macro_rules! try( +//! macro_rules! try { //! ($e:expr) => (match $e { Ok(e) => e, Err(e) => return Err(e) }) -//! ); +//! } //! # fn main() { } //! ``` //! diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index d069744f8da54..02887024d00cb 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -948,17 +948,18 @@ fn run_utf8_validation_iterator(iter: &mut slice::Iter) let old = *iter; // restore the iterator we had at the start of this codepoint. - macro_rules! err (() => { { + macro_rules! err { () => {{ *iter = old; return Err(Utf8Error::InvalidByte(whole.len() - iter.as_slice().len())) - } }); - macro_rules! next ( () => { + }}} + + macro_rules! next { () => { match iter.next() { Some(a) => *a, // we needed data, but there was none: error! None => return Err(Utf8Error::TooShort), } - }); + }} let first = match iter.next() { Some(&b) => b, diff --git a/src/libcoretest/num/int_macros.rs b/src/libcoretest/num/int_macros.rs index 965ffde70970b..b98432e26b215 100644 --- a/src/libcoretest/num/int_macros.rs +++ b/src/libcoretest/num/int_macros.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -macro_rules! int_module (($T:ty, $T_i:ident) => ( +macro_rules! int_module { ($T:ty, $T_i:ident) => ( #[cfg(test)] mod tests { use core::$T_i::*; @@ -203,4 +203,4 @@ mod tests { } } -)); +)} diff --git a/src/libcoretest/num/uint_macros.rs b/src/libcoretest/num/uint_macros.rs index eff238c816eee..04d8fb15cf5aa 100644 --- a/src/libcoretest/num/uint_macros.rs +++ b/src/libcoretest/num/uint_macros.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -macro_rules! uint_module (($T:ty, $T_i:ident) => ( +macro_rules! uint_module { ($T:ty, $T_i:ident) => ( #[cfg(test)] mod tests { use core::$T_i::*; @@ -123,4 +123,5 @@ mod tests { assert!(5u.checked_div(0) == None); } } -)); + +)} diff --git a/src/librand/distributions/mod.rs b/src/librand/distributions/mod.rs index e684fcf40f7b3..2fdba8a6c4f96 100644 --- a/src/librand/distributions/mod.rs +++ b/src/librand/distributions/mod.rs @@ -297,7 +297,7 @@ mod tests { // it doesn't do weird things to the RNG (so 0 maps to 0, 1 to // 1, internally; modulo a modulo operation). - macro_rules! t ( + macro_rules! t { ($items:expr, $expected:expr) => {{ let mut items = $items; let wc = WeightedChoice::new(items.as_mut_slice()); @@ -309,7 +309,7 @@ mod tests { assert_eq!(wc.ind_sample(&mut rng), val) } }} - ); + } t!(vec!(Weighted { weight: 1, item: 10i}), [10]); diff --git a/src/librand/distributions/range.rs b/src/librand/distributions/range.rs index 558fa20125675..1038009522d67 100644 --- a/src/librand/distributions/range.rs +++ b/src/librand/distributions/range.rs @@ -182,7 +182,7 @@ mod tests { #[test] fn test_integers() { let mut rng = ::test::rng(); - macro_rules! t ( + macro_rules! t { ($($ty:ty),*) => {{ $( let v: &[($ty, $ty)] = &[(0, 10), @@ -199,7 +199,7 @@ mod tests { } )* }} - ); + } t!(i8, i16, i32, i64, int, u8, u16, u32, u64, uint) } @@ -207,7 +207,7 @@ mod tests { #[test] fn test_floats() { let mut rng = ::test::rng(); - macro_rules! t ( + macro_rules! t { ($($ty:ty),*) => {{ $( let v: &[($ty, $ty)] = &[(0.0, 100.0), @@ -225,7 +225,7 @@ mod tests { } )* }} - ); + } t!(f32, f64) } diff --git a/src/librand/isaac.rs b/src/librand/isaac.rs index 53ae242c5e245..698730302b9ca 100644 --- a/src/librand/isaac.rs +++ b/src/librand/isaac.rs @@ -69,7 +69,7 @@ impl IsaacRng { let mut g = a; let mut h = a; - macro_rules! mix( + macro_rules! mix { () => {{ a^=b<<11; d+=a; b+=c; b^=c>>2; e+=b; c+=d; @@ -80,14 +80,14 @@ impl IsaacRng { g^=h<<8; b+=g; h+=a; h^=a>>9; c+=h; a+=b; }} - ); + } for _ in range(0u, 4) { mix!(); } if use_rsl { - macro_rules! memloop ( + macro_rules! memloop { ($arr:expr) => {{ for i in range_step(0, RAND_SIZE as uint, 8) { a+=$arr[i ]; b+=$arr[i+1]; @@ -101,7 +101,7 @@ impl IsaacRng { self.mem[i+6]=g; self.mem[i+7]=h; } }} - ); + } memloop!(self.rsl); memloop!(self.mem); @@ -129,41 +129,42 @@ impl IsaacRng { static MIDPOINT: uint = (RAND_SIZE / 2) as uint; - macro_rules! ind (($x:expr) => { - self.mem[(($x >> 2) as uint & ((RAND_SIZE - 1) as uint))] - }); + macro_rules! ind { + ($x:expr) => ( self.mem[(($x >> 2) as uint & ((RAND_SIZE - 1) as uint))] ) + } let r = [(0, MIDPOINT), (MIDPOINT, 0)]; for &(mr_offset, m2_offset) in r.iter() { - macro_rules! rngstepp( + macro_rules! rngstepp { ($j:expr, $shift:expr) => {{ - let base = $j; - let mix = a << $shift as uint; + let base = $j; + let mix = a << $shift as uint; - let x = self.mem[base + mr_offset]; - a = (a ^ mix) + self.mem[base + m2_offset]; - let y = ind!(x) + a + b; - self.mem[base + mr_offset] = y; + let x = self.mem[base + mr_offset]; + a = (a ^ mix) + self.mem[base + m2_offset]; + let y = ind!(x) + a + b; + self.mem[base + mr_offset] = y; - b = ind!(y >> RAND_SIZE_LEN as uint) + x; - self.rsl[base + mr_offset] = b; - }} - ); - macro_rules! rngstepn( + b = ind!(y >> RAND_SIZE_LEN as uint) + x; + self.rsl[base + mr_offset] = b; + }} + } + + macro_rules! rngstepn { ($j:expr, $shift:expr) => {{ - let base = $j; - let mix = a >> $shift as uint; + let base = $j; + let mix = a >> $shift as uint; - let x = self.mem[base + mr_offset]; - a = (a ^ mix) + self.mem[base + m2_offset]; - let y = ind!(x) + a + b; - self.mem[base + mr_offset] = y; + let x = self.mem[base + mr_offset]; + a = (a ^ mix) + self.mem[base + m2_offset]; + let y = ind!(x) + a + b; + self.mem[base + mr_offset] = y; - b = ind!(y >> RAND_SIZE_LEN as uint) + x; - self.rsl[base + mr_offset] = b; - }} - ); + b = ind!(y >> RAND_SIZE_LEN as uint) + x; + self.rsl[base + mr_offset] = b; + }} + } for i in range_step(0u, MIDPOINT, 4) { rngstepp!(i + 0, 13); @@ -294,15 +295,15 @@ impl Isaac64Rng { /// of `rsl` as a seed, otherwise construct one algorithmically (not /// randomly). fn init(&mut self, use_rsl: bool) { - macro_rules! init ( + macro_rules! init { ($var:ident) => ( let mut $var = 0x9e3779b97f4a7c13; ) - ); + } init!(a); init!(b); init!(c); init!(d); init!(e); init!(f); init!(g); init!(h); - macro_rules! mix( + macro_rules! mix { () => {{ a-=e; f^=h>>9; h+=a; b-=f; g^=a<<9; a+=b; @@ -313,14 +314,14 @@ impl Isaac64Rng { g-=c; d^=f>>17; f+=g; h-=d; e^=g<<14; g+=h; }} - ); + } for _ in range(0u, 4) { mix!(); } if use_rsl { - macro_rules! memloop ( + macro_rules! memloop { ($arr:expr) => {{ for i in range(0, RAND_SIZE_64 / 8).map(|i| i * 8) { a+=$arr[i ]; b+=$arr[i+1]; @@ -334,7 +335,7 @@ impl Isaac64Rng { self.mem[i+6]=g; self.mem[i+7]=h; } }} - ); + } memloop!(self.rsl); memloop!(self.mem); @@ -359,49 +360,51 @@ impl Isaac64Rng { let mut b = self.b + self.c; const MIDPOINT: uint = RAND_SIZE_64 / 2; const MP_VEC: [(uint, uint); 2] = [(0,MIDPOINT), (MIDPOINT, 0)]; - macro_rules! ind ( + macro_rules! ind { ($x:expr) => { *self.mem.get_unchecked(($x as uint >> 3) & (RAND_SIZE_64 - 1)) } - ); + } for &(mr_offset, m2_offset) in MP_VEC.iter() { for base in range(0, MIDPOINT / 4).map(|i| i * 4) { - macro_rules! rngstepp( + macro_rules! rngstepp { ($j:expr, $shift:expr) => {{ - let base = base + $j; - let mix = a ^ (a << $shift as uint); - let mix = if $j == 0 {!mix} else {mix}; - - unsafe { - let x = *self.mem.get_unchecked(base + mr_offset); - a = mix + *self.mem.get_unchecked(base + m2_offset); - let y = ind!(x) + a + b; - *self.mem.get_unchecked_mut(base + mr_offset) = y; - - b = ind!(y >> RAND_SIZE_64_LEN) + x; - *self.rsl.get_unchecked_mut(base + mr_offset) = b; - } - }} - ); - macro_rules! rngstepn( + let base = base + $j; + let mix = a ^ (a << $shift as uint); + let mix = if $j == 0 {!mix} else {mix}; + + unsafe { + let x = *self.mem.get_unchecked(base + mr_offset); + a = mix + *self.mem.get_unchecked(base + m2_offset); + let y = ind!(x) + a + b; + *self.mem.get_unchecked_mut(base + mr_offset) = y; + + b = ind!(y >> RAND_SIZE_64_LEN) + x; + *self.rsl.get_unchecked_mut(base + mr_offset) = b; + } + }} + } + + macro_rules! rngstepn { ($j:expr, $shift:expr) => {{ - let base = base + $j; - let mix = a ^ (a >> $shift as uint); - let mix = if $j == 0 {!mix} else {mix}; - - unsafe { - let x = *self.mem.get_unchecked(base + mr_offset); - a = mix + *self.mem.get_unchecked(base + m2_offset); - let y = ind!(x) + a + b; - *self.mem.get_unchecked_mut(base + mr_offset) = y; - - b = ind!(y >> RAND_SIZE_64_LEN) + x; - *self.rsl.get_unchecked_mut(base + mr_offset) = b; - } - }} - ); + let base = base + $j; + let mix = a ^ (a >> $shift as uint); + let mix = if $j == 0 {!mix} else {mix}; + + unsafe { + let x = *self.mem.get_unchecked(base + mr_offset); + a = mix + *self.mem.get_unchecked(base + m2_offset); + let y = ind!(x) + a + b; + *self.mem.get_unchecked_mut(base + mr_offset) = y; + + b = ind!(y >> RAND_SIZE_64_LEN) + x; + *self.rsl.get_unchecked_mut(base + mr_offset) = b; + } + }} + } + rngstepp!(0u, 21); rngstepn!(1u, 5); rngstepp!(2u, 12); diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 69e5b4889c288..c070bed2be23d 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -167,21 +167,27 @@ impl LintStore { } pub fn register_builtin(&mut self, sess: Option<&Session>) { - macro_rules! add_builtin ( ( $sess:ident, $($name:ident),*, ) => ( - {$( - 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)),*]); - )); + macro_rules! add_builtin { + ($sess:ident, $($name:ident),*,) => ( + {$( + 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, diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index 6671f0f72f674..f50d629dae789 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -503,7 +503,7 @@ pub fn eval_const_expr_partial(tcx: &ty::ctxt, e: &Expr) -> Result ( $intermediate_ty:ty, @@ -524,7 +524,7 @@ pub fn eval_const_expr_partial(tcx: &ty::ctxt, e: &Expr) -> Result Err("can't cast this type".to_string()) }) - ); + } eval_const_expr_partial(tcx, &**base) .and_then(|val| define_casts!(val, { diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 5834844382207..b1098c5d9f7a1 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -6237,8 +6237,8 @@ pub fn hash_crate_independent<'tcx>(tcx: &ctxt<'tcx>, ty: Ty<'tcx>, svh: &Svh) - return state.result(); fn helper<'tcx>(tcx: &ctxt<'tcx>, ty: Ty<'tcx>, svh: &Svh, state: &mut sip::SipState) { - macro_rules! byte( ($b:expr) => { ($b as u8).hash(state) } ); - macro_rules! hash( ($e:expr) => { $e.hash(state) } ); + macro_rules! byte { ($b:expr) => { ($b as u8).hash(state) } } + macro_rules! hash { ($e:expr) => { $e.hash(state) } } let region = |&: state: &mut sip::SipState, r: Region| { match r { diff --git a/src/librustc_back/sha2.rs b/src/librustc_back/sha2.rs index 1e55f442fb9ac..d606c5158d0f7 100644 --- a/src/librustc_back/sha2.rs +++ b/src/librustc_back/sha2.rs @@ -346,12 +346,12 @@ impl Engine256State { // Sha-512 and Sha-256 use basically the same calculations which are implemented // by these macros. Inlining the calculations seems to result in better generated code. - macro_rules! schedule_round( ($t:expr) => ( + 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( + macro_rules! sha2_round { ($A:ident, $B:ident, $C:ident, $D:ident, $E:ident, $F:ident, $G:ident, $H:ident, $K:ident, $t:expr) => ( { @@ -360,7 +360,7 @@ impl Engine256State { $H += sum0($A) + maj($A, $B, $C); } ) - ); + } read_u32v_be(w.slice_mut(0, 16), data); diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs index d53f97c3a0423..f14583bb9aa81 100644 --- a/src/librustc_back/target/mod.rs +++ b/src/librustc_back/target/mod.rs @@ -239,7 +239,7 @@ impl Target { options: Default::default(), }; - macro_rules! key ( + macro_rules! key { ($key_name:ident) => ( { let name = (stringify!($key_name)).replace("_", "-"); obj.find(name[]).map(|o| o.as_string() @@ -257,7 +257,7 @@ impl Target { ) ); } ); - ); + } key!(cpu); key!(linker); @@ -305,7 +305,7 @@ impl Target { } // this would use a match if stringify! were allowed in pattern position - macro_rules! load_specific ( + macro_rules! load_specific { ( $($name:ident),+ ) => ( { let target = target.replace("-", "_"); @@ -326,7 +326,7 @@ impl Target { } } ) - ); + } load_specific!( x86_64_unknown_linux_gnu, diff --git a/src/librustc_trans/trans/context.rs b/src/librustc_trans/trans/context.rs index e5a0e2e9234d5..b121dbec011c9 100644 --- a/src/librustc_trans/trans/context.rs +++ b/src/librustc_trans/trans/context.rs @@ -741,7 +741,7 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> { } fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option { - macro_rules! ifn ( + macro_rules! ifn { ($name:expr fn() -> $ret:expr) => ( if *key == $name { let f = base::decl_cdecl_fn( @@ -759,10 +759,10 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option (Type::struct_(ccx, &[$($field_ty),*], false)) - ); + } let i8p = Type::i8p(ccx); let void = Type::void(ccx); @@ -883,7 +883,7 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option $ret:expr) => ( if unsafe { llvm::LLVMVersionMinor() >= 4 } { // The `if key == $name` is already in ifn! @@ -896,7 +896,7 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option t_f32); compatible_ifn!("llvm.copysign.f64", copysign(t_f64, t_f64) -> t_f64); diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index ae82e201cb855..a78dfe3edceda 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -558,7 +558,7 @@ mod tests { t!(b"foo/\xFFbar", filename_display, "\u{FFFD}bar"); t!(b"/", filename_display, ""); - macro_rules! t( + macro_rules! t { ($path:expr, $exp:expr) => ( { let path = Path::new($path); @@ -573,7 +573,7 @@ mod tests { assert!(mo.as_slice() == $exp); } ) - ); + } t!("foo", "foo"); t!(b"foo\x80", "foo\u{FFFD}"); @@ -585,7 +585,7 @@ mod tests { #[test] fn test_display() { - macro_rules! t( + macro_rules! t { ($path:expr, $exp:expr, $expf:expr) => ( { let path = Path::new($path); @@ -595,7 +595,7 @@ mod tests { assert!(f == $expf); } ) - ); + } t!(b"foo", "foo", "foo"); t!(b"foo/bar", "foo/bar", "bar"); @@ -608,7 +608,7 @@ mod tests { #[test] fn test_components() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $op:ident, $exp:expr) => ( { let path = Path::new($path); @@ -629,7 +629,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")); @@ -692,7 +692,7 @@ mod tests { #[test] fn test_push() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $join:expr) => ( { let path = $path; @@ -703,7 +703,7 @@ mod tests { assert!(p1 == p2.join(join)); } ) - ); + } t!(s: "a/b/c", ".."); t!(s: "/a/b/c", "d"); @@ -713,7 +713,7 @@ mod tests { #[test] fn test_push_path() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $push:expr, $exp:expr) => ( { let mut p = Path::new($path); @@ -722,7 +722,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"); @@ -734,7 +734,7 @@ mod tests { #[test] fn test_push_many() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $push:expr, $exp:expr) => ( { let mut p = Path::new($path); @@ -749,7 +749,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"); @@ -762,7 +762,7 @@ mod tests { #[test] fn test_pop() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $left:expr, $right:expr) => ( { let mut p = Path::new($path); @@ -779,7 +779,7 @@ mod tests { assert!(result == $right); } ) - ); + } t!(b: b"a/b/c", b"a/b", true); t!(b: b"a", b".", true); @@ -818,7 +818,7 @@ mod tests { #[test] fn test_join_path() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $join:expr, $exp:expr) => ( { let path = Path::new($path); @@ -827,7 +827,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"); @@ -839,7 +839,7 @@ mod tests { #[test] fn test_join_many() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $join:expr, $exp:expr) => ( { let path = Path::new($path); @@ -854,7 +854,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"); @@ -917,7 +917,7 @@ mod tests { #[test] fn test_setters() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $set:ident, $with:ident, $arg:expr) => ( { let path = $path; @@ -938,7 +938,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"); @@ -961,7 +961,7 @@ mod tests { #[test] fn test_getters() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $filename:expr, $dirname:expr, $filestem:expr, $ext:expr) => ( { let path = $path; @@ -992,7 +992,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); @@ -1031,7 +1031,7 @@ mod tests { #[test] fn test_is_absolute() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $abs:expr, $rel:expr) => ( { let path = Path::new($path); @@ -1039,7 +1039,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); @@ -1052,7 +1052,7 @@ mod tests { #[test] fn test_is_ancestor_of() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $dest:expr, $exp:expr) => ( { let path = Path::new($path); @@ -1060,7 +1060,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); @@ -1086,7 +1086,7 @@ mod tests { #[test] fn test_ends_with_path() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $child:expr, $exp:expr) => ( { let path = Path::new($path); @@ -1101,7 +1101,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); @@ -1125,7 +1125,7 @@ mod tests { #[test] fn test_path_relative_from() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $other:expr, $exp:expr) => ( { let path = Path::new($path); @@ -1134,7 +1134,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")); @@ -1170,7 +1170,7 @@ mod tests { #[test] fn test_components_iter() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $exp:expr) => ( { let path = Path::new($path); @@ -1196,7 +1196,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"]); @@ -1216,7 +1216,7 @@ mod tests { #[test] fn test_str_components() { - macro_rules! t( + macro_rules! t { (b: $arg:expr, $exp:expr) => ( { let path = Path::new($arg); @@ -1228,7 +1228,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 cf8bc0e6242b3..30ed07446a400 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -1149,7 +1149,7 @@ mod tests { #[test] fn test_parse_prefix() { - macro_rules! t( + macro_rules! t { ($path:expr, $exp:expr) => ( { let path = $path; @@ -1159,7 +1159,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 { #[test] fn test_display() { - macro_rules! t( + macro_rules! t { ($path:expr, $exp:expr, $expf:expr) => ( { let path = Path::new($path); @@ -1358,7 +1358,7 @@ mod tests { assert_eq!(f, $expf); } ) - ); + } t!("foo", "foo", "foo"); t!("foo\\bar", "foo\\bar", "bar"); @@ -1367,7 +1367,7 @@ mod tests { #[test] fn test_components() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $op:ident, $exp:expr) => ( { let path = $path; @@ -1390,7 +1390,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"); @@ -1490,7 +1490,7 @@ mod tests { #[test] fn test_push() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $join:expr) => ( { let path = $path; @@ -1501,7 +1501,7 @@ mod tests { assert!(p1 == p2.join(join)); } ) - ); + } t!(s: "a\\b\\c", ".."); t!(s: "\\a\\b\\c", "d"); @@ -1525,7 +1525,7 @@ mod tests { #[test] fn test_push_path() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $push:expr, $exp:expr) => ( { let mut p = Path::new($path); @@ -1534,7 +1534,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"); @@ -1577,7 +1577,7 @@ mod tests { #[test] fn test_push_many() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $push:expr, $exp:expr) => ( { let mut p = Path::new($path); @@ -1592,7 +1592,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"); @@ -1606,7 +1606,7 @@ mod tests { #[test] fn test_pop() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $left:expr, $right:expr) => ( { let pstr = $path; @@ -1627,7 +1627,7 @@ mod tests { assert!(result == $right); } ) - ); + } t!(s: "a\\b\\c", "a\\b", true); t!(s: "a", ".", true); @@ -1695,7 +1695,7 @@ mod tests { #[test] fn test_join_path() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $join:expr, $exp:expr) => ( { let path = Path::new($path); @@ -1704,7 +1704,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"); @@ -1718,7 +1718,7 @@ mod tests { #[test] fn test_join_many() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $join:expr, $exp:expr) => ( { let path = Path::new($path); @@ -1733,7 +1733,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"); @@ -1746,7 +1746,7 @@ mod tests { #[test] fn test_with_helpers() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $op:ident, $arg:expr, $res:expr) => ( { let pstr = $path; @@ -1759,7 +1759,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"); @@ -1831,7 +1831,7 @@ mod tests { #[test] fn test_setters() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $set:ident, $with:ident, $arg:expr) => ( { let path = $path; @@ -1852,7 +1852,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"); @@ -1876,7 +1876,7 @@ mod tests { #[test] fn test_getters() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $filename:expr, $dirname:expr, $filestem:expr, $ext:expr) => ( { let path = $path; @@ -1907,7 +1907,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); @@ -1942,7 +1942,7 @@ mod tests { #[test] fn test_is_absolute() { - macro_rules! t( + macro_rules! t { ($path:expr, $abs:expr, $vol:expr, $cwd:expr, $rel:expr) => ( { let path = Path::new($path); @@ -1961,7 +1961,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); @@ -1982,7 +1982,7 @@ mod tests { #[test] fn test_is_ancestor_of() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $dest:expr, $exp:expr) => ( { let path = Path::new($path); @@ -1994,7 +1994,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); @@ -2085,7 +2085,7 @@ mod tests { #[test] fn test_ends_with_path() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $child:expr, $exp:expr) => ( { let path = Path::new($path); @@ -2093,7 +2093,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); @@ -2117,7 +2117,7 @@ mod tests { #[test] fn test_path_relative_from() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $other:expr, $exp:expr) => ( { let path = Path::new($path); @@ -2130,7 +2130,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")); @@ -2251,7 +2251,7 @@ mod tests { #[test] fn test_str_components() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $exp:expr) => ( { let path = Path::new($path); @@ -2265,7 +2265,7 @@ mod tests { assert_eq!(comps, exp); } ); - ); + } t!(s: b"a\\b\\c", ["a", "b", "c"]); t!(s: "a\\b\\c", ["a", "b", "c"]); @@ -2309,7 +2309,7 @@ mod tests { #[test] fn test_components_iter() { - macro_rules! t( + macro_rules! t { (s: $path:expr, $exp:expr) => ( { let path = Path::new($path); @@ -2321,7 +2321,7 @@ mod tests { assert_eq!(comps, exp); } ) - ); + } t!(s: "a\\b\\c", [b"a", b"b", b"c"]); t!(s: ".", [b"."]); @@ -2330,7 +2330,7 @@ mod tests { #[test] fn test_make_non_verbatim() { - macro_rules! t( + macro_rules! t { ($path:expr, $exp:expr) => ( { let path = Path::new($path); @@ -2339,7 +2339,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/libsyntax/ext/deriving/cmp/eq.rs b/src/libsyntax/ext/deriving/cmp/eq.rs index 7a67fab820de5..1b1bc6d281a2f 100644 --- a/src/libsyntax/ext/deriving/cmp/eq.rs +++ b/src/libsyntax/ext/deriving/cmp/eq.rs @@ -61,7 +61,7 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt, cx, span, substr) } - macro_rules! md ( + macro_rules! md { ($name:expr, $f:ident) => { { let inline = cx.meta_word(span, InternedString::new("inline")); let attrs = vec!(cx.attribute(span, inline)); @@ -77,7 +77,7 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt, }) } } } - ); + } let trait_def = TraitDef { span: span, diff --git a/src/libsyntax/ext/deriving/cmp/ord.rs b/src/libsyntax/ext/deriving/cmp/ord.rs index c02416bfbea3a..7353ddc172015 100644 --- a/src/libsyntax/ext/deriving/cmp/ord.rs +++ b/src/libsyntax/ext/deriving/cmp/ord.rs @@ -27,7 +27,7 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt, push: F) where F: FnOnce(P), { - macro_rules! md ( + macro_rules! md { ($name:expr, $op:expr, $equal:expr) => { { let inline = cx.meta_word(span, InternedString::new("inline")); let attrs = vec!(cx.attribute(span, inline)); @@ -43,7 +43,7 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt, }) } } } - ); + } let ordering_ty = Literal(Path::new(vec!["std", "cmp", "Ordering"])); let ret_ty = Literal(Path::new_(vec!["std", "option", "Option"], diff --git a/src/libsyntax/ext/deriving/mod.rs b/src/libsyntax/ext/deriving/mod.rs index 14b19fee3df5e..e72c83b67c89b 100644 --- a/src/libsyntax/ext/deriving/mod.rs +++ b/src/libsyntax/ext/deriving/mod.rs @@ -71,9 +71,11 @@ pub fn expand_meta_derive(cx: &mut ExtCtxt, MetaNameValue(ref tname, _) | MetaList(ref tname, _) | MetaWord(ref tname) => { - macro_rules! expand(($func:path) => ($func(cx, titem.span, - &**titem, item, - |i| push.call_mut((i,))))); + macro_rules! expand { + ($func:path) => ($func(cx, titem.span, &**titem, item, + |i| push.call_mut((i,)))) + } + match tname.get() { "Clone" => expand!(clone::expand_deriving_clone), diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index cf0d2c6474b2c..9837c8088fa45 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -38,8 +38,8 @@ impl<'a> ParserAnyMacro<'a> { /// Make sure we don't have any tokens left to parse, so we don't /// silently drop anything. `allow_semi` is so that "optional" /// semicolons at the end of normal expressions aren't complained - /// about e.g. the semicolon in `macro_rules! kapow( () => { - /// panic!(); } )` doesn't get picked up by .parse_expr(), but it's + /// about e.g. the semicolon in `macro_rules! kapow { () => { + /// panic!(); } }` doesn't get picked up by .parse_expr(), but it's /// allowed to be there. fn ensure_complete_parse(&self, allow_semi: bool) { let mut parser = self.parser.borrow_mut(); diff --git a/src/libterm/terminfo/parser/compiled.rs b/src/libterm/terminfo/parser/compiled.rs index fe96d7b8b7d01..5f0111c7d7a84 100644 --- a/src/libterm/terminfo/parser/compiled.rs +++ b/src/libterm/terminfo/parser/compiled.rs @@ -160,12 +160,12 @@ pub static stringnames: &'static[&'static str] = &[ "cbt", "_", "cr", "csr", "tb /// Parse a compiled terminfo entry, using long capability names if `longnames` is true pub fn parse(file: &mut io::Reader, longnames: bool) -> Result, String> { - macro_rules! try( ($e:expr) => ( + macro_rules! try { ($e:expr) => ( match $e { Ok(e) => e, Err(e) => return Err(format!("{}", e)) } - ) ); + ) } let bnames; let snames; diff --git a/src/test/auxiliary/lint_stability.rs b/src/test/auxiliary/lint_stability.rs index 5ef1acae6c7ed..5eb6b0de3de94 100644 --- a/src/test/auxiliary/lint_stability.rs +++ b/src/test/auxiliary/lint_stability.rs @@ -180,16 +180,16 @@ pub struct FrozenTupleStruct(pub int); pub struct LockedTupleStruct(pub int); #[macro_export] -macro_rules! macro_test( +macro_rules! macro_test { () => (deprecated()); -); +} #[macro_export] -macro_rules! macro_test_arg( +macro_rules! macro_test_arg { ($func:expr) => ($func); -); +} #[macro_export] -macro_rules! macro_test_arg_nested( +macro_rules! macro_test_arg_nested { ($func:ident) => (macro_test_arg!($func())); -); +} diff --git a/src/test/auxiliary/macro_crate_def_only.rs b/src/test/auxiliary/macro_crate_def_only.rs index ad3e72f5fa221..c323eb0c44624 100644 --- a/src/test/auxiliary/macro_crate_def_only.rs +++ b/src/test/auxiliary/macro_crate_def_only.rs @@ -11,6 +11,6 @@ #![feature(macro_rules)] #[macro_export] -macro_rules! make_a_5( +macro_rules! make_a_5 { () => (5) -); +} diff --git a/src/test/auxiliary/macro_crate_test.rs b/src/test/auxiliary/macro_crate_test.rs index b82cfcbc8fcb2..418a7c6e538ed 100644 --- a/src/test/auxiliary/macro_crate_test.rs +++ b/src/test/auxiliary/macro_crate_test.rs @@ -24,9 +24,9 @@ use syntax::ptr::P; use rustc::plugin::Registry; #[macro_export] -macro_rules! exported_macro (() => (2i)); +macro_rules! exported_macro { () => (2i) } -macro_rules! unexported_macro (() => (3i)); +macro_rules! unexported_macro { () => (3i) } #[plugin_registrar] pub fn plugin_registrar(reg: &mut Registry) { diff --git a/src/test/auxiliary/macro_export_inner_module.rs b/src/test/auxiliary/macro_export_inner_module.rs index 9b4b1ceb5c1e7..fb98637811d72 100644 --- a/src/test/auxiliary/macro_export_inner_module.rs +++ b/src/test/auxiliary/macro_export_inner_module.rs @@ -12,7 +12,7 @@ pub mod inner { #[macro_export] - macro_rules! foo( + macro_rules! foo { () => (1) - ); + } } diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs index ee7c442da195c..21e55384f46bf 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -28,11 +28,12 @@ fn main() { let argv = os::args(); let _tests = argv.slice(1, argv.len()); - macro_rules! bench ( + macro_rules! bench { ($id:ident) => (maybe_run_test(argv.as_slice(), stringify!($id).to_string(), - $id))); + $id)) + } bench!(shift_push); bench!(read_line); diff --git a/src/test/compile-fail/gated-macro-rules.rs b/src/test/compile-fail/gated-macro-rules.rs index ae2f03fd5f798..dea0c60d91b7f 100644 --- a/src/test/compile-fail/gated-macro-rules.rs +++ b/src/test/compile-fail/gated-macro-rules.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -macro_rules! foo(() => ()); +macro_rules! foo { () => () } //~^ ERROR: macro definitions are not stable enough for use fn main() {} diff --git a/src/test/compile-fail/infinite-macro-expansion.rs b/src/test/compile-fail/infinite-macro-expansion.rs index 22ac2eb1f7d5d..22011f192356b 100644 --- a/src/test/compile-fail/infinite-macro-expansion.rs +++ b/src/test/compile-fail/infinite-macro-expansion.rs @@ -10,11 +10,9 @@ #![feature(macro_rules)] -macro_rules! recursive( - () => ( - recursive!() //~ ERROR recursion limit reached while expanding the macro `recursive` - ) - ); +macro_rules! recursive { + () => (recursive!()) //~ ERROR recursion limit reached while expanding the macro `recursive` +} fn main() { recursive!() diff --git a/src/test/compile-fail/issue-15167.rs b/src/test/compile-fail/issue-15167.rs index 300831b100773..cb10791973340 100644 --- a/src/test/compile-fail/issue-15167.rs +++ b/src/test/compile-fail/issue-15167.rs @@ -17,7 +17,7 @@ #![feature(macro_rules)] -macro_rules! f(() => (n)) +macro_rules! f { () => (n) } fn main() -> (){ for n in range(0i, 1) { diff --git a/src/test/compile-fail/issue-6596.rs b/src/test/compile-fail/issue-6596.rs index 3222b2cd53719..b237b4259184f 100644 --- a/src/test/compile-fail/issue-6596.rs +++ b/src/test/compile-fail/issue-6596.rs @@ -12,11 +12,11 @@ // error-pattern: unexpected token -macro_rules! e( +macro_rules! e { ($inp:ident) => ( $nonexistent ); -); +} fn main() { e!(foo); diff --git a/src/test/compile-fail/liveness-return-last-stmt-semi.rs b/src/test/compile-fail/liveness-return-last-stmt-semi.rs index e92faa6bdaf6e..cdcb0859ed950 100644 --- a/src/test/compile-fail/liveness-return-last-stmt-semi.rs +++ b/src/test/compile-fail/liveness-return-last-stmt-semi.rs @@ -12,7 +12,7 @@ #![feature(macro_rules)] -macro_rules! test ( () => { fn foo() -> int { 1i; } } ); +macro_rules! test { () => { fn foo() -> int { 1i; } } } //~^ ERROR not all control paths return a value //~^^ HELP consider removing this semicolon diff --git a/src/test/compile-fail/macro-inner-attributes.rs b/src/test/compile-fail/macro-inner-attributes.rs index f64b7be50e307..8d2f49ecc7f53 100644 --- a/src/test/compile-fail/macro-inner-attributes.rs +++ b/src/test/compile-fail/macro-inner-attributes.rs @@ -10,9 +10,9 @@ #![feature(macro_rules)] -macro_rules! test ( ($nm:ident, +macro_rules! test { ($nm:ident, #[$a:meta], - $i:item) => (mod $nm { #![$a] $i }); ); + $i:item) => (mod $nm { #![$a] $i }); } test!(a, #[cfg(qux)], diff --git a/src/test/compile-fail/macro-match-nonterminal.rs b/src/test/compile-fail/macro-match-nonterminal.rs index 150187aa07d3c..8bfaac1770d96 100644 --- a/src/test/compile-fail/macro-match-nonterminal.rs +++ b/src/test/compile-fail/macro-match-nonterminal.rs @@ -10,7 +10,7 @@ #![feature(macro_rules)] -macro_rules! test ( ($a, $b) => (()); ); //~ ERROR Cannot transcribe +macro_rules! test { ($a, $b) => (()); } //~ ERROR Cannot transcribe fn main() { test!() diff --git a/src/test/compile-fail/macro-outer-attributes.rs b/src/test/compile-fail/macro-outer-attributes.rs index 6d59c203d14bd..4f2c097eca94f 100644 --- a/src/test/compile-fail/macro-outer-attributes.rs +++ b/src/test/compile-fail/macro-outer-attributes.rs @@ -10,9 +10,9 @@ #![feature(macro_rules)] -macro_rules! test ( ($nm:ident, +macro_rules! test { ($nm:ident, #[$a:meta], - $i:item) => (mod $nm { #[$a] $i }); ); + $i:item) => (mod $nm { #[$a] $i }); } test!(a, #[cfg(qux)], diff --git a/src/test/compile-fail/macros-no-semicolon-items.rs b/src/test/compile-fail/macros-no-semicolon-items.rs index f1f31a99e970a..314292085dfe6 100644 --- a/src/test/compile-fail/macros-no-semicolon-items.rs +++ b/src/test/compile-fail/macros-no-semicolon-items.rs @@ -12,4 +12,3 @@ macro_rules! foo() //~ ERROR semicolon fn main() { } - diff --git a/src/test/compile-fail/method-macro-backtrace.rs b/src/test/compile-fail/method-macro-backtrace.rs index 747b4815ac2ae..56087c79799f6 100644 --- a/src/test/compile-fail/method-macro-backtrace.rs +++ b/src/test/compile-fail/method-macro-backtrace.rs @@ -12,9 +12,9 @@ #![feature(macro_rules)] -macro_rules! make_method ( ($name:ident) => ( - fn $name(&self) { } -)); +macro_rules! make_method { + ($name:ident) => ( fn $name(&self) { } ) +} struct S; diff --git a/src/test/compile-fail/pattern-macro-hygiene.rs b/src/test/compile-fail/pattern-macro-hygiene.rs index 3322fecf950c1..64f810c1c95e7 100644 --- a/src/test/compile-fail/pattern-macro-hygiene.rs +++ b/src/test/compile-fail/pattern-macro-hygiene.rs @@ -10,7 +10,7 @@ #![feature(macro_rules)] -macro_rules! foo ( () => ( x ) ); +macro_rules! foo { () => ( x ) } fn main() { let foo!() = 2; diff --git a/src/test/run-pass/borrowck-macro-interaction-issue-6304.rs b/src/test/run-pass/borrowck-macro-interaction-issue-6304.rs index 822db63971e21..bd42cc94a3393 100644 --- a/src/test/run-pass/borrowck-macro-interaction-issue-6304.rs +++ b/src/test/run-pass/borrowck-macro-interaction-issue-6304.rs @@ -24,12 +24,12 @@ pub enum Bar { impl Foo { fn elaborate_stm(&mut self, s: Box) -> Box { - macro_rules! declare( + macro_rules! declare { ($id:expr, $rest:expr) => ({ self.check_id($id); box Bar::Bar2($id, $rest) }) - ); + } match s { box Bar::Bar2(id, rest) => declare!(id, self.elaborate_stm(rest)), _ => panic!() diff --git a/src/test/run-pass/cleanup-rvalue-scopes.rs b/src/test/run-pass/cleanup-rvalue-scopes.rs index 42f6914e081a3..fe74956fd1e40 100644 --- a/src/test/run-pass/cleanup-rvalue-scopes.rs +++ b/src/test/run-pass/cleanup-rvalue-scopes.rs @@ -61,7 +61,7 @@ impl Drop for AddFlags { } } -macro_rules! end_of_block( +macro_rules! end_of_block { ($pat:pat, $expr:expr) => ( { println!("end_of_block({})", stringify!({let $pat = $expr;})); @@ -74,9 +74,9 @@ macro_rules! end_of_block( check_flags(1); } ) -); +} -macro_rules! end_of_stmt( +macro_rules! end_of_stmt { ($pat:pat, $expr:expr) => ( { println!("end_of_stmt({})", stringify!($expr)); @@ -91,7 +91,7 @@ macro_rules! end_of_stmt( check_flags(0); } ) -); +} pub fn main() { diff --git a/src/test/run-pass/const-binops.rs b/src/test/run-pass/const-binops.rs index cac805189b82e..51647aebcf85d 100644 --- a/src/test/run-pass/const-binops.rs +++ b/src/test/run-pass/const-binops.rs @@ -10,14 +10,14 @@ #![feature(macro_rules)] -macro_rules! assert_approx_eq( +macro_rules! assert_approx_eq { ($a:expr, $b:expr) => ({ use std::num::Float; let (a, b) = (&$a, &$b); assert!((*a - *b).abs() < 1.0e-6, "{} is not approximately equal to {}", *a, *b); }) -); +} static A: int = -4 + 3; static A2: uint = 3 + 3; diff --git a/src/test/run-pass/core-run-destroy.rs b/src/test/run-pass/core-run-destroy.rs index c1db8a6eb13f4..33564af2d7d20 100644 --- a/src/test/run-pass/core-run-destroy.rs +++ b/src/test/run-pass/core-run-destroy.rs @@ -26,9 +26,9 @@ use std::str; use std::sync::mpsc::channel; use std::thread::Thread; -macro_rules! succeed( ($e:expr) => ( +macro_rules! succeed { ($e:expr) => ( match $e { Ok(..) => {}, Err(e) => panic!("panic: {}", e) } -) ); +) } fn test_destroy_once() { let mut p = sleeper(); diff --git a/src/test/run-pass/deriving-in-macro.rs b/src/test/run-pass/deriving-in-macro.rs index 97f6ee341a71f..162de18f581ab 100644 --- a/src/test/run-pass/deriving-in-macro.rs +++ b/src/test/run-pass/deriving-in-macro.rs @@ -10,14 +10,14 @@ #![feature(macro_rules)] -macro_rules! define_vec ( +macro_rules! define_vec { () => ( mod foo { #[derive(PartialEq)] pub struct bar; } ) -); +} define_vec!(); diff --git a/src/test/run-pass/exponential-notation.rs b/src/test/run-pass/exponential-notation.rs index 38d1093762432..6addbf693548f 100644 --- a/src/test/run-pass/exponential-notation.rs +++ b/src/test/run-pass/exponential-notation.rs @@ -15,7 +15,9 @@ use std::num::strconv::SignificantDigits::DigMax; use std::num::strconv::SignFormat::{SignAll, SignNeg}; use std::num::strconv::float_to_str_common as to_string; -macro_rules! t(($a:expr, $b:expr) => { { let (r, _) = $a; assert_eq!(r, $b.to_string()); } }); +macro_rules! t { + ($a:expr, $b:expr) => { { let (r, _) = $a; assert_eq!(r, $b.to_string()); } } +} pub fn main() { // Basic usage diff --git a/src/test/run-pass/html-literals.rs b/src/test/run-pass/html-literals.rs index 0d56f28e8fae7..6f6a429db172e 100644 --- a/src/test/run-pass/html-literals.rs +++ b/src/test/run-pass/html-literals.rs @@ -27,13 +27,13 @@ left. */ use HTMLFragment::{tag, text}; -macro_rules! html ( +macro_rules! html { ( $($body:tt)* ) => ( parse_node!( []; []; $($body)* ) ) -); +} -macro_rules! parse_node ( +macro_rules! parse_node { ( [:$head:ident ($(:$head_nodes:expr),*) $(:$tags:ident ($(:$tag_nodes:expr),*))*]; @@ -85,7 +85,7 @@ macro_rules! parse_node ( ); ( []; [:$e:expr]; ) => ( $e ); -); +} pub fn main() { let _page = html! ( diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index 1efae89f66563..6f050e7db05f4 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -37,7 +37,9 @@ impl fmt::Show for C { } } -macro_rules! t(($a:expr, $b:expr) => { assert_eq!($a.as_slice(), $b) }); +macro_rules! t { + ($a:expr, $b:expr) => { assert_eq!($a.as_slice(), $b) } +} pub fn main() { // Various edge cases without formats diff --git a/src/test/run-pass/intrinsics-math.rs b/src/test/run-pass/intrinsics-math.rs index 9f2fe155cdf95..4c86cb0049af6 100644 --- a/src/test/run-pass/intrinsics-math.rs +++ b/src/test/run-pass/intrinsics-math.rs @@ -11,14 +11,14 @@ #![feature(globs, macro_rules, intrinsics)] -macro_rules! assert_approx_eq( +macro_rules! assert_approx_eq { ($a:expr, $b:expr) => ({ use std::num::Float; let (a, b) = (&$a, &$b); assert!((*a - *b).abs() < 1.0e-6, "{} is not approximately equal to {}", *a, *b); }) -); +} mod rusti { extern "rust-intrinsic" { diff --git a/src/test/run-pass/issue-15189.rs b/src/test/run-pass/issue-15189.rs index 01c96b7563a75..60083c254805d 100644 --- a/src/test/run-pass/issue-15189.rs +++ b/src/test/run-pass/issue-15189.rs @@ -12,7 +12,9 @@ #![feature(macro_rules)] -macro_rules! third(($e:expr)=>({let x = 2; $e[x]})); +macro_rules! third { + ($e:expr) => ({let x = 2; $e[x]}) +} fn main() { let x = vec!(10u,11u,12u,13u); diff --git a/src/test/run-pass/issue-15221.rs b/src/test/run-pass/issue-15221.rs index a11b34e476275..f778af7ebcf51 100644 --- a/src/test/run-pass/issue-15221.rs +++ b/src/test/run-pass/issue-15221.rs @@ -10,11 +10,13 @@ #![feature(macro_rules)] -macro_rules! inner ( - ($e:pat ) => ($e)); +macro_rules! inner { + ($e:pat ) => ($e) +} -macro_rules! outer ( - ($e:pat ) => (inner!($e))); +macro_rules! outer { + ($e:pat ) => (inner!($e)) +} fn main() { let outer!(g1) = 13i; diff --git a/src/test/run-pass/issue-5060.rs b/src/test/run-pass/issue-5060.rs index 0cd25bc2c719b..18ebe35dcdf7d 100644 --- a/src/test/run-pass/issue-5060.rs +++ b/src/test/run-pass/issue-5060.rs @@ -10,7 +10,7 @@ #![feature(macro_rules)] -macro_rules! print_hd_tl ( +macro_rules! print_hd_tl { ($field_hd:ident, $($field_tl:ident),+) => ({ print!("{}", stringify!($field_hd)); print!("::["); @@ -21,7 +21,7 @@ macro_rules! print_hd_tl ( // FIXME: #9970 print!("{}", "]\n"); }) -); +} pub fn main() { print_hd_tl!(x, y, z, w) diff --git a/src/test/run-pass/issue-7911.rs b/src/test/run-pass/issue-7911.rs index c69b66f4dbd76..8cc507d88558a 100644 --- a/src/test/run-pass/issue-7911.rs +++ b/src/test/run-pass/issue-7911.rs @@ -27,7 +27,7 @@ trait Test { fn get_mut(&mut self) -> &mut FooBar; } -macro_rules! generate_test(($type_:path, $slf:ident, $field:expr) => ( +macro_rules! generate_test { ($type_:path, $slf:ident, $field:expr) => ( impl Test for $type_ { fn get_immut(&$slf) -> &FooBar { &$field as &FooBar @@ -37,7 +37,7 @@ macro_rules! generate_test(($type_:path, $slf:ident, $field:expr) => ( &mut $field as &mut FooBar } } -)); +)} generate_test!(Foo, self, self.bar); diff --git a/src/test/run-pass/issue-8709.rs b/src/test/run-pass/issue-8709.rs index d4ea05004a064..4e7d42f6b0bd7 100644 --- a/src/test/run-pass/issue-8709.rs +++ b/src/test/run-pass/issue-8709.rs @@ -10,13 +10,13 @@ #![feature(macro_rules)] -macro_rules! sty( +macro_rules! sty { ($t:ty) => (stringify!($t)) -); +} -macro_rules! spath( +macro_rules! spath { ($t:path) => (stringify!($t)) -); +} fn main() { assert_eq!(sty!(int), "int"); diff --git a/src/test/run-pass/issue-8851.rs b/src/test/run-pass/issue-8851.rs index 5826a5f9919f4..765e696cd55fd 100644 --- a/src/test/run-pass/issue-8851.rs +++ b/src/test/run-pass/issue-8851.rs @@ -20,7 +20,7 @@ enum T { B(uint) } -macro_rules! test( +macro_rules! test { ($id:ident, $e:expr) => ( fn foo(t: T) -> int { match t { @@ -29,7 +29,7 @@ macro_rules! test( } } ) -); +} test!(y, 10 + (y as int)); diff --git a/src/test/run-pass/issue-9110.rs b/src/test/run-pass/issue-9110.rs index 60011281d425e..26390d8da7d57 100644 --- a/src/test/run-pass/issue-9110.rs +++ b/src/test/run-pass/issue-9110.rs @@ -10,14 +10,14 @@ #![feature(macro_rules)] -macro_rules! silly_macro( +macro_rules! silly_macro { () => ( pub mod Qux { pub struct Foo { x : u8 } pub fn bar(_foo : Foo) {} } ); -); +} silly_macro!(); diff --git a/src/test/run-pass/issue-9129.rs b/src/test/run-pass/issue-9129.rs index a6746f452065d..2ac1a42a24629 100644 --- a/src/test/run-pass/issue-9129.rs +++ b/src/test/run-pass/issue-9129.rs @@ -19,8 +19,8 @@ impl bomb for S { fn boom(&self, _: Ident) { } } pub struct Ident { name: uint } -// macro_rules! int3( () => ( unsafe { asm!( "int3" ); } ) ) -macro_rules! int3( () => ( { } ) ); +// macro_rules! int3 { () => ( unsafe { asm!( "int3" ); } ) } +macro_rules! int3 { () => ( { } ) } fn Ident_new() -> Ident { int3!(); diff --git a/src/test/run-pass/issue-9737.rs b/src/test/run-pass/issue-9737.rs index 1f385b2fb1589..2bd251ca58750 100644 --- a/src/test/run-pass/issue-9737.rs +++ b/src/test/run-pass/issue-9737.rs @@ -12,7 +12,9 @@ #![feature(macro_rules)] -macro_rules! f((v: $x:expr) => ( println!("{}", $x) )) +macro_rules! f { + (v: $x:expr) => ( println!("{}", $x) ) +} fn main () { let v = 5; diff --git a/src/test/run-pass/lambda-var-hygiene.rs b/src/test/run-pass/lambda-var-hygiene.rs index 5dfc4208554b1..ebd3e3c6641ea 100644 --- a/src/test/run-pass/lambda-var-hygiene.rs +++ b/src/test/run-pass/lambda-var-hygiene.rs @@ -13,7 +13,9 @@ #![feature(macro_rules)] // shouldn't affect evaluation of $ex: -macro_rules! bad_macro (($ex:expr) => ({(|_x| { $ex }) (9) })) +macro_rules! bad_macro { + ($ex:expr) => ({(|_x| { $ex }) (9) }) +} fn takes_x(_x : int) { assert_eq!(bad_macro!(_x),8); diff --git a/src/test/run-pass/let-var-hygiene.rs b/src/test/run-pass/let-var-hygiene.rs index 5eed791e0582d..e0388407571f9 100644 --- a/src/test/run-pass/let-var-hygiene.rs +++ b/src/test/run-pass/let-var-hygiene.rs @@ -11,7 +11,10 @@ #![feature(macro_rules)] // shouldn't affect evaluation of $ex: -macro_rules! bad_macro (($ex:expr) => ({let _x = 9i; $ex})); +macro_rules! bad_macro { + ($ex:expr) => ({let _x = 9i; $ex}) +} + pub fn main() { let _x = 8i; assert_eq!(bad_macro!(_x),8i) diff --git a/src/test/run-pass/macro-2.rs b/src/test/run-pass/macro-2.rs index 7b4d376993aa9..07667de4716f5 100644 --- a/src/test/run-pass/macro-2.rs +++ b/src/test/run-pass/macro-2.rs @@ -14,12 +14,12 @@ pub fn main() { - macro_rules! mylambda_tt( + macro_rules! mylambda_tt { ($x:ident, $body:expr) => ({ fn f($x: int) -> int { return $body; }; f }) - ); + } assert!(mylambda_tt!(y, y * 2)(8) == 16); } diff --git a/src/test/run-pass/macro-interpolation.rs b/src/test/run-pass/macro-interpolation.rs index 45712f5c62a6e..e531eb9dbc445 100644 --- a/src/test/run-pass/macro-interpolation.rs +++ b/src/test/run-pass/macro-interpolation.rs @@ -10,7 +10,7 @@ #![feature(macro_rules)] -macro_rules! overly_complicated ( +macro_rules! overly_complicated { ($fnname:ident, $arg:ident, $ty:ty, $body:block, $val:expr, $pat:pat, $res:path) => ({ fn $fnname($arg: $ty) -> Option<$ty> $body @@ -22,7 +22,7 @@ macro_rules! overly_complicated ( } }) -); +} pub fn main() { assert!(overly_complicated!(f, x, Option, { return Some(x); }, diff --git a/src/test/run-pass/macro-invocation-in-count-expr-fixed-array-type.rs b/src/test/run-pass/macro-invocation-in-count-expr-fixed-array-type.rs index ecd7c0458f701..5103c50f5cf57 100644 --- a/src/test/run-pass/macro-invocation-in-count-expr-fixed-array-type.rs +++ b/src/test/run-pass/macro-invocation-in-count-expr-fixed-array-type.rs @@ -10,9 +10,9 @@ #![feature(macro_rules)] -macro_rules! four ( +macro_rules! four { () => (4) -); +} fn main() { let _x: [u16; four!()]; diff --git a/src/test/run-pass/macro-multiple-items.rs b/src/test/run-pass/macro-multiple-items.rs index 4fb130f0e1314..40f41447aa85a 100644 --- a/src/test/run-pass/macro-multiple-items.rs +++ b/src/test/run-pass/macro-multiple-items.rs @@ -12,7 +12,7 @@ #![feature(macro_rules)] -macro_rules! make_foo( +macro_rules! make_foo { () => ( struct Foo; @@ -20,7 +20,7 @@ macro_rules! make_foo( fn bar(&self) {} } ) -); +} make_foo!(); diff --git a/src/test/run-pass/macro-nt-list.rs b/src/test/run-pass/macro-nt-list.rs index 9367a231d4f65..91f0a3b607c3e 100644 --- a/src/test/run-pass/macro-nt-list.rs +++ b/src/test/run-pass/macro-nt-list.rs @@ -10,15 +10,15 @@ #![feature(macro_rules)] -macro_rules! list ( +macro_rules! list { ( ($($id:ident),*) ) => (()); ( [$($id:ident),*] ) => (()); ( {$($id:ident),*} ) => (()); -); +} -macro_rules! tt_list ( +macro_rules! tt_list { ( ($($tt:tt),*) ) => (()); -); +} pub fn main() { list!( () ); diff --git a/src/test/run-pass/macro-of-higher-order.rs b/src/test/run-pass/macro-of-higher-order.rs index c47b5e1108901..a7c0ca56d60c8 100644 --- a/src/test/run-pass/macro-of-higher-order.rs +++ b/src/test/run-pass/macro-of-higher-order.rs @@ -10,12 +10,12 @@ #![feature(macro_rules)] -macro_rules! higher_order ( +macro_rules! higher_order { (subst $lhs:tt => $rhs:tt) => ({ - macro_rules! anon ( $lhs => $rhs ); + macro_rules! anon { $lhs => $rhs } anon!(1u, 2u, "foo") }); -); +} fn main() { let val = higher_order!(subst ($x:expr, $y:expr, $foo:expr) => (($x + $y, $foo))); diff --git a/src/test/run-pass/macro-pat.rs b/src/test/run-pass/macro-pat.rs index 496cef9d644e2..d3e3292307586 100644 --- a/src/test/run-pass/macro-pat.rs +++ b/src/test/run-pass/macro-pat.rs @@ -10,35 +10,35 @@ #![feature(macro_rules)] -macro_rules! mypat( +macro_rules! mypat { () => ( Some('y') ) -); +} -macro_rules! char_x( +macro_rules! char_x { () => ( 'x' ) -); +} -macro_rules! some( +macro_rules! some { ($x:pat) => ( Some($x) ) -); +} -macro_rules! indirect( +macro_rules! indirect { () => ( some!(char_x!()) ) -); +} -macro_rules! ident_pat( +macro_rules! ident_pat { ($x:ident) => ( $x ) -); +} fn f(c: Option) -> uint { match c { diff --git a/src/test/run-pass/macro-stmt.rs b/src/test/run-pass/macro-stmt.rs index 7be49e1acd844..77d6b59f8bf44 100644 --- a/src/test/run-pass/macro-stmt.rs +++ b/src/test/run-pass/macro-stmt.rs @@ -12,21 +12,21 @@ #![feature(macro_rules)] -macro_rules! myfn( +macro_rules! myfn { ( $f:ident, ( $( $x:ident ),* ), $body:block ) => ( fn $f( $( $x : int),* ) -> int $body ) -); +} myfn!(add, (a,b), { return a+b; } ); pub fn main() { - macro_rules! mylet( + macro_rules! mylet { ($x:ident, $val:expr) => ( let $x = $val; ) - ); + } mylet!(y, 8i*2); assert_eq!(y, 16i); @@ -35,9 +35,9 @@ pub fn main() { assert_eq!(mult(2, add(4,4)), 16); - macro_rules! actually_an_expr_macro ( + macro_rules! actually_an_expr_macro { () => ( 16i ) - ); + } assert_eq!({ actually_an_expr_macro!() }, 16i); diff --git a/src/test/run-pass/macro-with-attrs1.rs b/src/test/run-pass/macro-with-attrs1.rs index 631fc8666713d..23a3a0374973d 100644 --- a/src/test/run-pass/macro-with-attrs1.rs +++ b/src/test/run-pass/macro-with-attrs1.rs @@ -13,10 +13,10 @@ #![feature(macro_rules)] #[cfg(foo)] -macro_rules! foo( () => (1i) ); +macro_rules! foo { () => (1i) } #[cfg(not(foo))] -macro_rules! foo( () => (2i) ); +macro_rules! foo { () => (2i) } pub fn main() { assert_eq!(foo!(), 1i); diff --git a/src/test/run-pass/macro-with-attrs2.rs b/src/test/run-pass/macro-with-attrs2.rs index 3ac0d47e61a63..038931551a88c 100644 --- a/src/test/run-pass/macro-with-attrs2.rs +++ b/src/test/run-pass/macro-with-attrs2.rs @@ -11,10 +11,10 @@ #![feature(macro_rules)] #[cfg(foo)] -macro_rules! foo( () => (1i) ); +macro_rules! foo { () => (1i) } #[cfg(not(foo))] -macro_rules! foo( () => (2i) ); +macro_rules! foo { () => (2i) } pub fn main() { assert_eq!(foo!(), 2i); diff --git a/src/test/run-pass/macro-with-braces-in-expr-position.rs b/src/test/run-pass/macro-with-braces-in-expr-position.rs index a6e579ddff304..b4170c27ec288 100644 --- a/src/test/run-pass/macro-with-braces-in-expr-position.rs +++ b/src/test/run-pass/macro-with-braces-in-expr-position.rs @@ -12,7 +12,7 @@ use std::thread::Thread; -macro_rules! expr (($e: expr) => { $e }); +macro_rules! expr { ($e: expr) => { $e } } macro_rules! spawn { ($($code: tt)*) => { diff --git a/src/test/run-pass/match-in-macro.rs b/src/test/run-pass/match-in-macro.rs index a776999ec8a00..7dde322ead620 100644 --- a/src/test/run-pass/match-in-macro.rs +++ b/src/test/run-pass/match-in-macro.rs @@ -14,13 +14,13 @@ enum Foo { B { b1: int, bb1: int}, } -macro_rules! match_inside_expansion( +macro_rules! match_inside_expansion { () => ( match (Foo::B { b1:29 , bb1: 100}) { Foo::B { b1:b2 , bb1:bb2 } => b2+bb2 } ) -); +} pub fn main() { assert_eq!(match_inside_expansion!(),129); diff --git a/src/test/run-pass/match-var-hygiene.rs b/src/test/run-pass/match-var-hygiene.rs index 482fdf5b1d040..da15f911e8b52 100644 --- a/src/test/run-pass/match-var-hygiene.rs +++ b/src/test/run-pass/match-var-hygiene.rs @@ -13,9 +13,9 @@ #![feature(macro_rules)] // shouldn't affect evaluation of $ex. -macro_rules! bad_macro (($ex:expr) => ( +macro_rules! bad_macro { ($ex:expr) => ( {match 9 {_x => $ex}} -)) +)} fn main() { match 8 { diff --git a/src/test/run-pass/non-built-in-quote.rs b/src/test/run-pass/non-built-in-quote.rs index 9151564b3407b..e4a3ac8cd9101 100644 --- a/src/test/run-pass/non-built-in-quote.rs +++ b/src/test/run-pass/non-built-in-quote.rs @@ -10,7 +10,7 @@ #![feature(macro_rules)] -macro_rules! quote_tokens ( () => (()) ); +macro_rules! quote_tokens { () => (()) } pub fn main() { quote_tokens!(); diff --git a/src/test/run-pass/syntax-extension-source-utils.rs b/src/test/run-pass/syntax-extension-source-utils.rs index f6708536a9d99..939d20ddc27fd 100644 --- a/src/test/run-pass/syntax-extension-source-utils.rs +++ b/src/test/run-pass/syntax-extension-source-utils.rs @@ -21,7 +21,7 @@ pub mod m1 { } } -macro_rules! indirect_line( () => ( line!() ) ); +macro_rules! indirect_line { () => ( line!() ) } pub fn main() { assert_eq!(line!(), 27); diff --git a/src/test/run-pass/typeck-macro-interaction-issue-8852.rs b/src/test/run-pass/typeck-macro-interaction-issue-8852.rs index 4dec227d52020..ce6122aad00e0 100644 --- a/src/test/run-pass/typeck-macro-interaction-issue-8852.rs +++ b/src/test/run-pass/typeck-macro-interaction-issue-8852.rs @@ -20,7 +20,7 @@ enum T { // doesn't cause capture. Making this macro hygienic (as I've done) // could very well make this test case completely pointless.... -macro_rules! test( +macro_rules! test { ($id1:ident, $id2:ident, $e:expr) => ( fn foo(a:T, b:T) -> T { match (a, b) { @@ -30,7 +30,7 @@ macro_rules! test( } } ) -); +} test!(x,y,x + y);