2013-12-17 01:04:02 +00:00
|
|
|
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2014-04-14 15:30:31 +00:00
|
|
|
#![feature(macro_rules)]
|
2013-12-17 01:04:02 +00:00
|
|
|
|
2014-06-27 00:41:43 +00:00
|
|
|
// 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....
|
|
|
|
|
2013-12-17 01:04:02 +00:00
|
|
|
enum T {
|
|
|
|
A(int),
|
|
|
|
B(uint)
|
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! test(
|
2014-06-27 00:41:43 +00:00
|
|
|
($id:ident, $e:expr) => (
|
2013-12-17 01:04:02 +00:00
|
|
|
fn foo(t: T) -> int {
|
|
|
|
match t {
|
2014-11-06 08:05:53 +00:00
|
|
|
T::A($id) => $e,
|
|
|
|
T::B($id) => $e
|
2013-12-17 01:04:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
2014-11-14 17:18:10 +00:00
|
|
|
);
|
2013-12-17 01:04:02 +00:00
|
|
|
|
2014-11-14 17:18:10 +00:00
|
|
|
test!(y, 10 + (y as int));
|
2013-12-17 01:04:02 +00:00
|
|
|
|
|
|
|
pub fn main() {
|
2014-11-06 08:05:53 +00:00
|
|
|
foo(T::A(20));
|
2013-12-17 01:04:02 +00:00
|
|
|
}
|