提交 ee1ee7f4 编写于 作者: J John Clements

make tests hygienic...

... and possibly totally pointless. Specifically, fixing
these to make their macros hygienic may mean that they no
longer test the thing that they were supposed to test.
上级 235ca180
......@@ -10,23 +10,28 @@
#![feature(macro_rules)]
// after fixing #9384 and implementing hygiene for match bindings,
// this now fails because the insertion of the 'y' into the match
// doesn't cause capture. Making this macro hygienic (as I've done)
// could very well make this test case completely pointless....
enum T {
A(int),
B(uint)
}
macro_rules! test(
($e:expr) => (
($id:ident, $e:expr) => (
fn foo(t: T) -> int {
match t {
A(y) => $e,
B(y) => $e
A($id) => $e,
B($id) => $e
}
}
)
)
test!(10 + (y as int))
test!(y, 10 + (y as int))
pub fn main() {
foo(A(20));
......
......@@ -15,19 +15,24 @@ enum T {
B(f64)
}
// after fixing #9384 and implementing hygiene for match bindings,
// this now fails because the insertion of the 'y' into the match
// doesn't cause capture. Making this macro hygienic (as I've done)
// could very well make this test case completely pointless....
macro_rules! test(
($e:expr) => (
($id1:ident, $id2:ident, $e:expr) => (
fn foo(a:T, b:T) -> T {
match (a, b) {
(A(x), A(y)) => A($e),
(B(x), B(y)) => B($e),
(A($id1), A($id2)) => A($e),
(B($id1), B($id2)) => B($e),
_ => fail!()
}
}
)
)
test!(x + y)
test!(x,y,x + y)
pub fn main() {
foo(A(1), A(2));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册