mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-28 20:16:58 +03:00
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.
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user