Skip to content

Commit 9814e58

Browse files
paulstansifergraydon
authored andcommitted
No longer parse the delimiters of the RHS of a macro as part of the expansion.
1 parent ba354b1 commit 9814e58

File tree

6 files changed

+28
-21
lines changed

6 files changed

+28
-21
lines changed

src/libcore/hash.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,14 @@ impl &SipState : io::Writer {
203203

204204
macro_rules! compress (
205205
($v0:expr, $v1:expr, $v2:expr, $v3:expr) =>
206-
{
206+
({
207207
$v0 += $v1; $v1 = rotl!($v1, 13); $v1 ^= $v0;
208208
$v0 = rotl!($v0, 32);
209209
$v2 += $v3; $v3 = rotl!($v3, 16); $v3 ^= $v2;
210210
$v0 += $v3; $v3 = rotl!($v3, 21); $v3 ^= $v0;
211211
$v2 += $v1; $v1 = rotl!($v1, 17); $v1 ^= $v2;
212212
$v2 = rotl!($v2, 32);
213-
}
213+
})
214214
);
215215

216216
let length = msg.len();

src/libcore/pipes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ use option::unwrap;
8686
const SPIN_COUNT: uint = 0;
8787

8888
macro_rules! move_it (
89-
{ $x:expr } => { unsafe { let y = move *ptr::addr_of(&($x)); move y } }
89+
{ $x:expr } => ( unsafe { let y = move *ptr::addr_of(&($x)); move y } )
9090
)
9191

9292
#[doc(hidden)]

src/libcore/task/spawn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ use rt::rust_task;
6767
use rt::rust_closure;
6868

6969
macro_rules! move_it (
70-
{ $x:expr } => { unsafe { let y = move *ptr::addr_of(&($x)); move y } }
70+
{ $x:expr } => ( unsafe { let y = move *ptr::addr_of(&($x)); move y } )
7171
)
7272

7373
type TaskSet = send_map::linear::LinearMap<*rust_task,()>;

src/librustc/middle/trans/alt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,14 +831,14 @@ fn root_pats_as_necessary(bcx: block, m: &[@Match],
831831
// matches should fit that sort of pattern or NONE (however, some of the
832832
// matches may be wildcards like _ or identifiers).
833833
macro_rules! any_pat (
834-
($m:expr, $pattern:pat) => {
834+
($m:expr, $pattern:pat) => (
835835
vec::any($m, |br| {
836836
match br.pats[col].node {
837837
$pattern => true,
838838
_ => false
839839
}
840840
})
841-
}
841+
)
842842
)
843843

844844
fn any_box_pat(m: &[@Match], col: uint) -> bool {

src/libsyntax/ext/tt/macro_rules.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,19 @@ fn add_new_extension(cx: ext_ctxt, sp: span, name: ident,
8181
success(named_matches) => {
8282
let rhs = match rhses[i] {
8383
// okay, what's your transcriber?
84-
@matched_nonterminal(nt_tt(@tt)) => tt,
85-
_ => cx.span_bug(sp, ~"bad thing in rhs")
84+
@matched_nonterminal(nt_tt(@tt)) => {
85+
match tt {
86+
// cut off delimiters; don't parse 'em
87+
tt_delim(tts) => tts.slice(1u,tts.len()-1u),
88+
_ => cx.span_fatal(
89+
sp, ~"macro rhs must be delimited")
90+
}
91+
},
92+
_ => cx.span_bug(sp, ~"bad thing in rhs")
8693
};
8794
// rhs has holes ( `$id` and `$(...)` that need filled)
8895
let trncbr = new_tt_reader(s_d, itr, Some(named_matches),
89-
~[rhs]);
96+
rhs);
9097
let p = @Parser(cx.parse_sess(), cx.cfg(),
9198
trncbr as reader);
9299

src/libsyntax/parse/parser.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ enum view_item_parse_mode {
120120
The important thing is to make sure that lookahead doesn't balk
121121
at INTERPOLATED tokens */
122122
macro_rules! maybe_whole_expr (
123-
($p:expr) => { match copy $p.token {
123+
($p:expr) => ( match copy $p.token {
124124
INTERPOLATED(token::nt_expr(e)) => {
125125
$p.bump();
126126
return e;
@@ -131,33 +131,33 @@ macro_rules! maybe_whole_expr (
131131
expr_path(pt));
132132
}
133133
_ => ()
134-
}}
134+
})
135135
)
136136

137137
macro_rules! maybe_whole (
138-
($p:expr, $constructor:ident) => { match copy $p.token {
138+
($p:expr, $constructor:ident) => ( match copy $p.token {
139139
INTERPOLATED(token::$constructor(x)) => { $p.bump(); return x; }
140140
_ => ()
141-
}} ;
142-
(deref $p:expr, $constructor:ident) => { match copy $p.token {
141+
}) ;
142+
(deref $p:expr, $constructor:ident) => ( match copy $p.token {
143143
INTERPOLATED(token::$constructor(x)) => { $p.bump(); return *x; }
144144
_ => ()
145-
}} ;
146-
(Some $p:expr, $constructor:ident) => { match copy $p.token {
145+
}) ;
146+
(Some $p:expr, $constructor:ident) => ( match copy $p.token {
147147
INTERPOLATED(token::$constructor(x)) => { $p.bump(); return Some(x); }
148148
_ => ()
149-
}} ;
150-
(iovi $p:expr, $constructor:ident) => { match copy $p.token {
149+
}) ;
150+
(iovi $p:expr, $constructor:ident) => ( match copy $p.token {
151151
INTERPOLATED(token::$constructor(x)) => {
152152
$p.bump();
153153
return iovi_item(x);
154154
}
155155
_ => ()
156-
}} ;
157-
(pair_empty $p:expr, $constructor:ident) => { match copy $p.token {
156+
}) ;
157+
(pair_empty $p:expr, $constructor:ident) => ( match copy $p.token {
158158
INTERPOLATED(token::$constructor(x)) => { $p.bump(); return (~[], x); }
159159
_ => ()
160-
}}
160+
})
161161

162162
)
163163

0 commit comments

Comments
 (0)