Skip to content

Commit f90ded8

Browse files
committed
---
yaml --- r: 94206 b: refs/heads/try c: 5c2f8aa h: refs/heads/master v: v3
1 parent 80efeaf commit f90ded8

File tree

6 files changed

+131
-4
lines changed

6 files changed

+131
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 0da105a8b7b6b1e0568e8ff20f6ff4b13cc7ecc2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d3e57dca68fde4effdda3e4ae2887aa535fcd6
5-
refs/heads/try: 5a93d12e01c8275674bcdb6f3f765a7bdcf08779
5+
refs/heads/try: 5c2f8aa330575f001a7d15b8ccd335aaa337bf8b
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

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

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2807,18 +2807,33 @@ impl Parser {
28072807
}
28082808

28092809
let lo1 = self.last_span.lo;
2810+
let bind_type = if self.eat_keyword(keywords::Mut) {
2811+
BindByValue(MutMutable)
2812+
} else if self.eat_keyword(keywords::Ref) {
2813+
BindByRef(self.parse_mutability())
2814+
} else {
2815+
BindByValue(MutImmutable)
2816+
};
2817+
28102818
let fieldname = self.parse_ident();
28112819
let hi1 = self.last_span.lo;
28122820
let fieldpath = ast_util::ident_to_path(mk_sp(lo1, hi1),
28132821
fieldname);
28142822
let subpat;
28152823
if *self.token == token::COLON {
2824+
match bind_type {
2825+
BindByRef(..) | BindByValue(MutMutable) =>
2826+
self.fatal(format!("unexpected `{}`",
2827+
self.this_token_to_str())),
2828+
_ => {}
2829+
}
2830+
28162831
self.bump();
28172832
subpat = self.parse_pat();
28182833
} else {
28192834
subpat = @ast::Pat {
28202835
id: ast::DUMMY_NODE_ID,
2821-
node: PatIdent(BindByValue(MutImmutable), fieldpath, None),
2836+
node: PatIdent(bind_type, fieldpath, None),
28222837
span: *self.last_span
28232838
};
28242839
}
@@ -4813,6 +4828,21 @@ impl Parser {
48134828
fn parse_view_path(&self) -> @view_path {
48144829
let lo = self.span.lo;
48154830

4831+
if *self.token == token::LBRACE {
4832+
// use {foo,bar}
4833+
let idents = self.parse_unspanned_seq(
4834+
&token::LBRACE, &token::RBRACE,
4835+
seq_sep_trailing_allowed(token::COMMA),
4836+
|p| p.parse_path_list_ident());
4837+
let path = ast::Path {
4838+
span: mk_sp(lo, self.span.hi),
4839+
global: false,
4840+
segments: ~[]
4841+
};
4842+
return @spanned(lo, self.span.hi,
4843+
view_path_list(path, idents, ast::DUMMY_NODE_ID));
4844+
}
4845+
48164846
let first_ident = self.parse_ident();
48174847
let mut path = ~[first_ident];
48184848
debug!("parsed view_path: {}", self.id_to_str(first_ident));

branches/try/src/libsyntax/print/pprust.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1935,8 +1935,12 @@ pub fn print_view_path(s: @ps, vp: &ast::view_path) {
19351935
}
19361936

19371937
ast::view_path_list(ref path, ref idents, _) => {
1938-
print_path(s, path, false);
1939-
word(s.s, "::{");
1938+
if path.segments.is_empty() {
1939+
word(s.s, "{");
1940+
} else {
1941+
print_path(s, path, false);
1942+
word(s.s, "::{");
1943+
}
19401944
commasep(s, inconsistent, (*idents), |s, w| {
19411945
print_ident(s, w.node.name);
19421946
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2013 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+
struct Foo { x: int }
13+
match Foo { x: 10 } {
14+
Foo { ref x: ref x } => {}, //~ ERROR unexpected `:`
15+
_ => {}
16+
}
17+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2013 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+
pub fn main() {
12+
struct Foo { x: int, y: int }
13+
let mut f = Foo { x: 10, y: 0 };
14+
match f {
15+
Foo { ref mut x, .. } => *x = 11,
16+
}
17+
match f {
18+
Foo { ref x, ref y } => {
19+
assert_eq!(f.x, 11);
20+
assert_eq!(f.y, 0);
21+
}
22+
}
23+
match f {
24+
Foo { mut x, y: ref mut y } => {
25+
x = 12;
26+
*y = 1;
27+
}
28+
}
29+
assert_eq!(f.x, 11);
30+
assert_eq!(f.y, 1);
31+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright 2013 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+
// xfail-fast
12+
13+
pub fn foo() -> int {
14+
3
15+
}
16+
pub fn bar() -> int {
17+
4
18+
}
19+
20+
pub mod baz {
21+
use {foo, bar};
22+
pub fn quux() -> int {
23+
foo() + bar()
24+
}
25+
}
26+
27+
pub mod grault {
28+
use {foo};
29+
pub fn garply() -> int {
30+
foo()
31+
}
32+
}
33+
34+
pub mod waldo {
35+
use {};
36+
pub fn plugh() -> int {
37+
0
38+
}
39+
}
40+
41+
fn main() {
42+
let _x = baz::quux();
43+
let _y = grault::garply();
44+
let _z = waldo::plugh();
45+
}

0 commit comments

Comments
 (0)