summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-03-05 18:38:52 -0800
committerPatrick Walton <pcwalton@mimiga.net>2013-03-07 22:37:03 -0800
commit0ea031bcb8c237365b8bf15ae474972570cf15f9 (patch)
tree8d022c7d9aaa0cb1f943fe7c3b7acd9750a7c08a /src/libsyntax
parent954ae9c975cebb7186dfc1182a68d2559bdef4bd (diff)
downloadrust-0ea031bcb8c237365b8bf15ae474972570cf15f9.tar.gz
rust-0ea031bcb8c237365b8bf15ae474972570cf15f9.zip
librustc: Remove record patterns from the compiler
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast.rs1
-rw-r--r--src/libsyntax/ast_util.rs2
-rw-r--r--src/libsyntax/fold.rs9
-rw-r--r--src/libsyntax/parse/obsolete.rs5
-rw-r--r--src/libsyntax/parse/parser.rs11
-rw-r--r--src/libsyntax/print/pprust.rs19
-rw-r--r--src/libsyntax/visit.rs5
7 files changed, 12 insertions, 40 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 68afa38ba89..0581f5f96b0 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -302,7 +302,6 @@ pub enum pat_ {
     pat_ident(binding_mode, @path, Option<@pat>),
     pat_enum(@path, Option<~[@pat]>), /* "none" means a * pattern where
                                        * we don't bind the fields to names */
-    pat_rec(~[field_pat], bool),
     pat_struct(@path, ~[field_pat], bool),
     pat_tup(~[@pat]),
     pat_box(@pat),
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs
index ba683004aee..686ae3900ff 100644
--- a/src/libsyntax/ast_util.rs
+++ b/src/libsyntax/ast_util.rs
@@ -520,7 +520,7 @@ pub fn walk_pat(pat: @pat, it: fn(@pat)) {
     it(pat);
     match pat.node {
         pat_ident(_, _, Some(p)) => walk_pat(p, it),
-        pat_rec(ref fields, _) | pat_struct(_, ref fields, _) => {
+        pat_struct(_, ref fields, _) => {
             for fields.each |f| {
                 walk_pat(f.pat, it)
             }
diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs
index 3ada03c08f4..ea18598f75c 100644
--- a/src/libsyntax/fold.rs
+++ b/src/libsyntax/fold.rs
@@ -399,15 +399,6 @@ pub fn noop_fold_pat(p: &pat_, fld: @ast_fold) -> pat_ {
                 pats.map(|pats| pats.map(|x| fld.fold_pat(*x)))
             )
         }
-        pat_rec(ref fields, etc) => {
-            let fs = do fields.map |f| {
-                ast::field_pat {
-                    ident: /* FIXME (#2543) */ copy f.ident,
-                    pat: fld.fold_pat(f.pat),
-                }
-            };
-            pat_rec(fs, etc)
-        }
         pat_struct(pth, ref fields, etc) => {
             let pth_ = fld.fold_path(pth);
             let fs = do fields.map |f| {
diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs
index dbb44858761..4e1b34bb299 100644
--- a/src/libsyntax/parse/obsolete.rs
+++ b/src/libsyntax/parse/obsolete.rs
@@ -50,6 +50,7 @@ pub enum ObsoleteSyntax {
     ObsoleteMutVector,
     ObsoleteTraitImplVisibility,
     ObsoleteRecordType,
+    ObsoleteRecordPattern,
 }
 
 impl to_bytes::IterBytes for ObsoleteSyntax {
@@ -150,6 +151,10 @@ pub impl Parser {
                 "structural record type",
                 "use a structure instead"
             ),
+            ObsoleteRecordPattern => (
+                "structural record pattern",
+                "use a structure instead"
+            ),
         };
 
         self.report(sp, kind, kind_str, desc);
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 498b6f3ca70..2a113c44612 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -40,8 +40,8 @@ use ast::{lit_int_unsuffixed, lit_nil, lit_str, lit_uint, local, m_const};
 use ast::{m_imm, m_mutbl, mac_, mac_invoc_tt, matcher, match_nonterminal};
 use ast::{match_seq, match_tok, method, mode, module_ns, mt, mul, mutability};
 use ast::{named_field, neg, node_id, noreturn, not, pat, pat_box, pat_enum};
-use ast::{pat_ident, pat_lit, pat_range, pat_rec, pat_region, pat_struct};
-use ast::{pat_tup, pat_uniq, pat_wild, path, private};
+use ast::{pat_ident, pat_lit, pat_range, pat_region, pat_struct, pat_tup};
+use ast::{pat_uniq, pat_wild, path, private};
 use ast::{re_self, re_anon, re_named, region, rem, required};
 use ast::{ret_style, return_val, self_ty, shl, shr, stmt, stmt_decl};
 use ast::{stmt_expr, stmt_semi, stmt_mac, struct_def, struct_field};
@@ -75,7 +75,7 @@ use parse::obsolete::{ObsoleteSyntax, ObsoleteLowerCaseKindBounds};
 use parse::obsolete::{ObsoleteUnsafeBlock, ObsoleteImplSyntax};
 use parse::obsolete::{ObsoleteTraitBoundSeparator, ObsoleteMutOwnedPointer};
 use parse::obsolete::{ObsoleteMutVector, ObsoleteTraitImplVisibility};
-use parse::obsolete::{ObsoleteRecordType};
+use parse::obsolete::{ObsoleteRecordType, ObsoleteRecordPattern};
 use parse::prec::{as_prec, token_to_binop};
 use parse::token::{can_begin_expr, is_ident, is_ident_or_path};
 use parse::token::{is_plain_ident, INTERPOLATED, special_idents};
@@ -2192,10 +2192,11 @@ pub impl Parser {
           }
           token::LBRACE => {
             self.bump();
-            let (fields, etc) = self.parse_pat_fields(refutable);
+            let (_, _) = self.parse_pat_fields(refutable);
             hi = self.span.hi;
             self.bump();
-            pat = pat_rec(fields, etc);
+            self.obsolete(*self.span, ObsoleteRecordPattern);
+            pat = pat_wild;
           }
           token::LPAREN => {
             self.bump();
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 8e26f37d7de..c0ce8ec45aa 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -1574,25 +1574,6 @@ pub fn print_pat(s: @ps, &&pat: @ast::pat, refutable: bool) {
           }
         }
       }
-      ast::pat_rec(fields, etc) => {
-        word(s.s, ~"{");
-        fn print_field(s: @ps, f: ast::field_pat, refutable: bool) {
-            cbox(s, indent_unit);
-            print_ident(s, f.ident);
-            word_space(s, ~":");
-            print_pat(s, f.pat, refutable);
-            end(s);
-        }
-        fn get_span(f: ast::field_pat) -> codemap::span { return f.pat.span; }
-        commasep_cmnt(s, consistent, fields,
-                      |s, f| print_field(s, f, refutable),
-                      get_span);
-        if etc {
-            if vec::len(fields) != 0u { word_space(s, ~","); }
-            word(s.s, ~"_");
-        }
-        word(s.s, ~"}");
-      }
       ast::pat_struct(path, fields, etc) => {
         print_path(s, path, true);
         word(s.s, ~"{");
diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs
index 2f086534ed5..8b277b22149 100644
--- a/src/libsyntax/visit.rs
+++ b/src/libsyntax/visit.rs
@@ -263,11 +263,6 @@ pub fn visit_pat<E>(p: @pat, e: E, v: vt<E>) {
                 for children.each |child| { (v.visit_pat)(*child, e, v); }
             }
         }
-        pat_rec(ref fields, _) => {
-            for fields.each |f| {
-                (v.visit_pat)(f.pat, e, v)
-            }
-        },
         pat_struct(path, ref fields, _) => {
             visit_path(path, e, v);
             for fields.each |f| {