]> git.lizzy.rs Git - rust.git/commitdiff
No longer parse the delimiters of the RHS of a macro as part of the expansion.
authorPaul Stansifer <paul.stansifer@gmail.com>
Tue, 20 Nov 2012 04:53:52 +0000 (23:53 -0500)
committerGraydon Hoare <graydon@mozilla.com>
Thu, 29 Nov 2012 20:09:10 +0000 (12:09 -0800)
src/libcore/hash.rs
src/libcore/pipes.rs
src/libcore/task/spawn.rs
src/librustc/middle/trans/alt.rs
src/libsyntax/ext/tt/macro_rules.rs
src/libsyntax/parse/parser.rs

index d938a1d41a321bf480b5a4ac11bb2a157fc6d965..cdca6852dbb6248c212b5aa53aebe00cf5729f77 100644 (file)
@@ -203,14 +203,14 @@ macro_rules! rotl (
 
         macro_rules! compress (
             ($v0:expr, $v1:expr, $v2:expr, $v3:expr) =>
-            {
+            ({
                 $v0 += $v1; $v1 = rotl!($v1, 13); $v1 ^= $v0;
                 $v0 = rotl!($v0, 32);
                 $v2 += $v3; $v3 = rotl!($v3, 16); $v3 ^= $v2;
                 $v0 += $v3; $v3 = rotl!($v3, 21); $v3 ^= $v0;
                 $v2 += $v1; $v1 = rotl!($v1, 17); $v1 ^= $v2;
                 $v2 = rotl!($v2, 32);
-            }
+            })
         );
 
         let length = msg.len();
index 9a6f05fe4051931c33e3d3a86b140c249c9e55ba..561732057cf3c5b049a556ba3124a671d2bb4fd3 100644 (file)
@@ -86,7 +86,7 @@
 const SPIN_COUNT: uint = 0;
 
 macro_rules! move_it (
-    { $x:expr } => { unsafe { let y = move *ptr::addr_of(&($x)); move y } }
+    { $x:expr } => ( unsafe { let y = move *ptr::addr_of(&($x)); move y } )
 )
 
 #[doc(hidden)]
index ea66776d22d66a8acb97c1e1eefc43a020e540ed..b4bea442e69cca434f8ea6fb8990a2866d5b5a67 100644 (file)
@@ -67,7 +67,7 @@
 use rt::rust_closure;
 
 macro_rules! move_it (
-    { $x:expr } => { unsafe { let y = move *ptr::addr_of(&($x)); move y } }
+    { $x:expr } => ( unsafe { let y = move *ptr::addr_of(&($x)); move y } )
 )
 
 type TaskSet = send_map::linear::LinearMap<*rust_task,()>;
index c8753dd0274fe944d30bf1171137c6645ef093f1..03501521129b7ac0ef2ce30753aebddb63820387 100644 (file)
@@ -831,14 +831,14 @@ fn root_pats_as_necessary(bcx: block, m: &[@Match],
 // matches should fit that sort of pattern or NONE (however, some of the
 // matches may be wildcards like _ or identifiers).
 macro_rules! any_pat (
-    ($m:expr, $pattern:pat) => {
+    ($m:expr, $pattern:pat) => (
         vec::any($m, |br| {
             match br.pats[col].node {
                 $pattern => true,
                 _ => false
             }
         })
-    }
+    )
 )
 
 fn any_box_pat(m: &[@Match], col: uint) -> bool {
index 1c62c9b2a6da2b4e925379a3be3d5f8857c58ea5..63885d5c2580bf65b77cb5a11df1106dab15fada 100644 (file)
@@ -81,12 +81,19 @@ fn generic_extension(cx: ext_ctxt, sp: span, name: ident,
                   success(named_matches) => {
                     let rhs = match rhses[i] {
                         // okay, what's your transcriber?
-                      @matched_nonterminal(nt_tt(@tt)) => tt,
-                      _ => cx.span_bug(sp, ~"bad thing in rhs")
+                        @matched_nonterminal(nt_tt(@tt)) => {
+                            match tt {
+                                // cut off delimiters; don't parse 'em
+                                tt_delim(tts) => tts.slice(1u,tts.len()-1u),
+                                _ => cx.span_fatal(
+                                    sp, ~"macro rhs must be delimited")
+                            }
+                        },
+                        _ => cx.span_bug(sp, ~"bad thing in rhs")
                     };
                     // rhs has holes ( `$id` and `$(...)` that need filled)
                     let trncbr = new_tt_reader(s_d, itr, Some(named_matches),
-                                               ~[rhs]);
+                                               rhs);
                     let p = @Parser(cx.parse_sess(), cx.cfg(),
                                     trncbr as reader);
 
index 638a02775d933f10dd746530f36942d6af0d874f..4ccbdd0f8ed24b550a01f14ee8a256af295fc5c3 100644 (file)
@@ -120,7 +120,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 e;
@@ -131,33 +131,33 @@ macro_rules! maybe_whole_expr (
                        expr_path(pt));
       }
       _ => ()
-    }}
+    })
 )
 
 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); }
       _ => ()
-    }}
+    })
 
 )