Skip to content

Commit 58bd8a0

Browse files
author
Keegan McAllister
committed
---
yaml --- r: 152097 b: refs/heads/try2 c: fd40d0c h: refs/heads/master i: 152095: 7dba594 v: v3
1 parent 86f9aa8 commit 58bd8a0

File tree

4 files changed

+102
-1
lines changed

4 files changed

+102
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 55776f28221e3da7dd31c2c6c5e05f7a9a31381f
8+
refs/heads/try2: fd40d0cf5b873ebc94b64fb1abcf2e14fd38dcf7
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/test/compile-fail/macro-incomplete-parse.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,16 @@ macro_rules! ignored_expr {
2222
() => ( 1, 2 ) //~ ERROR macro expansion ignores token `,`
2323
}
2424

25+
macro_rules! ignored_pat {
26+
() => ( 1, 2 ) //~ ERROR macro expansion ignores token `,`
27+
}
28+
2529
ignored_item!()
2630

2731
fn main() {
2832
ignored_expr!()
33+
match 1 {
34+
ignored_pat!() => (),
35+
_ => (),
36+
}
2937
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(macro_rules)]
12+
13+
macro_rules! foo ( () => ( x ) )
14+
15+
fn main() {
16+
let foo!() = 2;
17+
x + 1; //~ ERROR unresolved name `x`
18+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(macro_rules)]
12+
13+
macro_rules! mypat(
14+
() => (
15+
Some('y')
16+
)
17+
)
18+
19+
macro_rules! char_x(
20+
() => (
21+
'x'
22+
)
23+
)
24+
25+
macro_rules! some(
26+
($x:pat) => (
27+
Some($x)
28+
)
29+
)
30+
31+
macro_rules! indirect(
32+
() => (
33+
some!(char_x!())
34+
)
35+
)
36+
37+
macro_rules! ident_pat(
38+
($x:ident) => (
39+
$x
40+
)
41+
)
42+
43+
fn f(c: Option<char>) -> uint {
44+
match c {
45+
Some('x') => 1,
46+
mypat!() => 2,
47+
_ => 3,
48+
}
49+
}
50+
51+
pub fn main() {
52+
assert_eq!(1, f(Some('x')));
53+
assert_eq!(2, f(Some('y')));
54+
assert_eq!(3, f(None));
55+
56+
assert_eq!(1, match Some('x') {
57+
Some(char_x!()) => 1,
58+
_ => 2,
59+
});
60+
61+
assert_eq!(1, match Some('x') {
62+
some!(char_x!()) => 1,
63+
_ => 2,
64+
});
65+
66+
assert_eq!(1, match Some('x') {
67+
indirect!() => 1,
68+
_ => 2,
69+
});
70+
71+
assert_eq!(3, {
72+
let ident_pat!(x) = 2;
73+
x+1
74+
});
75+
}

0 commit comments

Comments
 (0)