Skip to content

Commit ad8430e

Browse files
huonwalexcrichton
authored andcommitted
---
yaml --- r: 149538 b: refs/heads/try2 c: 6757053 h: refs/heads/master v: v3
1 parent 6a17f9d commit ad8430e

File tree

6 files changed

+95
-4
lines changed

6 files changed

+95
-4
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: 0309104cc59d6290fba2fe6dd9bfdc18aacab5f8
8+
refs/heads/try2: 6757053cffb585249105fbd76f83a2fe7501219b
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libsyntax/parse/parser.rs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3185,15 +3185,35 @@ impl Parser {
31853185
let pth = self.parse_path(NoTypesAllowed).path;
31863186
self.bump();
31873187

3188-
let id = if self.token == token::LPAREN {
3188+
let id = if self.token == token::LPAREN || self.token == token::LBRACE {
31893189
token::special_idents::invalid // no special identifier
31903190
} else {
31913191
self.parse_ident()
31923192
};
31933193

3194+
// check that we're pointing at delimiters (need to check
3195+
// again after the `if`, because of `parse_ident`
3196+
// consuming more tokens).
3197+
let (bra, ket) = match self.token {
3198+
token::LPAREN => (token::LPAREN, token::RPAREN),
3199+
token::LBRACE => (token::LBRACE, token::RBRACE),
3200+
_ => {
3201+
// we only expect an ident if we didn't parse one
3202+
// above.
3203+
let ident_str = if id == token::special_idents::invalid {
3204+
"identifier, "
3205+
} else {
3206+
""
3207+
};
3208+
let tok_str = self.this_token_to_str();
3209+
self.fatal(format!("expected {}`(` or `\\{`, but found `{}`",
3210+
ident_str, tok_str))
3211+
}
3212+
};
3213+
31943214
let tts = self.parse_unspanned_seq(
3195-
&token::LPAREN,
3196-
&token::RPAREN,
3215+
&bra,
3216+
&ket,
31973217
seq_sep_none(),
31983218
|p| p.parse_token_tree()
31993219
);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
fn main() {
12+
foo! bar < //~ ERROR expected `(` or `{`, but found `<`
13+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
fn main() {
12+
foo! {
13+
bar, "baz", 1, 2.0
14+
) //~ ERROR incorrect close delimiter
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
fn main() {
12+
foo! (
13+
bar, "baz", 1, 2.0
14+
} //~ ERROR incorrect close delimiter
15+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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! expr (($e: expr) => { $e })
14+
15+
macro_rules! spawn {
16+
($($code: tt)*) => {
17+
expr!(spawn(proc() {$($code)*}))
18+
}
19+
}
20+
21+
pub fn main() {
22+
spawn! {
23+
info!("stmt");
24+
};
25+
let _ = spawn! {
26+
info!("expr");
27+
};
28+
}

0 commit comments

Comments
 (0)