Skip to content

Commit ee66830

Browse files
committed
---
yaml --- r: 27880 b: refs/heads/try c: 7bae344 h: refs/heads/master v: v3
1 parent b57b80a commit ee66830

File tree

4 files changed

+68
-60
lines changed

4 files changed

+68
-60
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
5-
refs/heads/try: 9260b02daafe26025a99d44ddaeeb89e5f3382be
5+
refs/heads/try: 7bae3449ce5113596c7cdbd1df3d27bdbd0cd777
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df

branches/try/src/libsyntax/ext/pipes/ast_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ trait ext_ctxt_ast_builder {
6969
span: span,
7070
+enum_definition: ast::enum_def,
7171
+ty_params: ~[ast::ty_param]) -> @ast::item;
72-
fn item_enum(name: ident, span: span,
72+
fn item_enum(name: ident, span: span,
7373
+enum_definition: ast::enum_def) -> @ast::item;
7474
fn variant(name: ident, span: span, +tys: ~[@ast::ty]) -> ast::variant;
7575
fn item_mod(name: ident, span: span, +items: ~[@ast::item]) -> @ast::item;

branches/try/src/test/run-pass/pipe-select-macro.rs

Lines changed: 3 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -22,63 +22,8 @@ proto! bar {
2222
}
2323
}
2424

25-
26-
// select!
27-
macro_rules! select_if {
28-
29-
{
30-
$index:expr,
31-
$count:expr
32-
} => {
33-
fail
34-
};
35-
36-
{
37-
$index:expr,
38-
$count:expr,
39-
$port:path => [
40-
$(type_this $message:path$(($(x $x: ident),+))dont_type_this*
41-
-> $next:ident => { $e:expr }),+
42-
]
43-
$(, $ports:path => [
44-
$(type_this $messages:path$(($(x $xs: ident),+))dont_type_this*
45-
-> $nexts:ident => { $es:expr }),+
46-
] )*
47-
} => {
48-
if $index == $count {
49-
match move pipes::try_recv($port) {
50-
$(some($message($($($x,)+)* next)) => {
51-
// FIXME (#2329) we really want move out of enum here.
52-
let $next = unsafe { let x <- *ptr::addr_of(next); x };
53-
$e
54-
})+
55-
_ => fail
56-
}
57-
} else {
58-
select_if!{
59-
$index,
60-
$count + 1
61-
$(, $ports => [
62-
$(type_this $messages$(($(x $xs),+))dont_type_this*
63-
-> $nexts => { $es }),+
64-
])*
65-
}
66-
}
67-
};
68-
}
69-
70-
macro_rules! select {
71-
{
72-
$( $port:path => {
73-
$($message:path$(($($x: ident),+))dont_type_this*
74-
-> $next:ident $e:expr),+
75-
} )+
76-
} => {
77-
let index = pipes::selecti([$(($port).header()),+]/_);
78-
select_if!{index, 0 $(, $port => [
79-
$(type_this $message$(($(x $x),+))dont_type_this* -> $next => { $e }),+
80-
])+}
81-
}
25+
fn macros() {
26+
include!("select-macro.rs");
8227
}
8328

8429
// Code
@@ -97,7 +42,7 @@ fn test(+foo: foo::client::foo, +bar: bar::client::bar) {
9742
},
9843

9944
do_baz(b) -> _next {
100-
if b { debug!("true") } else { debug!("false") }
45+
if *b { debug!("true") } else { debug!("false") }
10146
}
10247
}
10348
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// xfail-test - this isn't really a test.
2+
3+
{
4+
5+
// select!
6+
macro_rules! select_if {
7+
8+
{
9+
$index:expr,
10+
$count:expr
11+
} => {
12+
fail
13+
};
14+
15+
{
16+
$index:expr,
17+
$count:expr,
18+
$port:path => [
19+
$(type_this $message:path$(($(x $x: ident),+))dont_type_this*
20+
-> $next:ident => { $e:expr }),+
21+
]
22+
$(, $ports:path => [
23+
$(type_this $messages:path$(($(x $xs: ident),+))dont_type_this*
24+
-> $nexts:ident => { $es:expr }),+
25+
] )*
26+
} => {
27+
if $index == $count {
28+
match move pipes::try_recv($port) {
29+
$(some($message($($(ref $x,)+)* ref next)) => {
30+
// FIXME (#2329) we really want move out of enum here.
31+
let $next = unsafe { let x <- *ptr::addr_of(*next); x };
32+
$e
33+
})+
34+
_ => fail
35+
}
36+
} else {
37+
select_if!{
38+
$index,
39+
$count + 1
40+
$(, $ports => [
41+
$(type_this $messages$(($(x $xs),+))dont_type_this*
42+
-> $nexts => { $es }),+
43+
])*
44+
}
45+
}
46+
};
47+
}
48+
49+
macro_rules! select {
50+
{
51+
$( $port:path => {
52+
$($message:path$(($($x: ident),+))dont_type_this*
53+
-> $next:ident $e:expr),+
54+
} )+
55+
} => {
56+
let index = pipes::selecti([$(($port).header()),+]/_);
57+
select_if!{index, 0 $(, $port => [
58+
$(type_this $message$(($(x $x),+))dont_type_this* -> $next => { $e }),+
59+
])+}
60+
}
61+
}
62+
63+
}

0 commit comments

Comments
 (0)