about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2012-12-07 19:09:25 -0800
committerPatrick Walton <pcwalton@mimiga.net>2012-12-07 19:10:16 -0800
commit184f5102b37c9a52342382fe9e88144a62cd9782 (patch)
tree29ba8619bfa2c27f65cfadb64cb0461d93f4207c
parentcb7996a565b4cc37601c5248aa889fb108023f9a (diff)
downloadrust-184f5102b37c9a52342382fe9e88144a62cd9782.tar.gz
rust-184f5102b37c9a52342382fe9e88144a62cd9782.zip
libsyntax: Fix parsing of module-qualified structure patterns. rs=bugfix
-rw-r--r--src/libsyntax/parse/parser.rs30
-rw-r--r--src/test/run-pass/module-qualified-struct-destructure.rs12
2 files changed, 13 insertions, 29 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index a9a0c1bdc76..8e354f7017d 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -2046,8 +2046,6 @@ impl Parser {
                 pat = self.parse_pat_ident(refutable, bind_by_value);
             } else if self.eat_keyword(~"move") {
                 pat = self.parse_pat_ident(refutable, bind_by_move);
-            } else if !is_plain_ident(self.token) {
-                pat = self.parse_enum_variant(refutable);
             } else {
                 let binding_mode;
                 // XXX: Aren't these two cases deadcode? -- bblum
@@ -2066,7 +2064,7 @@ impl Parser {
                 let cannot_be_enum_or_struct;
                 match self.look_ahead(1) {
                     token::LPAREN | token::LBRACKET | token::LT |
-                    token::LBRACE =>
+                    token::LBRACE | token::MOD_SEP =>
                         cannot_be_enum_or_struct = false,
                     _ =>
                         cannot_be_enum_or_struct = true
@@ -2163,32 +2161,6 @@ impl Parser {
         pat_ident(binding_mode, name, sub)
     }
 
-    fn parse_enum_variant(refutable: bool) -> ast::pat_ {
-        let enum_path = self.parse_path_with_tps(true);
-        match self.token {
-          token::LPAREN => {
-            match self.look_ahead(1u) {
-              token::BINOP(token::STAR) => { // foo(*)
-                self.expect(token::LPAREN);
-                self.expect(token::BINOP(token::STAR));
-                self.expect(token::RPAREN);
-                pat_enum(enum_path, None)
-              }
-              _ => { // foo(a, ..., z)
-                let args = self.parse_unspanned_seq(
-                    token::LPAREN, token::RPAREN,
-                    seq_sep_trailing_disallowed(token::COMMA),
-                    |p| p.parse_pat(refutable));
-                pat_enum(enum_path, Some(args))
-              }
-            }
-          }
-          _ => { // option::None
-            pat_enum(enum_path, Some(~[]))
-          }
-        }
-    }
-
     fn parse_local(is_mutbl: bool,
                    allow_init: bool) -> @local {
         let lo = self.span.lo;
diff --git a/src/test/run-pass/module-qualified-struct-destructure.rs b/src/test/run-pass/module-qualified-struct-destructure.rs
new file mode 100644
index 00000000000..ee7359b0a6d
--- /dev/null
+++ b/src/test/run-pass/module-qualified-struct-destructure.rs
@@ -0,0 +1,12 @@
+mod m {
+    pub struct S {
+        x: int,
+        y: int
+    }
+}
+
+fn main() {
+    let x = m::S { x: 1, y: 2 };
+    let m::S { x: a, y: b } = x;
+}
+