Skip to content

Commit e0b4287

Browse files
committed
Fix fallout
1 parent 6680c9c commit e0b4287

File tree

7 files changed

+200
-202
lines changed

7 files changed

+200
-202
lines changed

src/doc/guide-macros.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ instead of `*` to mean "at least one".
161161
# let input_1 = T::SpecialA(0);
162162
# let input_2 = T::SpecialA(0);
163163
macro_rules! early_return {
164-
($inp:expr, [ $($sp:path)|+ ]) => (
164+
($inp:expr, [ $($sp:path),+ ]) => (
165165
match $inp {
166166
$(
167167
$sp(x) => { return x; }
@@ -171,7 +171,7 @@ macro_rules! early_return {
171171
)
172172
}
173173
// ...
174-
early_return!(input_1, [T::SpecialA|T::SpecialC|T::SpecialD]);
174+
early_return!(input_1, [T::SpecialA,T::SpecialC,T::SpecialD]);
175175
// ...
176176
early_return!(input_2, [T::SpecialB]);
177177
# return 0;
@@ -245,7 +245,7 @@ can solve the problem:
245245
~~~~
246246
macro_rules! biased_match {
247247
// special case: `let (x) = ...` is illegal, so use `let x = ...` instead
248-
( ($e:expr) ~ ($p:pat) else $err:stmt ;
248+
( ($e:expr) -> ($p:pat) else $err:stmt ;
249249
binds $bind_res:ident
250250
) => (
251251
let $bind_res = match $e {
@@ -254,7 +254,7 @@ macro_rules! biased_match {
254254
};
255255
);
256256
// more than one name; use a tuple
257-
( ($e:expr) ~ ($p:pat) else $err:stmt ;
257+
( ($e:expr) -> ($p:pat) else $err:stmt ;
258258
binds $( $bind_res:ident ),*
259259
) => (
260260
let ( $( $bind_res ),* ) = match $e {
@@ -268,9 +268,9 @@ macro_rules! biased_match {
268268
# struct T2 { body: T3 }
269269
# enum T3 { Good2(uint), Bad2}
270270
# fn f(x: T1) -> uint {
271-
biased_match!((x) ~ (T1::Good1(g1, val)) else { return 0 };
271+
biased_match!((x) -> (T1::Good1(g1, val)) else { return 0 };
272272
binds g1, val );
273-
biased_match!((g1.body) ~ (T3::Good2(result) )
273+
biased_match!((g1.body) -> (T3::Good2(result) )
274274
else { panic!("Didn't get good_2") };
275275
binds result );
276276
// complicated stuff goes here
@@ -286,7 +286,7 @@ pattern we want is clear:
286286
~~~~
287287
# fn main() {}
288288
# macro_rules! b {
289-
( $( ($e:expr) ~ ($p:pat) else $err:stmt ; )*
289+
( $( ($e:expr) -> ($p:pat) else $err:stmt ; )*
290290
binds $( $bind_res:ident ),*
291291
)
292292
# => (0) }
@@ -317,8 +317,8 @@ input patterns:
317317
~~~~
318318
# fn main() {}
319319
# macro_rules! b {
320-
( ($e :expr) ~ ($p :pat) else $err :stmt ;
321-
$( ($e_rest:expr) ~ ($p_rest:pat) else $err_rest:stmt ; )*
320+
( ($e :expr) -> ($p :pat) else $err :stmt ;
321+
$( ($e_rest:expr) -> ($p_rest:pat) else $err_rest:stmt ; )*
322322
binds $( $bind_res:ident ),*
323323
)
324324
# => (0) }
@@ -333,14 +333,14 @@ piece of syntax (the `let`) which we only want to transcribe once.
333333
334334
macro_rules! biased_match_rec {
335335
// Handle the first layer
336-
( ($e :expr) ~ ($p :pat) else $err :stmt ;
337-
$( ($e_rest:expr) ~ ($p_rest:pat) else $err_rest:stmt ; )*
336+
( ($e :expr) -> ($p :pat) else $err :stmt ;
337+
$( ($e_rest:expr) -> ($p_rest:pat) else $err_rest:stmt ; )*
338338
binds $( $bind_res:ident ),*
339339
) => (
340340
match $e {
341341
$p => {
342342
// Recursively handle the next layer
343-
biased_match_rec!($( ($e_rest) ~ ($p_rest) else $err_rest ; )*
343+
biased_match_rec!($( ($e_rest) -> ($p_rest) else $err_rest ; )*
344344
binds $( $bind_res ),*
345345
)
346346
}
@@ -354,20 +354,20 @@ macro_rules! biased_match_rec {
354354
// Wrap the whole thing in a `let`.
355355
macro_rules! biased_match {
356356
// special case: `let (x) = ...` is illegal, so use `let x = ...` instead
357-
( $( ($e:expr) ~ ($p:pat) else $err:stmt ; )*
357+
( $( ($e:expr) -> ($p:pat) else $err:stmt ; )*
358358
binds $bind_res:ident
359359
) => (
360360
let $bind_res = biased_match_rec!(
361-
$( ($e) ~ ($p) else $err ; )*
361+
$( ($e) -> ($p) else $err ; )*
362362
binds $bind_res
363363
);
364364
);
365365
// more than one name: use a tuple
366-
( $( ($e:expr) ~ ($p:pat) else $err:stmt ; )*
366+
( $( ($e:expr) -> ($p:pat) else $err:stmt ; )*
367367
binds $( $bind_res:ident ),*
368368
) => (
369369
let ( $( $bind_res ),* ) = biased_match_rec!(
370-
$( ($e) ~ ($p) else $err ; )*
370+
$( ($e) -> ($p) else $err ; )*
371371
binds $( $bind_res ),*
372372
);
373373
)
@@ -379,8 +379,8 @@ macro_rules! biased_match {
379379
# enum T3 { Good2(uint), Bad2}
380380
# fn f(x: T1) -> uint {
381381
biased_match!(
382-
(x) ~ (T1::Good1(g1, val)) else { return 0 };
383-
(g1.body) ~ (T3::Good2(result) ) else { panic!("Didn't get Good2") };
382+
(x) -> (T1::Good1(g1, val)) else { return 0 };
383+
(g1.body) -> (T3::Good2(result) ) else { panic!("Didn't get Good2") };
384384
binds val, result );
385385
// complicated stuff goes here
386386
return result + val;

src/libcore/str/mod.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,16 @@ use slice::{self, SliceExt};
3535
use uint;
3636

3737
macro_rules! delegate_iter {
38-
(exact $te:ty in $ti:ty) => {
39-
delegate_iter!{$te in $ti}
40-
#[stable]
38+
(exact $te:ty : $ti:ty) => {
39+
delegate_iter!{$te : $ti}
4140
impl<'a> ExactSizeIterator for $ti {
4241
#[inline]
4342
fn len(&self) -> uint {
4443
self.0.len()
4544
}
4645
}
4746
};
48-
($te:ty in $ti:ty) => {
47+
($te:ty : $ti:ty) => {
4948
#[stable]
5049
impl<'a> Iterator for $ti {
5150
type Item = $te;
@@ -67,7 +66,7 @@ macro_rules! delegate_iter {
6766
}
6867
}
6968
};
70-
(pattern $te:ty in $ti:ty) => {
69+
(pattern $te:ty : $ti:ty) => {
7170
#[stable]
7271
impl<'a, P: CharEq> Iterator for $ti {
7372
type Item = $te;
@@ -89,7 +88,7 @@ macro_rules! delegate_iter {
8988
}
9089
}
9190
};
92-
(pattern forward $te:ty in $ti:ty) => {
91+
(pattern forward $te:ty : $ti:ty) => {
9392
#[stable]
9493
impl<'a, P: CharEq> Iterator for $ti {
9594
type Item = $te;
@@ -415,7 +414,7 @@ impl<'a> DoubleEndedIterator for CharIndices<'a> {
415414
#[stable]
416415
#[derive(Clone)]
417416
pub struct Bytes<'a>(Map<&'a u8, u8, slice::Iter<'a, u8>, BytesDeref>);
418-
delegate_iter!{exact u8 in Bytes<'a>}
417+
delegate_iter!{exact u8 : Bytes<'a>}
419418

420419
/// A temporary fn new type that ensures that the `Bytes` iterator
421420
/// is cloneable.
@@ -1165,25 +1164,25 @@ impl<'a, S: ?Sized> Str for &'a S where S: Str {
11651164
#[derive(Clone)]
11661165
#[stable]
11671166
pub struct Split<'a, P>(CharSplits<'a, P>);
1168-
delegate_iter!{pattern &'a str in Split<'a, P>}
1167+
delegate_iter!{pattern &'a str : Split<'a, P>}
11691168

11701169
/// Return type of `StrExt::split_terminator`
11711170
#[derive(Clone)]
11721171
#[unstable = "might get removed in favour of a constructor method on Split"]
11731172
pub struct SplitTerminator<'a, P>(CharSplits<'a, P>);
1174-
delegate_iter!{pattern &'a str in SplitTerminator<'a, P>}
1173+
delegate_iter!{pattern &'a str : SplitTerminator<'a, P>}
11751174

11761175
/// Return type of `StrExt::splitn`
11771176
#[derive(Clone)]
11781177
#[stable]
11791178
pub struct SplitN<'a, P>(CharSplitsN<'a, P>);
1180-
delegate_iter!{pattern forward &'a str in SplitN<'a, P>}
1179+
delegate_iter!{pattern forward &'a str : SplitN<'a, P>}
11811180

11821181
/// Return type of `StrExt::rsplitn`
11831182
#[derive(Clone)]
11841183
#[stable]
11851184
pub struct RSplitN<'a, P>(CharSplitsN<'a, P>);
1186-
delegate_iter!{pattern forward &'a str in RSplitN<'a, P>}
1185+
delegate_iter!{pattern forward &'a str : RSplitN<'a, P>}
11871186

11881187
/// Methods for string slices
11891188
#[allow(missing_docs)]

0 commit comments

Comments
 (0)