diff options
| author | bors <bors@rust-lang.org> | 2013-12-11 01:06:21 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-12-11 01:06:21 -0800 |
| commit | fff03a5fc74f8e9430cc330907122ccd3782866d (patch) | |
| tree | 59b4f7086e43c8075488b00318cdc24ec5999345 /src/libsyntax | |
| parent | b8516de48f3f535f3de888652bed1dca4e489348 (diff) | |
| parent | bd36b06f555a552b7a66fbc3bd749eb7226be4fa (diff) | |
| download | rust-fff03a5fc74f8e9430cc330907122ccd3782866d.tar.gz rust-fff03a5fc74f8e9430cc330907122ccd3782866d.zip | |
auto merge of #10808 : kballard/rust/use-braces, r=alexcrichton
This fixes #10806.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 15 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 8 |
2 files changed, 21 insertions, 2 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 9ebcfaae7c5..4270a4d0dc5 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -4828,6 +4828,21 @@ impl Parser { fn parse_view_path(&self) -> @view_path { let lo = self.span.lo; + if *self.token == token::LBRACE { + // use {foo,bar} + let idents = self.parse_unspanned_seq( + &token::LBRACE, &token::RBRACE, + seq_sep_trailing_allowed(token::COMMA), + |p| p.parse_path_list_ident()); + let path = ast::Path { + span: mk_sp(lo, self.span.hi), + global: false, + segments: ~[] + }; + return @spanned(lo, self.span.hi, + view_path_list(path, idents, ast::DUMMY_NODE_ID)); + } + let first_ident = self.parse_ident(); let mut path = ~[first_ident]; debug!("parsed view_path: {}", self.id_to_str(first_ident)); diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index ea382e1cefe..19133fad9ee 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1935,8 +1935,12 @@ pub fn print_view_path(s: @ps, vp: &ast::view_path) { } ast::view_path_list(ref path, ref idents, _) => { - print_path(s, path, false); - word(s.s, "::{"); + if path.segments.is_empty() { + word(s.s, "{"); + } else { + print_path(s, path, false); + word(s.s, "::{"); + } commasep(s, inconsistent, (*idents), |s, w| { print_ident(s, w.node.name); }); |
