Skip to content

Commit 913f7bd

Browse files
committed
Modify pipec to not emit calls to some and none
1 parent e1b11aa commit 913f7bd

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/libcore/pipes.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ export stream, port, chan, shared_chan, port_set, channel;
9797
export oneshot, chan_one, port_one;
9898
export recv_one, try_recv_one, send_one, try_send_one;
9999

100+
// Functions used by the protocol compiler
101+
export rt;
102+
100103
#[doc(hidden)]
101104
const SPIN_COUNT: uint = 0;
102105

@@ -1194,6 +1197,13 @@ fn try_send_one<T: send>(+chan: chan_one<T>, +data: T)
11941197
oneshot::client::try_send(chan, data).is_some()
11951198
}
11961199

1200+
mod rt {
1201+
// These are used to hide the option constructors from the
1202+
// compiler because their names are changing
1203+
fn make_some<T>(+val: T) -> option<T> { some(val) }
1204+
fn make_none<T>() -> option<T> { none }
1205+
}
1206+
11971207
#[cfg(test)]
11981208
mod test {
11991209
#[test]

src/libsyntax/ext/pipes/pipec.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ impl message: gen_send {
104104
}
105105
else {
106106
body += fmt!("if pipes::send(pipe, message) {\n \
107-
some(c) \
108-
} else { none } }");
107+
pipes::rt::make_some(c) \
108+
} else { pipes::rt::make_none() } }");
109109
}
110110

111111
let body = cx.parse_expr(body);
@@ -163,8 +163,8 @@ impl message: gen_send {
163163
body += ~" }";
164164
} else {
165165
body += fmt!("if pipes::send(pipe, message) { \
166-
some(()) \
167-
} else { none } }");
166+
pipes::rt::make_some(()) \
167+
} else { pipes::rt::make_none() } }");
168168
}
169169
170170
let body = cx.parse_expr(body);

0 commit comments

Comments
 (0)