Skip to content

Commit

Permalink
Eliminate some extraneous curly brackets inside invocations of `macro…
Browse files Browse the repository at this point in the history
…_rules!`.
  • Loading branch information
paulstansifer committed Aug 23, 2012
1 parent 38891b9 commit c74a442
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/libcore/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn from_value<A>(+val: A) -> Future<A> {
}

macro_rules! move_it (
{$x:expr} => { unsafe { let y <- *ptr::addr_of($x); y } }
($x:expr) => { unsafe { let y <- *ptr::addr_of($x); y } }
)

fn from_port<A:send>(+port: future_pipe::client::waiting<A>) -> Future<A> {
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ fn kill_taskgroup(state: TaskGroupInner, me: *rust_task, is_main: bool) {
// a proper closure because the #[test]s won't understand. Have to fake it.
macro_rules! taskgroup_key (
// Use a "code pointer" value that will never be a real code pointer.
{} => (unsafe::transmute((-2 as uint, 0u)))
() => (unsafe::transmute((-2 as uint, 0u)))
)

fn gen_child_taskgroup(linked: bool, supervised: bool)
Expand Down
12 changes: 6 additions & 6 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ enum view_item_parse_mode {
The important thing is to make sure that lookahead doesn't balk
at INTERPOLATED tokens */
macro_rules! maybe_whole_expr (
{$p:expr} => { match copy $p.token {
($p:expr) => { match copy $p.token {
INTERPOLATED(token::nt_expr(e)) => {
$p.bump();
return pexpr(e);
Expand All @@ -142,26 +142,26 @@ macro_rules! maybe_whole_expr (
)

macro_rules! maybe_whole (
{$p:expr, $constructor:ident} => { match copy $p.token {
($p:expr, $constructor:ident) => { match copy $p.token {
INTERPOLATED(token::$constructor(x)) => { $p.bump(); return x; }
_ => ()
}} ;
{deref $p:expr, $constructor:ident} => { match copy $p.token {
(deref $p:expr, $constructor:ident) => { match copy $p.token {
INTERPOLATED(token::$constructor(x)) => { $p.bump(); return *x; }
_ => ()
}} ;
{some $p:expr, $constructor:ident} => { match copy $p.token {
(some $p:expr, $constructor:ident) => { match copy $p.token {
INTERPOLATED(token::$constructor(x)) => { $p.bump(); return some(x); }
_ => ()
}} ;
{iovi $p:expr, $constructor:ident} => { match copy $p.token {
(iovi $p:expr, $constructor:ident) => { match copy $p.token {
INTERPOLATED(token::$constructor(x)) => {
$p.bump();
return iovi_item(x);
}
_ => ()
}} ;
{pair_empty $p:expr, $constructor:ident} => { match copy $p.token {
(pair_empty $p:expr, $constructor:ident) => { match copy $p.token {
INTERPOLATED(token::$constructor(x)) => { $p.bump(); return (~[], x); }
_ => ()
}}
Expand Down
20 changes: 10 additions & 10 deletions src/test/run-pass/html-literals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,62 +16,62 @@ left.
*/

macro_rules! html (
{ $($body:tt)* } => (
( $($body:tt)* ) => (
parse_node!( []; []; $($body)* )
)
)

macro_rules! parse_node (
{
(
[:$head:ident ($(:$head_nodes:expr),*)
$(:$tags:ident ($(:$tag_nodes:expr),*))*];
[$(:$nodes:expr),*];
</$tag:ident> $($rest:tt)*
} => (
) => (
parse_node!(
[$(: $tags ($(:$tag_nodes),*))*];
[$(:$head_nodes,)* :tag(stringify!($head), ~[$($nodes),*])];
$($rest)*
)
);

{
(
[$(:$tags:ident ($(:$tag_nodes:expr),*) )*];
[$(:$nodes:expr),*];
<$tag:ident> $($rest:tt)*
} => (
) => (
parse_node!(
[:$tag ($(:$nodes)*) $(: $tags ($(:$tag_nodes),*) )*];
[];
$($rest)*
)
);

{
(
[$(:$tags:ident ($(:$tag_nodes:expr),*) )*];
[$(:$nodes:expr),*];
. $($rest:tt)*
} => (
) => (
parse_node!(
[$(: $tags ($(:$tag_nodes),*))*];
[$(:$nodes,)* :text(~".")];
$($rest)*
)
);

{
(
[$(:$tags:ident ($(:$tag_nodes:expr),*) )*];
[$(:$nodes:expr),*];
$word:ident $($rest:tt)*
} => (
) => (
parse_node!(
[$(: $tags ($(:$tag_nodes),*))*];
[$(:$nodes,)* :text(stringify!($word))];
$($rest)*
)
);

{ []; [:$e:expr]; } => ( $e );
( []; [:$e:expr]; ) => ( $e );
)

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/macro-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn main() {
assert (mylambda!(y, y * 2)(8) == 16);

macro_rules! mylambda_tt(
{$x:ident, $body:expr} => {
($x:ident, $body:expr) => {
fn f($x: int) -> int { return $body; };
f
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/macro-3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn main() {
assert (trivial!() == 16);

macro_rules! trivial_tt(
{} => {1*2*4*2*1}
() => {1*2*4*2*1}
)
assert(trivial_tt!() == 16);
}
2 changes: 1 addition & 1 deletion src/test/run-pass/macro-by-example-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ fn main() {
#macro[[#apply[f, [x, ...]], f(x, ...)]];

macro_rules! apply_tt(
{$f:expr, ($($x:expr),*)} => {$f($($x),*)}
($f:expr, ($($x:expr),*)) => {$f($($x),*)}
)

fn add(a: int, b: int) -> int { return a + b; }
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/macro-interpolation.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

macro_rules! overly_complicated (
{$fnname:ident, $arg:ident, $ty:ty, $body:block, $val:expr, $pat:pat, $res:path} =>
($fnname:ident, $arg:ident, $ty:ty, $body:block, $val:expr, $pat:pat, $res:path) =>
{
fn $fnname($arg: $ty) -> option<$ty> $body
match $fnname($val) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ fn main() {
assert (m1!(2) == 8);

macro_rules! m1tt (
{$a:expr} => {$a*4}
($a:expr) => {$a*4}
);
assert(m1tt!(2) == 8);
}

0 comments on commit c74a442

Please sign in to comment.